pub struct Device(/* private fields */);Implementations§
Source§impl Device
impl Device
pub fn new( context: Option<Context>, config: &DeviceConfig, ) -> Result<Device, Error>
Sourcepub fn set_data_callback<F>(&mut self, callback: F)
pub fn set_data_callback<F>(&mut self, callback: F)
Override the data callback of the device with a different one. This callback has less restrictions than the callback of the config because it does not have to be cloneable.
§Panics
- This will panic if it is called after the device has been started.
- This will also panic if there is more than one reference to the same device (if this has been cloned).
Sourcepub fn set_stop_callback<F>(&mut self, callback: F)
pub fn set_stop_callback<F>(&mut self, callback: F)
Override the stop callback of the device with a different one. This callback has less restrictions than the callback of the config because it does not have to be cloneable.
§Panics
- This will panic if it is called after the device has been started.
- This will also panic if there is more than one reference to the same device (if this has
Methods from Deref<Target = RawDevice>§
Sourcepub fn owned_context(&self) -> Option<&'static RawContext>
pub fn owned_context(&self) -> Option<&'static RawContext>
This will return the context owned by this device. A context that was passed into this
device via new is not owned by this device and if you need a reference to that use
context instead.
Sourcepub fn context(&self) -> &RawContext
pub fn context(&self) -> &RawContext
This will return a pointer to the context being used by this device.
Sourcepub unsafe fn raw_start(&self) -> Result<(), Error>
pub unsafe fn raw_start(&self) -> Result<(), Error>
Starts the device. For playback devices this begins playback. For capture devices this
begins recording.
Use stop to stop this device.
§Safety
This should not be called from a callback.
Sourcepub unsafe fn raw_stop(&self) -> Result<(), Error>
pub unsafe fn raw_stop(&self) -> Result<(), Error>
Stops this device. For playback devices this stops playback. For capture devices this stops
recording. Use start to start this device again.
§Safety
This should not be called from a callback.
Sourcepub fn is_started(&self) -> bool
pub fn is_started(&self) -> bool
Returns true if this device has started.
Sourcepub fn set_master_volume(&self, volume: f32) -> Result<(), Error>
pub fn set_master_volume(&self, volume: f32) -> Result<(), Error>
Sets the master volume factor for the device.
The volume factor must be between 0 (silence) and 1 (full volume). Use set_master_gain_db() to use decibel notation, where 0 is full volume and
values less than 0 decreases the volume.
§Callback Safety
Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
Sourcepub fn get_master_volume(&self) -> Result<f32, Error>
pub fn get_master_volume(&self) -> Result<f32, Error>
Retrieves the master volume factor for the device.
Sourcepub fn set_master_gain_db(&self, gain_db: f32) -> Result<(), Error>
pub fn set_master_gain_db(&self, gain_db: f32) -> Result<(), Error>
Sets the master volume for the device as gain in decibels.
A gain of 0 is full volume, whereas a gain of < 0 will decrease the volume.
The volume factor must be between 0 (silence) and 1 (full volume). Use set_master_gain_db() to use decibel notation, where 0 is full volume and
values less than 0 decreases the volume.
§Callback Safety
Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
Sourcepub fn get_master_gain_db(&self) -> Result<f32, Error>
pub fn get_master_gain_db(&self) -> Result<f32, Error>
Retrieves the master gain in decibels.