/// The state of a device. #[derive(PartialEq, Eq, Clone, Debug, Copy)] pubenum DeviceState { /// The device has been disabled at the system level.
Disabled, /// The device is enabled, but nothing is plugged into it.
Unplugged, /// The device is enabled.
Enabled,
}
bitflags! { /// Channel type for a `cubeb_stream`. Depending on the backend and platform /// used, this can control inter-stream interruption, ducking, and volume /// control. pubstruct DevicePref: ffi::cubeb_device_pref { const MULTIMEDIA = ffi::CUBEB_DEVICE_PREF_MULTIMEDIA; const VOICE = ffi::CUBEB_DEVICE_PREF_VOICE; const NOTIFICATION = ffi::CUBEB_DEVICE_PREF_NOTIFICATION; const ALL = ffi::CUBEB_DEVICE_PREF_ALL;
}
}
bitflags! { /// Whether a particular device is an input device (e.g. a microphone), or an /// output device (e.g. headphones). pubstruct DeviceType: ffi::cubeb_device_type { const INPUT = ffi::CUBEB_DEVICE_TYPE_INPUT as _; const OUTPUT = ffi::CUBEB_DEVICE_TYPE_OUTPUT as _;
}
}
/// Gets the output device name. /// /// May return `None` if there is no output device. pubfn output_name(&self) -> Option<&str> { self.output_name_bytes().map(|b| str::from_utf8(b).unwrap())
}
/// Gets the input device name. /// /// May return `None` if there is no input device. pubfn input_name(&self) -> Option<&str> { self.input_name_bytes().map(|b| str::from_utf8(b).unwrap())
}
ffi_type_stack! { /// This structure holds the characteristics of an input or output /// audio device. It is obtained using `enumerate_devices`, which /// returns these structures via `device_collection` and must be /// destroyed via `device_collection_destroy`. type CType = ffi::cubeb_device_info; pubstruct DeviceInfo; pubstruct DeviceInfoRef;
}
/// Device identifier which might be presented in a UI. pubfn device_id(&self) -> Option<&str> { self.device_id_bytes().map(|b| str::from_utf8(b).unwrap())
}
/// Friendly device name which might be presented in a UI. pubfn friendly_name(&self) -> Option<&str> { self.friendly_name_bytes()
.map(|b| str::from_utf8(b).unwrap())
}
/// Two devices have the same group identifier if they belong to /// the same physical device; for example a headset and /// microphone. pubfn group_id(&self) -> Option<&str> { self.group_id_bytes().map(|b| str::from_utf8(b).unwrap())
}
/// The default sample format for this device. pubfn default_format(&self) -> DeviceFormat {
DeviceFormat::from_bits(self.get_ref().default_format).unwrap()
}
/// Lowest possible latency in frames. pubfn latency_lo(&self) -> u32 { self.get_ref().latency_lo
}
/// Higest possible latency in frames. pubfn latency_hi(&self) -> u32 { self.get_ref().latency_hi
}
}
#[cfg(test)] mod tests { use ffi::cubeb_device; use Device;
#[test] fn device_device_ref_same_ptr() { let ptr: *mut cubeb_device = 0xDEAD_BEEF as *mut _; let device = unsafe { Device::from_ptr(ptr) };
assert_eq!(device.as_ptr(), ptr);
assert_eq!(device.as_ptr(), device.as_ref().as_ptr());
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.19Bemerkung:
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.