Remove current broken implementation of current_device()

This commit is contained in:
Paul Adenot 2023-11-21 15:55:23 +01:00
Родитель cb373b8c42
Коммит acf1fe38ad
2 изменённых файлов: 1 добавлений и 75 удалений

Просмотреть файл

@ -1350,14 +1350,6 @@ fn convert_uint32_into_string(data: u32) -> CString {
CString::new(buffer).unwrap_or(empty)
}
fn get_device_source_string(
id: AudioDeviceID,
devtype: DeviceType,
) -> std::result::Result<CString, OSStatus> {
let data = get_device_source(id, devtype)?;
Ok(convert_uint32_into_string(data))
}
fn get_channel_count(
devid: AudioObjectID,
devtype: DeviceType,
@ -4077,50 +4069,8 @@ impl<'ctx> StreamOps for AudioUnitStream<'ctx> {
fn set_name(&mut self, _: &CStr) -> Result<()> {
Err(Error::not_supported())
}
#[cfg(target_os = "ios")]
fn current_device(&mut self) -> Result<&DeviceRef> {
Err(not_supported())
}
#[cfg(not(target_os = "ios"))]
fn current_device(&mut self) -> Result<&DeviceRef> {
let output_device = match get_default_device(DeviceType::OUTPUT) {
None => {
cubeb_log!("Could not get default output device");
return Err(Error::error());
}
Some(id) => id,
};
let output_name =
get_device_source_string(output_device, DeviceType::OUTPUT).map_err(|e| {
cubeb_log!(
"Could not get device source string for default output device. Error: {}",
e
);
Error::error()
})?;
let input_device = match get_default_device(DeviceType::INPUT) {
None => {
cubeb_log!("Could not get default input device");
return Err(Error::error());
}
Some(id) => id,
};
let input_name =
get_device_source_string(input_device, DeviceType::INPUT).map_err(|e| {
cubeb_log!(
"Could not get device source string for default input device. Error: {}",
e
);
Error::error()
})?;
let mut device: Box<ffi::cubeb_device> = Box::default();
device.input_name = input_name.into_raw();
device.output_name = output_name.into_raw();
Ok(unsafe { DeviceRef::from_ptr(Box::into_raw(device)) })
Err(Error::not_supported())
}
#[cfg(target_os = "ios")]
fn device_destroy(&mut self, device: &DeviceRef) -> Result<()> {

Просмотреть файл

@ -979,30 +979,6 @@ fn test_convert_uint32_into_string() {
assert_eq!(data_string, CString::new("RUST").unwrap());
}
// get_device_source_string
// ------------------------------------
#[test]
fn test_get_device_source_string() {
test_get_source_name_in_scope(Scope::Input);
test_get_source_name_in_scope(Scope::Output);
fn test_get_source_name_in_scope(scope: Scope) {
if let Some(dev) = test_get_default_device(scope.clone()) {
if let Some(name) = test_get_source_name(dev, scope.clone()) {
let source = get_device_source_string(dev, scope.into())
.unwrap()
.into_string()
.unwrap();
assert_eq!(name, source);
} else {
println!("No source name for default {:?} device ", scope);
}
} else {
println!("No default {:?} device", scope);
}
}
}
// get_channel_count
// ------------------------------------
#[test]