Struct libpulse_binding::context::Context
[−]
[src]
pub struct Context { pub ptr: *mut ContextInternal, // some fields omitted }
An opaque connection context to a daemon This acts as a safe Rust wrapper for the actual C object.
Fields
ptr: *mut ContextInternal
The actual C object.
Methods
impl Context
[src]
fn device_manager(&self) -> DeviceManager
[src]
Returns a device manager object linked to the current context, giving access to device
manager routines. See ::context::ext_device_manager
.
impl Context
[src]
fn device_restore(&self) -> DeviceRestore
[src]
Returns a device restore object linked to the current context, giving access to device
restore routines. See ::context::ext_device_restore
.
impl Context
[src]
fn stream_restore(&self) -> StreamRestore
[src]
Returns a stream restore object linked to the current context, giving access to stream
restore routines. See ::context::ext_stream_restore
.
impl Context
[src]
fn introspect(&self) -> Introspector
[src]
Returns an introspection object linked to the current context, giving access to
introspection routines. See ::context::introspect
.
impl Context
[src]
fn remove_sample(
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Remove a sample from the sample cache.
Returns an operation object which may be used to cancel the operation while it is running.
fn play_sample(
&self,
name: &str,
dev: Option<&str>,
volume: Volume,
cb: Option<(ContextSuccessCb, *mut c_void)>
) -> Option<Operation>
[src]
&self,
name: &str,
dev: Option<&str>,
volume: Volume,
cb: Option<(ContextSuccessCb, *mut c_void)>
) -> Option<Operation>
Play a sample from the sample cache to the specified device.
If the sepecified device is None
use the default sink.
Params
name
: Name of the sample to play.dev
: Sink to play this sample on, orNone
for default.volume
: Volume to play this sample with. Starting with 0.9.15 you may pass here::volume::VOLUME_INVALID
which will leave the decision about the volume to the server side which is a good idea.cb
: Call this function after successfully starting playback, orNone
.userdata
: Userdata to pass to the callback.
fn play_sample_with_proplist(
&self,
name: &str,
dev: Option<&str>,
volume: Volume,
proplist: &mut Proplist,
cb: Option<(ContextPlaySampleCb, *mut c_void)>
) -> Option<Operation>
[src]
&self,
name: &str,
dev: Option<&str>,
volume: Volume,
proplist: &mut Proplist,
cb: Option<(ContextPlaySampleCb, *mut c_void)>
) -> Option<Operation>
Play a sample from the sample cache to the specified device, allowing specification of a property list for the playback stream.
If the device is None
use the default sink.
Params
name
: Name of the sample to play.dev
: Sink to play this sample on, orNone
for default.volume
: Volume to play this sample with. Starting with 0.9.15 you may pass here::volume::VOLUME_INVALID
which will leave the decision about the volume to the server side which is a good idea.proplist
: Property list for this sound. The property list of the cached entry will be merged into this property list.cb
: Call this function after successfully starting playback, orNone
.userdata
: Userdata to pass to the callback.
impl Context
[src]
fn subscribe(
&self,
mask: InterestMaskSet,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
mask: InterestMaskSet,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Enable event notification.
The mask
parameter is used to specify which facilities you are interested in being
modified about. Use set_subscribe_callback
to set the
actual callback that will be called when an event occurs.
fn set_subscribe_callback(&self, cb: Option<(Callback, *mut c_void)>)
[src]
Set the context specific call back function that is called whenever a subscribed-to event
occurs. Use subscribe
to set the facilities you are interested in
recieving notifications for, and thus to start receiving notifications with the callback set
here.
impl Context
[src]
fn new(mainloop_api: &mut MainloopApi, name: &str) -> Option<Self>
[src]
Instantiate a new connection context with an abstract mainloop API and an application name.
It is recommended to use new_with_proplist
instead and
specify some initial properties.
fn new_with_proplist(
mainloop_api: &mut MainloopApi,
name: &str,
proplist: &mut Proplist
) -> Option<Self>
[src]
mainloop_api: &mut MainloopApi,
name: &str,
proplist: &mut Proplist
) -> Option<Self>
Instantiate a new connection context with an abstract mainloop API and an application name, and specify the initial client property list.
fn from_raw(ptr: *mut ContextInternal) -> Self
[src]
Create a new Context
from an existing ContextInternal
pointer.
fn from_raw_weak(ptr: *mut ContextInternal) -> Self
[src]
Create a new Context
from an existing ContextInternal
pointer. This is the 'weak' version, for use in callbacks, which avoids destroying the
internal object when dropped.
fn set_state_callback(&self, cb: Option<(ContextNotifyCb, *mut c_void)>)
[src]
Set a callback function that is called whenever the context status changes.
fn set_event_callback(&self, cb: Option<(ContextEventCb, *mut c_void)>)
[src]
Set a callback function that is called whenever a meta/policy control event is received.
fn errno(&self) -> i32
[src]
Returns the error number of the last failed operation
fn is_pending(&self) -> bool
[src]
Returns true
if some data is pending to be written to the connection
fn get_state(&self) -> State
[src]
Returns the current context status
fn connect(
&self,
server: Option<&str>,
flags: FlagSet,
api: Option<&SpawnApi>
) -> Result<(), i32>
[src]
&self,
server: Option<&str>,
flags: FlagSet,
api: Option<&SpawnApi>
) -> Result<(), i32>
Connect the context to the specified server.
If server is None
, connect to the default server. This routine may but will not always
return synchronously on error. Use set_state_callback
to be
notified when the connection is established. If flags
doesn't have
flags::NOAUTOSPAWN
set and no specific server is specified
or accessible, a new daemon is spawned. If api
is not None
, the functions specified in
the structure are used when forking a new child process.
fn disconnect(&self)
[src]
Terminate the context connection immediately.
fn drain(&self, cb: (ContextNotifyCb, *mut c_void)) -> Option<Operation>
[src]
Drain the context.
If there is nothing to drain, the function returns None
.
fn exit_daemon(&self, cb: (ContextSuccessCb, *mut c_void)) -> Option<Operation>
[src]
Tell the daemon to exit.
The returned operation is unlikely to complete successfully, since the daemon probably died before returning a success notification.
fn set_default_sink(
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Set the name of the default sink.
fn set_default_source(
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Set the name of the default source.
fn is_local(&self) -> Option<bool>
[src]
Returns true
when the connection is to a local daemon. Returns None
on error, for
instance when no connection has been made yet.
fn set_name(
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
name: &str,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Set a different application name for context on the server.
fn get_server(&self) -> Option<String>
[src]
Return the server name this context is connected to.
fn get_protocol_version(&self) -> u32
[src]
Return the protocol version of the library.
fn get_server_protocol_version(&self) -> Option<u32>
[src]
Return the protocol version of the connected server.
Returns None
on error.
fn proplist_update(
&self,
mode: UpdateMode,
p: &mut Proplist,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
mode: UpdateMode,
p: &mut Proplist,
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Update the property list of the client, 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 then be used to route streams of the client to the
right device.
fn proplist_remove(
&self,
keys: &[&str],
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
[src]
&self,
keys: &[&str],
cb: (ContextSuccessCb, *mut c_void)
) -> Option<Operation>
Update the property list of the client, remove entries.
fn get_index(&self) -> Option<u32>
[src]
Return the client index this context is identified in the server with.
This is useful for usage with the introspection functions, such as
::introspect::Introspector::get_client_info
.
Returns None
on error.
fn rttime_new<T>(
&self,
mainloop: &Mainloop<MI = T::MI>,
usec: Usecs,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<T::MI>> where
T: Mainloop,
[src]
&self,
mainloop: &Mainloop<MI = T::MI>,
usec: Usecs,
cb: (TimeEventCb, *mut c_void)
) -> Option<TimeEvent<T::MI>> where
T: Mainloop,
Create a new timer event source for the specified time (wrapper for
::mainloop::api::MainloopApi.time_new
).
A reference to the mainloop object is needed, in order to associate the event object with it. The association is done to ensure the even does not outlive the mainloop.
If pointer returned by underlying C function is NULL
, None
will be returned, otherwise a
::mainloop::events::timer::TimeEvent
object will be returned.
fn rttime_restart<T>(&self, e: &TimeEvent<T::MI>, usec: Usecs) where
T: Mainloop,
[src]
T: Mainloop,
Restart a running or expired timer event source (wrapper for
::mainloop::api::MainloopApi.time_restart
).
fn get_tile_size(&self, ss: &Spec) -> Option<usize>
[src]
Return the optimal block size for passing around audio buffers.
It is recommended to allocate buffers of the size returned here when writing audio data to playback streams, if the latency constraints permit this. It is not recommended writing larger blocks than this because usually they will then be split up internally into chunks of this size. It is not recommended writing smaller blocks than this (unless required due to latency demands) because this increases CPU usage.
If ss
is invalid, returns None
, else returns tile size rounded down to multiple of the
frame size. This is supposed to be used in a construct such as:
let size = stream.get_context().get_tile_size( stream.get_sample_spec().unwrap()).unwrap();
[src]
Load the authentication cookie from a file.
This function is primarily meant for PulseAudio's own tunnel modules, which need to load the cookie from a custom location. Applications don't usually need to care about the cookie at all, but if it happens that you know what the authentication cookie is and your application needs to load it from a non-standard location, feel free to use this function.