1 module pulse.scache;
2 
3 import pulse.context;
4 import pulse.stream;
5 import pulse.context;
6 import pulse.proplist;
7 import pulse.channelmap;
8 import pulse.sample;
9 import pulse.operation;
10 import pulse.volume;
11 
12 extern (C):
13 
14 /***
15   This file is part of PulseAudio.
16 
17   Copyright 2004-2006 Lennart Poettering
18   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
19 
20   PulseAudio is free software; you can redistribute it and/or modify
21   it under the terms of the GNU Lesser General Public License as published
22   by the Free Software Foundation; either version 2.1 of the License,
23   or (at your option) any later version.
24 
25   PulseAudio is distributed in the hope that it will be useful, but
26   WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28   General Public License for more details.
29 
30   You should have received a copy of the GNU Lesser General Public License
31   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
32 ***/
33 
34 /** \page scache Sample Cache
35  *
36  * \section overv_sec Overview
37  *
38  * The sample cache provides a simple way of overcoming high network latencies
39  * and reducing bandwidth. Instead of streaming a sound precisely when it
40  * should be played, it is stored on the server and only the command to start
41  * playing it needs to be sent.
42  *
43  * \section create_sec Creation
44  *
45  * To create a sample, the normal stream API is used (see \ref streams). The
46  * function pa_stream_connect_upload() will make sure the stream is stored as
47  * a sample on the server.
48  *
49  * To complete the upload, pa_stream_finish_upload() is called and the sample
50  * will receive the same name as the stream. If the upload should be aborted,
51  * simply call pa_stream_disconnect().
52  *
53  * \section play_sec Playing samples
54  *
55  * To play back a sample, simply call pa_context_play_sample():
56  *
57  * \code
58  * pa_operation *o;
59  *
60  * o = pa_context_play_sample(my_context,
61  *                            "sample2",       // Name of my sample
62  *                            NULL,            // Use default sink
63  *                            PA_VOLUME_NORM,  // Full volume
64  *                            NULL,            // Don't need a callback
65  *                            NULL
66  *                            );
67  * if (o)
68  *     pa_operation_unref(o);
69  * \endcode
70  *
71  * \section rem_sec Removing samples
72  *
73  * When a sample is no longer needed, it should be removed on the server to
74  * save resources. The sample is deleted using pa_context_remove_sample().
75  */
76 
77 /** \file
78  * All sample cache related routines
79  *
80  * See also \subpage scache
81  */
82 
83 /** Callback prototype for pa_context_play_sample_with_proplist(). The
84  * idx value is the index of the sink input object, or
85  * PA_INVALID_INDEX on failure. \since 0.9.11 */
86 alias pa_context_play_sample_cb_t = void function (pa_context* c, uint idx, void* userdata);
87 
88 /** Make this stream a sample upload stream. Returns zero on success. */
89 int pa_stream_connect_upload (pa_stream* s, size_t length);
90 
91 /** Finish the sample upload, the stream name will become the sample
92  * name. You cancel a sample upload by issuing
93  * pa_stream_disconnect(). Returns zero on success. */
94 int pa_stream_finish_upload (pa_stream* s);
95 
96 /** Remove a sample from the sample cache. Returns an operation object which
97  * may be used to cancel the operation while it is running. */
98 pa_operation* pa_context_remove_sample (pa_context* c, const(char)* name, pa_context_success_cb_t cb, void* userdata);
99 
100 /** Play a sample from the sample cache to the specified device. If
101  * the latter is NULL use the default sink. Returns an operation
102  * object */
103 
104 /**< Context */
105 /**< Name of the sample to play */
106 /**< Sink to play this sample on */
107 /**< 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. */
108 /**< Call this function after successfully starting playback, or NULL */
109 /**< Userdata to pass to the callback */
110 pa_operation* pa_context_play_sample (
111     pa_context* c,
112     const(char)* name,
113     const(char)* dev,
114     pa_volume_t volume,
115     pa_context_success_cb_t cb,
116     void* userdata);
117 
118 /** Play a sample from the sample cache to the specified device,
119  * allowing specification of a property list for the playback
120  * stream. If the latter is NULL use the default sink. Returns an
121  * operation object. \since 0.9.11 */
122 
123 /**< Context */
124 /**< Name of the sample to play */
125 /**< Sink to play this sample on */
126 /**< 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.  */
127 /**< Property list for this sound. The property list of the cached entry will have this merged into it. */
128 /**< Call this function after successfully starting playback, or NULL */
129 /**< Userdata to pass to the callback */
130 pa_operation* pa_context_play_sample_with_proplist (
131     pa_context* c,
132     const(char)* name,
133     const(char)* dev,
134     pa_volume_t volume,
135     const(pa_proplist)* proplist,
136     pa_context_play_sample_cb_t cb,
137     void* userdata);
138