[−][src]Module libpulse_binding::context::scache
Sample cache mechanism.
Overview
The sample cache provides a simple way of overcoming high network latencies and reducing bandwidth. Instead of streaming a sound precisely when it should be played, it is stored on the server and only the command to start playing it needs to be sent.
Creation
To create a sample, the normal stream API is used (see stream
). The function
stream::Stream::connect_upload
will make sure the stream is stored as a sample on the
server.
To complete the upload, stream::Stream::finish_upload
is called and the sample will receive
the same name as the stream. If the upload should be aborted, simply call
stream::Stream::disconnect
.
Playing samples
To play back a sample, simply call context::Context::play_sample
:
extern crate libpulse_binding as pulse; use pulse::volume; //... let o = my_context.play_sample( "sample2", // Name of my sample None, // Use default sink volume::VOLUME_NORM, // Full volume None // Don’t need a callback );
Removing samples
When a sample is no longer needed, it should be removed on the server to save resources. The
sample is deleted using context::Context::remove_sample
.