Trait audio_streams::shm_streams::ShmStream
source · pub trait ShmStream: Send {
// Required methods
fn frame_size(&self) -> usize;
fn num_channels(&self) -> usize;
fn frame_rate(&self) -> u32;
fn wait_for_next_action_with_timeout(
&mut self,
timeout: Duration
) -> Result<Option<ServerRequest<'_>>, BoxError>;
}
Expand description
ShmStream
allows a client to interact with an active CRAS stream.
Required Methods§
sourcefn frame_size(&self) -> usize
fn frame_size(&self) -> usize
Get the size of a frame of audio data for this stream.
sourcefn num_channels(&self) -> usize
fn num_channels(&self) -> usize
Get the number of channels of audio data for this stream.
sourcefn frame_rate(&self) -> u32
fn frame_rate(&self) -> u32
Get the frame rate of audio data for this stream.
sourcefn wait_for_next_action_with_timeout(
&mut self,
timeout: Duration
) -> Result<Option<ServerRequest<'_>>, BoxError>
fn wait_for_next_action_with_timeout( &mut self, timeout: Duration ) -> Result<Option<ServerRequest<'_>>, BoxError>
Waits until the next server message indicating action is required.
For playback streams, this will be AUDIO_MESSAGE_REQUEST_DATA
, meaning
that we must set the buffer offset to the next location where playback
data can be found.
For capture streams, this will be AUDIO_MESSAGE_DATA_READY
, meaning
that we must set the buffer offset to the next location where captured
data can be written to.
Will return early if timeout
elapses before a message is received.
§Arguments
timeout
- The amount of time to wait until a message is received.
§Return value
Returns Some(request)
where request
is an object that implements the
ServerRequest
trait and which can be used to get the
number of bytes requested for playback streams or that have already been
written to shm for capture streams.
If the timeout occurs before a message is received, returns None
.
§Errors
- If an invalid message type is received for the stream.