Trait audio_streams::shm_streams::ShmStreamSource
source · pub trait ShmStreamSource<E: Error>: Send {
// Required method
fn new_stream(
&mut self,
direction: StreamDirection,
num_channels: usize,
format: SampleFormat,
frame_rate: u32,
buffer_size: usize,
effects: &[StreamEffect],
client_shm: &dyn SharedMemory<Error = E>,
buffer_offsets: [u64; 2]
) -> Result<Box<dyn ShmStream>, BoxError>;
// Provided method
fn keep_fds(&self) -> Vec<RawFd> { ... }
}
Expand description
ShmStreamSource
creates streams for playback or capture of audio.
Required Methods§
sourcefn new_stream(
&mut self,
direction: StreamDirection,
num_channels: usize,
format: SampleFormat,
frame_rate: u32,
buffer_size: usize,
effects: &[StreamEffect],
client_shm: &dyn SharedMemory<Error = E>,
buffer_offsets: [u64; 2]
) -> Result<Box<dyn ShmStream>, BoxError>
fn new_stream( &mut self, direction: StreamDirection, num_channels: usize, format: SampleFormat, frame_rate: u32, buffer_size: usize, effects: &[StreamEffect], client_shm: &dyn SharedMemory<Error = E>, buffer_offsets: [u64; 2] ) -> Result<Box<dyn ShmStream>, BoxError>
Creates a new ShmStream
Creates a new ShmStream
object, which allows:
- Waiting until the server has communicated that data is ready or requested that we make more data available.
- Setting the location and length of buffers for reading/writing audio data.
§Arguments
direction
- The direction of the stream, eitherPlayback
orCapture
.num_channels
- The number of audio channels for the stream.format
- The audio format to use for audio samples.frame_rate
- The stream’s frame rate in Hz.buffer_size
- The maximum size of an audio buffer. This will be the size used for transfers of audio data between client and server.effects
- Audio effects to use for the stream, such as echo-cancellation.client_shm
- The shared memory area that will contain samples.buffer_offsets
- The two initial values to use as buffer offsets for streams. This way, the server will not write audio data to an arbitrary offset inclient_shm
if the client fails to update offsets in time.
§Errors
- If sending the connect stream message to the server fails.