Struct audio_streams::shm_streams::ServerRequest
source · pub struct ServerRequest<'a> {
requested_frames: usize,
buffer_set: &'a mut dyn BufferSet,
}
Expand description
ServerRequest
represents an active request from the server for the client
to provide a buffer in shared memory to playback from or capture to.
Fields§
§requested_frames: usize
§buffer_set: &'a mut dyn BufferSet
Implementations§
source§impl<'a> ServerRequest<'a>
impl<'a> ServerRequest<'a>
sourcepub fn new<D: BufferSet>(requested_frames: usize, buffer_set: &'a mut D) -> Self
pub fn new<D: BufferSet>(requested_frames: usize, buffer_set: &'a mut D) -> Self
Create a new ServerRequest object
Create a ServerRequest object representing a request from the server
for a buffer requested_frames
in size.
When the client responds to this request by calling
set_buffer_offset_and_frames
,
BufferSet::callback will be called on buffer_set
.
§Arguments
requested_frames
- The requested buffer size in frames.buffer_set
- The object implementing the callback for when a buffer is provided.
sourcepub fn requested_frames(&self) -> usize
pub fn requested_frames(&self) -> usize
Get the number of frames of audio data requested by the server.
The returned value should never be greater than the buffer_size
given in new_stream
.
sourcepub fn set_buffer_offset_and_frames(
self,
offset: usize,
frames: usize
) -> Result<(), BoxError>
pub fn set_buffer_offset_and_frames( self, offset: usize, frames: usize ) -> Result<(), BoxError>
Sets the buffer offset and length for the requested buffer.
Sets the buffer offset and length of the buffer that fulfills this
server request to offset
and length
, respectively. This means that
length
bytes of audio samples may be read from/written to that
location in client_shm
for a playback/capture stream, respectively.
This function may only be called once for a ServerRequest
, at which
point the ServerRequest is dropped and no further calls are possible.
§Arguments
offset
- The value to use as the new buffer offset for the next buffer.frames
- The length of the next buffer in frames.
§Errors
- If
frames
is greater thanrequested_frames
.
sourcepub fn ignore_request(self) -> Result<(), BoxError>
pub fn ignore_request(self) -> Result<(), BoxError>
Ignore this request
If the client does not intend to respond to this ServerRequest with a buffer, they should call this function. The stream will be notified that the request has been ignored and will handle it properly.