Struct libpulse_binding::stream::Stream
source · pub struct Stream { /* private fields */ }Expand description
An opaque stream for playback or recording.
Note: Saves a copy of active multi-use closure callbacks, which it frees on drop.
Implementations
sourceimpl Stream
impl Stream
sourcepub fn new(
ctx: &mut Context,
name: &str,
ss: &Spec,
map: Option<&Map>
) -> Option<Self>
pub fn new(
ctx: &mut Context,
name: &str,
ss: &Spec,
map: Option<&Map>
) -> Option<Self>
Create a new, unconnected stream with the specified name and sample type.
It is recommended to use new_with_proplist instead and
specify some initial properties.
Params
ctx: The context to create this stream inname: A name for this streamss: The desired sample formatmap: The desired channel map, orNonefor default
sourcepub fn new_with_proplist(
ctx: &mut Context,
name: &str,
ss: &Spec,
map: Option<&Map>,
proplist: &mut Proplist
) -> Option<Self>
pub fn new_with_proplist(
ctx: &mut Context,
name: &str,
ss: &Spec,
map: Option<&Map>,
proplist: &mut Proplist
) -> Option<Self>
Create a new, unconnected stream with the specified name and sample type, and specify the initial stream property list.
Params
ctx: The context to create this stream inname: A name for this streamss: The desired sample formatmap: The desired channel map, orNonefor defaultproplist: The initial property list
sourcepub fn new_extended(
ctx: &mut Context,
name: &str,
formats: &[&Info],
proplist: &mut Proplist
) -> Option<Self>
pub fn new_extended(
ctx: &mut Context,
name: &str,
formats: &[&Info],
proplist: &mut Proplist
) -> Option<Self>
Create a new, unconnected stream with the specified name, the set of formats this client can provide, and an initial list of properties. While connecting, the server will select the most appropriate format which the client must then provide.
Params
ctx: The context to create this stream inname: A name for this streamformats: The list of formats that can be providedproplist: The initial property list
sourcepub fn get_index(&self) -> Option<u32>
pub fn get_index(&self) -> Option<u32>
Return the sink input resp. source output index this stream is identified in the server
with. This is useful with the introspection functions such as
::context::introspect::Introspector::get_sink_input_info or
::context::introspect::Introspector::get_source_output_info.
sourcepub fn get_device_index(&self) -> Option<u32>
pub fn get_device_index(&self) -> Option<u32>
Return the index of the sink or source this stream is connected to in the server. This is
useful with the introspection functions such as
::context::introspect::Introspector::get_sink_info_by_index or
::context::introspect::Introspector::get_source_info_by_index.
Please note that streams may be moved between sinks/sources and thus it is recommended to
use set_moved_callback to be notified about this.
sourcepub fn get_device_name(&self) -> Option<Cow<'static, str>>
pub fn get_device_name(&self) -> Option<Cow<'static, str>>
Return the name of the sink or source this stream is connected to in the server. This is
useful with the introspection functions such as
::context::introspect::Introspector::get_sink_info_by_name or
::context::introspect::Introspector::get_source_info_by_name.
Please note that streams may be moved between sinks/sources and thus it is recommended to
use set_moved_callback to be notified about this.
sourcepub fn is_suspended(&self) -> Result<bool, PAErr>
pub fn is_suspended(&self) -> Result<bool, PAErr>
Return whether or not the sink or source this stream is connected to has been suspended.
sourcepub fn is_corked(&self) -> Result<bool, PAErr>
pub fn is_corked(&self) -> Result<bool, PAErr>
Return whether or not this stream has been corked.
sourcepub fn connect_playback(
&mut self,
dev: Option<&str>,
attr: Option<&BufferAttr>,
flags: FlagSet,
volume: Option<&ChannelVolumes>,
sync_stream: Option<&mut Self>
) -> Result<(), PAErr>
pub fn connect_playback(
&mut self,
dev: Option<&str>,
attr: Option<&BufferAttr>,
flags: FlagSet,
volume: Option<&ChannelVolumes>,
sync_stream: Option<&mut Self>
) -> Result<(), PAErr>
Connect the stream to a sink.
It is strongly recommended to pass None in both dev and volume and to set neither
flags::START_MUTED nor flags::START_UNMUTED – unless these options are directly
dependent on user input or configuration.
If you follow this rule then the sound server will have the full flexibility to choose the device, volume and mute status automatically, based on server-side policies, heuristics and stored information from previous uses. Also the server may choose to reconfigure audio devices to make other sinks/sources or capabilities available to be able to accept the stream.
Before PA 0.9.20 it was not defined whether the ‘volume’ parameter was interpreted relative
to the sink’s current volume or treated as an absolute device volume. Since PA 0.9.20 it is
an absolute volume when the sink is in flat volume mode, and relative otherwise, thus making
sure the volume passed here has always the same semantics as the volume passed to
::context::introspect::Introspector::set_sink_input_volume. It is possible to figure out
whether flat volume mode is in effect for a given sink by calling
::context::introspect::Introspector::get_sink_info_by_name.
Since PA 5.0, it’s possible to specify a single-channel volume even if the stream has multiple channels. In that case the same volume is applied to all channels.
Params
dev: Name of the sink to connect to, orNonefor defaultattr: Buffering attributes, orNonefor defaultflags: Additional flags, or0for defaultvolume: Initial volume, orNonefor defaultsync_stream: Synchronize this stream with the specified one, orNonefor a standalone stream.
sourcepub fn connect_record(
&mut self,
dev: Option<&str>,
attr: Option<&BufferAttr>,
flags: FlagSet
) -> Result<(), PAErr>
pub fn connect_record(
&mut self,
dev: Option<&str>,
attr: Option<&BufferAttr>,
flags: FlagSet
) -> Result<(), PAErr>
Connect the stream to a source.
Params
dev: Name of the source to connect to, orNonefor defaultattr: Buffering attributes, orNonefor defaultflags: Additional flags, or0for default
sourcepub fn connect_upload(&mut self, length: usize) -> Result<(), PAErr>
pub fn connect_upload(&mut self, length: usize) -> Result<(), PAErr>
Make this stream a sample upload stream. (See ::scache).
sourcepub fn finish_upload(&mut self) -> Result<(), PAErr>
pub fn finish_upload(&mut self) -> Result<(), PAErr>
Finish the sample upload, the stream name will become the sample name.
You cancel a sample upload by issuing disconnect.
sourcepub fn disconnect(&mut self) -> Result<(), PAErr>
pub fn disconnect(&mut self) -> Result<(), PAErr>
Disconnect a stream from a source/sink.
sourcepub fn begin_write<'a>(
&mut self,
nbytes: Option<usize>
) -> Result<Option<&'a mut [u8]>, PAErr>
pub fn begin_write<'a>(
&mut self,
nbytes: Option<usize>
) -> Result<Option<&'a mut [u8]>, PAErr>
Prepare writing data to the server (for playback streams).
This function may be used to optimize the number of memory copies when doing playback
(“zero-copy”). It is recommended to call this function before each call to write. It is
used to obtain a chunk of PA internally allocated memory, into which you can directly write
your data before calling write to actually execute the write.
This function should be called with nbytes set to the number of bytes you want to write,
or None, in which case the size will be chosen automatically (which is recommended).
The return value is a Result type, with the Ok variant wrapping an Option. Err will
be returned if PA encountered an error; Ok(None) will be returned if it appeared to be
successful, but the pointer returned was NULL, otherwise the buffer will be returned as
Ok(Some(_)).
After placing your data in the memory area returned, call write with a sub-slice of it,
to actually execute the write. Note, the buffer may only be used once, i.e. if you were
thinking of getting a large buffer, placing a large chunk of data into it, then perform
multiple small writes from it, you cannot do this. Any attempt at accessing the memory
returned after the following write or cancel_write is invalid.
If you want to cancel a previously called begin_write without calling write use
cancel_write.
The memory should not be explicitly freed by the caller.
An invocation of write should “quickly” follow a begin_write. It is not recommended
letting an unbounded amount of time pass after calling begin_write and before calling
write. Calling begin_write twice without calling write or cancel_write in
between will return exactly the same data pointer and nbytes values.
sourcepub fn cancel_write(&mut self) -> Result<(), PAErr>
pub fn cancel_write(&mut self) -> Result<(), PAErr>
Reverses the effect of begin_write dropping any data that has already been placed in the
memory area returned by begin_write. Only valid to call after a call to begin_write
has been made, and neither cancel_write nor write have been called yet. Accessing
the memory previously returned by begin_write after calling this function is invalid.
sourcepub fn write(
&mut self,
data: &[u8],
free_cb: Option<FreeCb>,
offset: i64,
seek: SeekMode
) -> Result<(), PAErr>
pub fn write(
&mut self,
data: &[u8],
free_cb: Option<FreeCb>,
offset: i64,
seek: SeekMode
) -> Result<(), PAErr>
Write some data to the server (for playback streams).
If free_cb is provided, this routine is called when all data has been written out. An
internal reference to the specified data is kept, the data is not copied. If None, the
data is copied into an internal buffer.
The client may freely seek around in the output buffer. For most applications it is typical
to pass 0 and SeekMode::Relative as values for the arguments offset and seek
respectively. After a successful write call the write index will be at the position after
where this chunk of data has been written to.
As an optimization for avoiding needless memory copies you may call begin_write before
this call and then place your audio data directly in the memory area returned by that call.
Then, pass a pointer to that memory area to write. After the invocation of write the
memory area may no longer be accessed. Any further explicit freeing of the memory area is
not necessary. It is OK to write to the memory area returned by begin_write only
partially with this call, skipping bytes both at the end and at the beginning of the
reserved memory area.
Params
data: The data to write. The length must be in multiples of the stream’s sample spec frame size.free_cb: A cleanup routine for the data orNoneto request an internal copy of the data.offset: Offset for seeking. Must be0for upload streams. Must be in multiples of the stream’s sample spec frame size.seek: Seek mode. Must beSeekMode::Relativefor upload streams.
sourcepub fn write_ext_free(
&mut self,
data: &[u8],
free_cb: Option<(FreeCb, *mut c_void)>,
offset: i64,
seek: SeekMode
) -> Result<(), PAErr>
pub fn write_ext_free(
&mut self,
data: &[u8],
free_cb: Option<(FreeCb, *mut c_void)>,
offset: i64,
seek: SeekMode
) -> Result<(), PAErr>
Write some data to the server (for playback streams).
This function does exactly the same as write with the only difference being that a void
pointer is provided along with the free_cb callback pointer, and this void pointer will be
passed to the callback instead of the data pointer.
Params
data: The data to write. The length must be in multiples of the stream’s sample spec frame size.free_cb: A cleanup routine for the data orNoneto request an internal copy of the data. If provided, the accompanying data pointer will be supplied to the callback.offset: Offset for seeking. Must be0for upload streams.seek: Seek mode, must beSeekMode::Relativefor upload streams.
sourcepub fn peek<'a>(&mut self) -> Result<PeekResult<'a>, PAErr>
pub fn peek<'a>(&mut self) -> Result<PeekResult<'a>, PAErr>
Read the next fragment from the buffer (for recording streams).
This function returns one of the PeekResult variants - either Empty, Hole or
Data:
- If there is data at the current read index, the
Datavariant will be returned, which contains a slice giving a view of the data. (The length of this slice can be less or more than a complete fragment). This is pointing into an internal buffer, so obviously you must make a copy of it if you want to keep it. - If there is no data at the current read index, it means that either the buffer is empty
or it contains a hole (that is, the write index is ahead of the read index but there’s no
data where the read index points at). If the buffer is empty, the
Emptyresult variant will be returned. If there is a hole, theHolevariant will be returned, containing the length of the hole in bytes.
Use discard to actually remove the data from the buffer and move the read index
forward. discard should not be called if the buffer is empty, but it should be called if
there is a hole.
sourcepub fn discard(&mut self) -> Result<(), PAErr>
pub fn discard(&mut self) -> Result<(), PAErr>
Remove the current fragment on record streams.
It is invalid to do this without first calling peek.
Note: The original C function name used the term drop; We instead use discard here to
avoid conflict with the Rust Drop trait!
sourcepub fn writable_size(&self) -> Option<usize>
pub fn writable_size(&self) -> Option<usize>
Return the number of bytes requested by the server that have not yet been written.
It is possible to write more than this amount, up to the stream’s buffer_attr.maxlength
bytes. This is usually not desirable, though, as it would increase stream latency to be
higher than requested (buffer_attr.tlength).
sourcepub fn readable_size(&self) -> Option<usize>
pub fn readable_size(&self) -> Option<usize>
Return the number of bytes that may be read using peek.
sourcepub fn drain(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn drain(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Drain a playback stream.
Use this for notification when the playback buffer is empty after playing all the audio in the buffer. Please note that only one drain operation per stream may be issued at a time.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn update_timing_info(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn update_timing_info(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Request a timing info structure update for a stream.
Use get_timing_info to get access to the raw timing data, or get_time or
get_latency to get cleaned up values.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn set_state_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_state_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called whenever the state of the stream changes.
sourcepub fn set_write_callback(
&mut self,
callback: Option<Box<dyn FnMut(usize) + 'static>>
)
pub fn set_write_callback(
&mut self,
callback: Option<Box<dyn FnMut(usize) + 'static>>
)
Set the callback function that is called when new data may be written to the stream.
The callback accepts an argument giving the number of bytes.
sourcepub fn set_read_callback(
&mut self,
callback: Option<Box<dyn FnMut(usize) + 'static>>
)
pub fn set_read_callback(
&mut self,
callback: Option<Box<dyn FnMut(usize) + 'static>>
)
Set the callback function that is called when new data is available from the stream.
The callback accepts an argument giving the number of bytes.
sourcepub fn set_overflow_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_overflow_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called when a buffer overflow happens. (Only for playback streams).
sourcepub fn get_underflow_index(&self) -> Option<u64>
pub fn get_underflow_index(&self) -> Option<u64>
Return at what position the latest underflow occurred.
None is returned if this information is not known (e.g. if no underflow has occurred).
This can be used inside the underflow callback to get information about the current underflow. (Only for playback streams).
sourcepub fn set_underflow_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_underflow_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called when a buffer underflow happens. (Only for playback streams)
sourcepub fn set_started_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_started_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called when the server starts playback after an underrun or on initial startup. This only informs that audio is flowing again, it is no indication that audio started to reach the speakers already. (Only for playback streams).
sourcepub fn set_latency_update_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_latency_update_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called whenever a latency information update happens.
Useful on flags::AUTO_TIMING_UPDATE streams only.
sourcepub fn set_moved_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_moved_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called whenever the stream is moved to a different
sink/source. Use get_device_name or get_device_index to query the new sink/source.
sourcepub fn set_suspended_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_suspended_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called whenever the sink/source this stream is connected
to is suspended or resumed. Use is_suspended to query the new suspend status. Please
note that the suspend status might also change when the stream is moved between devices.
Thus if you call this function you very likely want to call set_moved_callback too.
sourcepub fn set_event_callback(
&mut self,
callback: Option<Box<dyn FnMut(String, Proplist) + 'static>>
)
pub fn set_event_callback(
&mut self,
callback: Option<Box<dyn FnMut(String, Proplist) + 'static>>
)
Set the callback function that is called whenever a meta/policy control event is received.
The callback is given a name which represents what event occurred. The set of defined events
can be extended at any time. Also, server modules may introduce additional message types so
make sure that your callback function ignores messages it doesn’t know. Some well known
event names can be found in the event_names submodule. It is
also given an (owned) property list.
sourcepub fn set_buffer_attr_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
pub fn set_buffer_attr_callback(
&mut self,
callback: Option<Box<dyn FnMut() + 'static>>
)
Set the callback function that is called whenever the buffer attributes on the server side
change. Please note that the buffer attributes can change when moving a stream to a
different sink/source too, hence if you use this callback you should use
set_moved_callback as well.
sourcepub fn cork(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn cork(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Pause playback of this stream temporarily.
Available on both playback and recording streams. The pause operation is executed as
quickly as possible. If a cork is very quickly followed by an uncork, this might not
actually have any effect on the stream that is output. You can use is_corked to find out
whether the stream is currently paused or not. Normally a stream will be created in uncorked
state. If you pass flags::START_CORKED as a flag when connecting the stream, it will be
created in corked state.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn uncork(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn uncork(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Resume playback of this stream.
Available on both playback and recording streams. The un-pause operation is executed as
quickly as possible. If an uncork is very quickly followed by a cork, this might not
actually have any effect on the stream that is output. You can use is_corked to find out
whether the stream is currently paused or not. Normally a stream will be created in uncorked
state. If you pass flags::START_CORKED as a flag when connecting the stream, it will be
created in corked state.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn flush(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn flush(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Flush the playback or record buffer of this stream.
This discards any audio data in the buffer. Most of the time you’re better off using the
parameter seek of write instead of this function.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn prebuf(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn prebuf(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Re-enable prebuffering if specified in the ::def::BufferAttr structure. Available for
playback streams only.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn trigger(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn trigger(
&mut self,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Request immediate start of playback on this stream.
This disables prebuffering temporarily if specified in the ::def::BufferAttr structure.
Available for playback streams only.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn set_name(
&mut self,
name: &str,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
pub fn set_name(
&mut self,
name: &str,
callback: Option<Box<dyn FnMut(bool) + 'static>>
) -> Operation<dyn FnMut(bool)>
Rename the stream.
The optional callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn get_time(&self) -> Result<Option<MicroSeconds>, PAErr>
pub fn get_time(&self) -> Result<Option<MicroSeconds>, PAErr>
Return the current playback/recording time.
This is based on the data in the timing info structure returned by get_timing_info. The
returned time is in the sound card clock domain, which usually runs at a slightly different
rate than the system clock.
This function will usually only return new data if a timing info update has been received.
Only if timing interpolation has been requested (flags::INTERPOLATE_TIMING) the data
from the last timing update is used for an estimation of the current playback/recording time
based on the local time that passed since the timing info structure has been acquired.
The time value returned by this function is guaranteed to increase monotonically (the
returned value is always greater or equal to the value returned by the last call). This
behaviour can be disabled by using flags::NOT_MONOTONIC. This may be desirable to better
deal with bad estimations of transport latencies, but may have strange effects if the
application is not able to deal with time going ‘backwards’.
The time interpolator activated by flags::INTERPOLATE_TIMING favours ‘smooth’ time
graphs over accurate ones to improve the smoothness of UI operations that are tied to the
audio clock. If accuracy is more important to you, you might need to estimate your timing
based on the data from get_timing_info yourself or not work with interpolated timing at
all and instead always query the server side for the most up to date timing with
update_timing_info.
If no timing information has been received yet this call will return Ok(None). For more
details see get_timing_info.
sourcepub fn get_latency(&self) -> Result<Latency, PAErr>
pub fn get_latency(&self) -> Result<Latency, PAErr>
Determine the total stream latency.
This function is based on get_time. The returned time is in the sound card clock domain,
which usually runs at a slightly different rate than the system clock.
In case the stream is a monitoring stream the result can be negative, i.e. the captured
samples are not yet played, in which case Ok(Latency::Negative(usecs)) will be returned
instead of Ok(Latency::Positive(usecs))
If no timing information has been received yet, this call will return Ok(Latency::None).
For more details see get_timing_info and get_time.
sourcepub fn get_timing_info<'a>(&mut self) -> Option<&'a TimingInfo>
pub fn get_timing_info<'a>(&mut self) -> Option<&'a TimingInfo>
Returns the latest raw timing data structure.
The returned pointer refers to an internal read-only instance of the timing structure. The
user should make a copy of this structure if wanting to modify it. An in-place update to
this data structure may be requested using update_timing_info.
If no timing information has been received before (i.e. by requesting update_timing_info
or by using flags::AUTO_TIMING_UPDATE), this function will return None (as it will
also if an error occurs).
Please note that the write_index member field (and only this field) is updated on each
write call, not just when a timing update has been received.
sourcepub fn get_sample_spec<'a>(&mut self) -> Option<&'a Spec>
pub fn get_sample_spec<'a>(&mut self) -> Option<&'a Spec>
Return a pointer to the stream’s sample specification.
sourcepub fn get_channel_map<'a>(&mut self) -> Option<&'a Map>
pub fn get_channel_map<'a>(&mut self) -> Option<&'a Map>
Return a pointer to the stream’s channel map.
sourcepub fn get_format_info(&self) -> Option<Info>
pub fn get_format_info(&self) -> Option<Info>
Return a pointer to the stream’s format.
sourcepub fn get_buffer_attr<'a>(&mut self) -> Option<&'a BufferAttr>
pub fn get_buffer_attr<'a>(&mut self) -> Option<&'a BufferAttr>
Return the per-stream server-side buffer metrics of the stream.
Only valid after the stream has been connected successfully. This will return the actual
configured buffering metrics, which may differ from what was requested during
connect_record or connect_playback. This call will always return the actual
per-stream server-side buffer metrics, regardless whether flags::ADJUST_LATENCY is set
or not.
sourcepub fn set_buffer_attr<F>(
&mut self,
attr: &BufferAttr,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
pub fn set_buffer_attr<F>(
&mut self,
attr: &BufferAttr,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
Change the buffer metrics of the stream during playback.
The server might have chosen different buffer metrics then requested. The selected metrics
may be queried with get_buffer_attr as soon as the callback is called. Only valid after
the stream has been connected successfully. Please be aware of the slightly different
semantics of the call depending whether flags::ADJUST_LATENCY is set or not.
The callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn update_sample_rate<F>(
&mut self,
rate: u32,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
pub fn update_sample_rate<F>(
&mut self,
rate: u32,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
Change the stream sampling rate during playback.
You need to pass flags::VARIABLE_RATE in the flags parameter of connect_playback if
you plan to use this function. Only valid after the stream has been connected successfully.
The callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn update_proplist<F>(
&mut self,
mode: UpdateMode,
proplist: &mut Proplist,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
pub fn update_proplist<F>(
&mut self,
mode: UpdateMode,
proplist: &mut Proplist,
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
Update the property list of the sink input/source output of this stream, adding new entries.
Please note that it is highly recommended to set as many properties initially via
new_with_proplist as possible instead a posteriori with this function, since that
information may be used to route this stream to the right device.
The callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn remove_proplist<F>(
&mut self,
keys: &[&str],
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
pub fn remove_proplist<F>(
&mut self,
keys: &[&str],
callback: F
) -> Operation<dyn FnMut(bool)>where
F: FnMut(bool) + 'static,
Update the property list of the sink input/source output of this stream, remove entries.
The callback must accept a bool, which indicates success.
Panics if the underlying C function returns a null pointer.
sourcepub fn set_monitor_stream(&mut self, sink_input_index: u32) -> Result<(), PAErr>
pub fn set_monitor_stream(&mut self, sink_input_index: u32) -> Result<(), PAErr>
For record streams connected to a monitor source: monitor only a very specific sink input of
the sink. This function needs to be called before connect_record
is called.
sourcepub fn get_monitor_stream(&self) -> Option<u32>
pub fn get_monitor_stream(&self) -> Option<u32>
Return the sink input index previously set with
set_monitor_stream.