cpal
cpal copied to clipboard
What audio device to use? Platform: Android
Hello!
I'm working with Android and have encountered an issue where the default device selected is the earpiece. This is unfortunately not what I want, I rather have the speaker. From the creation code I cannot find a way to figure out what device to use as only the name and output configuration is available, in my case they all are identical to name and output.
So I figure I go down and into the creation of the host. Changing the default_output_device function to ->
fn default_output_device(&self) -> Option<Self::Device> {
if let Ok(devices) = oboe::AudioDeviceInfo::request(oboe::AudioDeviceDirection::Output) {
devices
.into_iter()
//New filtration to remove the earpiece device
.filter(|d| d.device_type as i32 != oboe::AudioDeviceType::BuiltinEarpiece as i32)
.map(|d| Device(Some(d)))
.next()
} else {
Some(Device(None))
}
}
Solves my issue.
But I don't see that being an approach for everyone. So I'm curious if there is any other ideas on how to allow the selection of device? oboe exposes the device type but cpal does not seem to have that in today so I'm a little out of nifty ideas.
Perhaps the oboe host should expose a platform-specific interface to take ownership of an oboe device that you can construct manually per your preferences?
Yes that would be preferably, giving the user on that platform access to all the information provided by the platform.
Are there any other such examples of platform specific interfaces found in cpal that can be used as reference design?
Resolved by #638