Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device types introduced in API level 31 or Android Tiramisu #44

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/java_interface/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ pub struct AudioDeviceInfo {
pub enum AudioDeviceType {
Unknown = 0,
AuxLine = 19,
BleBroadcast = 30,
BleHeadset = 26,
BleSpeaker = 27,
BluetoothA2DP = 8,
BluetoothSCO = 7,
BuiltinEarpiece = 1,
Expand All @@ -100,17 +103,20 @@ pub enum AudioDeviceType {
FmTuner = 16,
Hdmi = 9,
HdmiArc = 10,
HdmiEarc = 29,
HearingAid = 23,
Ip = 20,
LineAnalog = 5,
LineDigital = 6,
RemoteSubmix = 25,
Telephony = 18,
TvTuner = 17,
UsbAccessory = 12,
UsbDevice = 11,
UsbHeadset = 22,
WiredHeadphones = 4,
WiredHeadset = 3,
Unsupported = -1,
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/java_interface/devices_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::{
call_method_no_args_ret_string, get_context, get_devices, get_system_service,
with_attached, JNIEnv, JObject, JResult,
},
AudioDeviceDirection, AudioDeviceInfo, Context,
AudioDeviceDirection, AudioDeviceInfo, AudioDeviceType, Context,
};

impl AudioDeviceInfo {
Expand Down Expand Up @@ -63,7 +63,7 @@ fn try_request_devices_info<'a>(
device_type: FromPrimitive::from_i32(call_method_no_args_ret_int(
env, device, "getType",
)?)
.unwrap(),
.unwrap_or(AudioDeviceType::Unsupported),
direction: AudioDeviceDirection::new(
call_method_no_args_ret_bool(env, device, "isSource")?,
call_method_no_args_ret_bool(env, device, "isSink")?,
Expand Down