Path: blob/master/thirdparty/linuxbsd_headers/pulse/scache.h
9905 views
#ifndef fooscachehfoo1#define fooscachehfoo23/***4This file is part of PulseAudio.56Copyright 2004-2006 Lennart Poettering7Copyright 2006 Pierre Ossman <[email protected]> for Cendio AB89PulseAudio is free software; you can redistribute it and/or modify10it under the terms of the GNU Lesser General Public License as published11by the Free Software Foundation; either version 2.1 of the License,12or (at your option) any later version.1314PulseAudio is distributed in the hope that it will be useful, but15WITHOUT ANY WARRANTY; without even the implied warranty of16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17General Public License for more details.1819You should have received a copy of the GNU Lesser General Public License20along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.21***/2223#include <sys/types.h>2425#include <pulse/context.h>26#include <pulse/stream.h>27#include <pulse/cdecl.h>28#include <pulse/version.h>2930/** \page scache Sample Cache31*32* \section overv_sec Overview33*34* The sample cache provides a simple way of overcoming high network latencies35* and reducing bandwidth. Instead of streaming a sound precisely when it36* should be played, it is stored on the server and only the command to start37* playing it needs to be sent.38*39* \section create_sec Creation40*41* To create a sample, the normal stream API is used (see \ref streams). The42* function pa_stream_connect_upload() will make sure the stream is stored as43* a sample on the server.44*45* To complete the upload, pa_stream_finish_upload() is called and the sample46* will receive the same name as the stream. If the upload should be aborted,47* simply call pa_stream_disconnect().48*49* \section play_sec Playing samples50*51* To play back a sample, simply call pa_context_play_sample():52*53* \code54* pa_operation *o;55*56* o = pa_context_play_sample(my_context,57* "sample2", // Name of my sample58* NULL, // Use default sink59* PA_VOLUME_NORM, // Full volume60* NULL, // Don't need a callback61* NULL62* );63* if (o)64* pa_operation_unref(o);65* \endcode66*67* \section rem_sec Removing samples68*69* When a sample is no longer needed, it should be removed on the server to70* save resources. The sample is deleted using pa_context_remove_sample().71*/7273/** \file74* All sample cache related routines75*76* See also \subpage scache77*/7879PA_C_DECL_BEGIN8081/** Callback prototype for pa_context_play_sample_with_proplist(). The82* idx value is the index of the sink input object, or83* PA_INVALID_INDEX on failure. \since 0.9.11 */84typedef void (*pa_context_play_sample_cb_t)(pa_context *c, uint32_t idx, void *userdata);8586/** Make this stream a sample upload stream */87int pa_stream_connect_upload(pa_stream *s, size_t length);8889/** Finish the sample upload, the stream name will become the sample90* name. You cancel a sample upload by issuing91* pa_stream_disconnect() */92int pa_stream_finish_upload(pa_stream *s);9394/** Remove a sample from the sample cache. Returns an operation object which may be used to cancel the operation while it is running */95pa_operation* pa_context_remove_sample(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata);9697/** Play a sample from the sample cache to the specified device. If98* the latter is NULL use the default sink. Returns an operation99* object */100pa_operation* pa_context_play_sample(101pa_context *c /**< Context */,102const char *name /**< Name of the sample to play */,103const char *dev /**< Sink to play this sample on */,104pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,105pa_context_success_cb_t cb /**< Call this function after successfully starting playback, or NULL */,106void *userdata /**< Userdata to pass to the callback */);107108/** Play a sample from the sample cache to the specified device,109* allowing specification of a property list for the playback110* stream. If the latter is NULL use the default sink. Returns an111* operation object. \since 0.9.11 */112pa_operation* pa_context_play_sample_with_proplist(113pa_context *c /**< Context */,114const char *name /**< Name of the sample to play */,115const char *dev /**< Sink to play this sample on */,116pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,117pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will be merged into this property list */,118pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */,119void *userdata /**< Userdata to pass to the callback */);120121PA_C_DECL_END122123#endif124125126