]> code.delx.au - pulseaudio/blob - src/pulse/stream.h
don't use PA_STREAM_NOT_MONOTONOUS anymore
[pulseaudio] / src / pulse / stream.h
1 #ifndef foostreamhfoo
2 #define foostreamhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
10 PulseAudio is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published
12 by the Free Software Foundation; either version 2 of the License,
13 or (at your option) any later version.
14
15 PulseAudio is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with PulseAudio; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 USA.
24 ***/
25
26 #include <sys/types.h>
27
28 #include <pulse/sample.h>
29 #include <pulse/channelmap.h>
30 #include <pulse/volume.h>
31 #include <pulse/def.h>
32 #include <pulse/cdecl.h>
33 #include <pulse/operation.h>
34
35 /** \page streams Audio Streams
36 *
37 * \section overv_sec Overview
38 *
39 * Audio streams form the central functionality of the sound server. Data is
40 * routed, converted and mixed from several sources before it is passed along
41 * to a final output. Currently, there are three forms of audio streams:
42 *
43 * \li Playback streams - Data flows from the client to the server.
44 * \li Record streams - Data flows from the server to the client.
45 * \li Upload streams - Similar to playback streams, but the data is stored in
46 * the sample cache. See \ref scache for more information
47 * about controlling the sample cache.
48 *
49 * \section create_sec Creating
50 *
51 * To access a stream, a pa_stream object must be created using
52 * pa_stream_new(). At this point the audio sample format and mapping of
53 * channels must be specified. See \ref sample and \ref channelmap for more
54 * information about those structures.
55 *
56 * This first step will only create a client-side object, representing the
57 * stream. To use the stream, a server-side object must be created and
58 * associated with the local object. Depending on which type of stream is
59 * desired, a different function is needed:
60 *
61 * \li Playback stream - pa_stream_connect_playback()
62 * \li Record stream - pa_stream_connect_record()
63 * \li Upload stream - pa_stream_connect_upload() (see \ref scache)
64 *
65 * Similar to how connections are done in contexts, connecting a stream will
66 * not generate a pa_operation object. Also like contexts, the application
67 * should register a state change callback, using
68 * pa_stream_set_state_callback(), and wait for the stream to enter an active
69 * state.
70 *
71 * \subsection bufattr_subsec Buffer Attributes
72 *
73 * Playback and record streams always have a server-side buffer as
74 * part of the data flow. The size of this buffer needs to be chosen
75 * in a compromise between low latency and sensitivity for buffer
76 * overflows/underruns.
77 *
78 * The buffer metrics may be controlled by the application. They are
79 * described with a pa_buffer_attr structure which contains a number
80 * of fields:
81 *
82 * \li maxlength - The absolute maximum number of bytes that can be
83 * stored in the buffer. If this value is exceeded
84 * then data will be lost. It is recommended to pass
85 * (uint32_t) -1 here which will cause the server to
86 * fill in the maximum possible value.
87 *
88 * \li tlength - The target fill level of the playback buffer. The
89 * server will only send requests for more data as long
90 * as the buffer has less than this number of bytes of
91 * data. If you pass (uint32_t) -1 (which is
92 * recommended) here the server will choose the longest
93 * target buffer fill level possible to minimize the
94 * number of necessary wakeups and maximize drop-out
95 * safety. This can exceed 2s of buffering. For
96 * low-latency applications or applications where
97 * latency matters you should pass a proper value here.
98 *
99 * \li prebuf - Number of bytes that need to be in the buffer before
100 * playback will commence. Start of playback can be
101 * forced using pa_stream_trigger() even though the
102 * prebuffer size hasn't been reached. If a buffer
103 * underrun occurs, this prebuffering will be again
104 * enabled. If the playback shall never stop in case of a
105 * buffer underrun, this value should be set to 0. In
106 * that case the read index of the output buffer
107 * overtakes the write index, and hence the fill level of
108 * the buffer is negative. If you pass (uint32_t) -1 here
109 * (which is recommended) the server will choose the same
110 * value as tlength here.
111 *
112 * \li minreq - Minimum free number of the bytes in the playback
113 * buffer before the server will request more data. It is
114 * recommended to fill in (uint32_t) -1 here. This value
115 * influences how much time the sound server has to move
116 * data from the per-stream server-side playback buffer
117 * to the hardware playback buffer.
118 *
119 * \li fragsize - Maximum number of bytes that the server will push in
120 * one chunk for record streams. If you pass (uint32_t)
121 * -1 (which is recommended) here, the server will
122 * choose the longest fragment setting possible to
123 * minimize the number of necessary wakeups and
124 * maximize drop-out safety. This can exceed 2s of
125 * buffering. For low-latency applications or
126 * applications where latency matters you should pass a
127 * proper value here.
128 *
129 * If PA_STREAM_ADJUST_LATENCY is set, then the tlength/fragsize
130 * parameters will be interpreted slightly differently than described
131 * above when passed to pa_stream_connect_record() and
132 * pa_stream_connect_playback(): the overall latency that is comprised
133 * of both the server side playback buffer length, the hardware
134 * playback buffer length and additional latencies will be adjusted in
135 * a way that it matches tlength resp. fragsize. Set
136 * PA_STREAM_ADJUST_LATENCY if you want to control the overall
137 * playback latency for your stream. Unset it if you want to control
138 * only the latency induced by the server-side, rewritable playback
139 * buffer. The server will try to fulfill the clients latency requests
140 * as good as possible. However if the underlying hardware cannot
141 * change the hardware buffer length or only in a limited range, the
142 * actually resulting latency might be different from what the client
143 * requested. Thus, for synchronization clients always need to check
144 * the actual measured latency via pa_stream_get_latency() or a
145 * similar call, and not make any assumptions. about the latency
146 * available. The function pa_stream_get_buffer_attr() will always
147 * return the actual size of the server-side per-stream buffer in
148 * tlength/fragsize, regardless whether PA_STREAM_ADJUST_LATENCY is
149 * set or not.
150 *
151 * The server-side per-stream playback buffers are indexed by a write and a read
152 * index. The application writes to the write index and the sound
153 * device reads from the read index. The read index is increased
154 * monotonically, while the write index may be freely controlled by
155 * the application. Substracting the read index from the write index
156 * will give you the current fill level of the buffer. The read/write
157 * indexes are 64bit values and measured in bytes, they will never
158 * wrap. The current read/write index may be queried using
159 * pa_stream_get_timing_info() (see below for more information). In
160 * case of a buffer underrun the read index is equal or larger than
161 * the write index. Unless the prebuf value is 0, PulseAudio will
162 * temporarily pause playback in such a case, and wait until the
163 * buffer is filled up to prebuf bytes again. If prebuf is 0, the
164 * read index may be larger than the write index, in which case
165 * silence is played. If the application writes data to indexes lower
166 * than the read index, the data is immediately lost.
167 *
168 * \section transfer_sec Transferring Data
169 *
170 * Once the stream is up, data can start flowing between the client and the
171 * server. Two different access models can be used to transfer the data:
172 *
173 * \li Asynchronous - The application register a callback using
174 * pa_stream_set_write_callback() and
175 * pa_stream_set_read_callback() to receive notifications
176 * that data can either be written or read.
177 * \li Polled - Query the library for available data/space using
178 * pa_stream_writable_size() and pa_stream_readable_size() and
179 * transfer data as needed. The sizes are stored locally, in the
180 * client end, so there is no delay when reading them.
181 *
182 * It is also possible to mix the two models freely.
183 *
184 * Once there is data/space available, it can be transferred using either
185 * pa_stream_write() for playback, or pa_stream_peek() / pa_stream_drop() for
186 * record. Make sure you do not overflow the playback buffers as data will be
187 * dropped.
188 *
189 * \section bufctl_sec Buffer Control
190 *
191 * The transfer buffers can be controlled through a number of operations:
192 *
193 * \li pa_stream_cork() - Start or stop the playback or recording.
194 * \li pa_stream_trigger() - Start playback immediatly and do not wait for
195 * the buffer to fill up to the set trigger level.
196 * \li pa_stream_prebuf() - Reenable the playback trigger level.
197 * \li pa_stream_drain() - Wait for the playback buffer to go empty. Will
198 * return a pa_operation object that will indicate when
199 * the buffer is completely drained.
200 * \li pa_stream_flush() - Drop all data from the playback buffer and do not
201 * wait for it to finish playing.
202 *
203 * \section seek_modes Seeking in the Playback Buffer
204 *
205 * A client application may freely seek in the playback buffer. To
206 * accomplish that the pa_stream_write() function takes a seek mode
207 * and an offset argument. The seek mode is one of:
208 *
209 * \li PA_SEEK_RELATIVE - seek relative to the current write index
210 * \li PA_SEEK_ABSOLUTE - seek relative to the beginning of the playback buffer, (i.e. the first that was ever played in the stream)
211 * \li PA_SEEK_RELATIVE_ON_READ - seek relative to the current read index. Use this to write data to the output buffer that should be played as soon as possible
212 * \li PA_SEEK_RELATIVE_END - seek relative to the last byte ever written.
213 *
214 * If an application just wants to append some data to the output
215 * buffer, PA_SEEK_RELATIVE and an offset of 0 should be used.
216 *
217 * After a call to pa_stream_write() the write index will be left at
218 * the position right after the last byte of the written data.
219 *
220 * \section latency_sec Latency
221 *
222 * A major problem with networked audio is the increased latency caused by
223 * the network. To remedy this, PulseAudio supports an advanced system of
224 * monitoring the current latency.
225 *
226 * To get the raw data needed to calculate latencies, call
227 * pa_stream_get_timing_info(). This will give you a pa_timing_info
228 * structure that contains everything that is known about the server
229 * side buffer transport delays and the backend active in the
230 * server. (Besides other things it contains the write and read index
231 * values mentioned above.)
232 *
233 * This structure is updated every time a
234 * pa_stream_update_timing_info() operation is executed. (i.e. before
235 * the first call to this function the timing information structure is
236 * not available!) Since it is a lot of work to keep this structure
237 * up-to-date manually, PulseAudio can do that automatically for you:
238 * if PA_STREAM_AUTO_TIMING_UPDATE is passed when connecting the
239 * stream PulseAudio will automatically update the structure every
240 * 100ms and every time a function is called that might invalidate the
241 * previously known timing data (such as pa_stream_write() or
242 * pa_stream_flush()). Please note however, that there always is a
243 * short time window when the data in the timing information structure
244 * is out-of-date. PulseAudio tries to mark these situations by
245 * setting the write_index_corrupt and read_index_corrupt fields
246 * accordingly.
247 *
248 * The raw timing data in the pa_timing_info structure is usually hard
249 * to deal with. Therefore a simpler interface is available:
250 * you can call pa_stream_get_time() or pa_stream_get_latency(). The
251 * former will return the current playback time of the hardware since
252 * the stream has been started. The latter returns the overall time a sample
253 * that you write now takes to be played by the hardware. These two
254 * functions base their calculations on the same data that is returned
255 * by pa_stream_get_timing_info(). Hence the same rules for keeping
256 * the timing data up-to-date apply here. In case the write or read
257 * index is corrupted, these two functions will fail with
258 * PA_ERR_NODATA set.
259 *
260 * Since updating the timing info structure usually requires a full
261 * network round trip and some applications monitor the timing very
262 * often PulseAudio offers a timing interpolation system. If
263 * PA_STREAM_INTERPOLATE_TIMING is passed when connecting the stream,
264 * pa_stream_get_time() and pa_stream_get_latency() will try to
265 * interpolate the current playback time/latency by estimating the
266 * number of samples that have been played back by the hardware since
267 * the last regular timing update. It is espcially useful to combine
268 * this option with PA_STREAM_AUTO_TIMING_UPDATE, which will enable
269 * you to monitor the current playback time/latency very precisely and
270 * very frequently without requiring a network round trip every time.
271 *
272 * \section flow_sec Overflow and underflow
273 *
274 * Even with the best precautions, buffers will sometime over - or
275 * underflow. To handle this gracefully, the application can be
276 * notified when this happens. Callbacks are registered using
277 * pa_stream_set_overflow_callback() and
278 * pa_stream_set_underflow_callback().
279 *
280 * \section sync_streams Sychronizing Multiple Playback Streams
281 *
282 * PulseAudio allows applications to fully synchronize multiple
283 * playback streams that are connected to the same output device. That
284 * means the streams will always be played back sample-by-sample
285 * synchronously. If stream operations like pa_stream_cork() are
286 * issued on one of the synchronized streams, they are simultaneously
287 * issued on the others.
288 *
289 * To synchronize a stream to another, just pass the "master" stream
290 * as last argument to pa_stream_connect_playack(). To make sure that
291 * the freshly created stream doesn't start playback right-away, make
292 * sure to pass PA_STREAM_START_CORKED and - after all streams have
293 * been created - uncork them all with a single call to
294 * pa_stream_cork() for the master stream.
295 *
296 * To make sure that a particular stream doesn't stop to play when a
297 * server side buffer underrun happens on it while the other
298 * synchronized streams continue playing and hence deviate you need to
299 * pass a "prebuf" pa_buffer_attr of 0 when connecting it.
300 *
301 * \section disc_sec Disconnecting
302 *
303 * When a stream has served is purpose it must be disconnected with
304 * pa_stream_disconnect(). If you only unreference it, then it will live on
305 * and eat resources both locally and on the server until you disconnect the
306 * context.
307 *
308 */
309
310 /** \file
311 * Audio streams for input, output and sample upload */
312
313 PA_C_DECL_BEGIN
314
315 /** An opaque stream for playback or recording */
316 typedef struct pa_stream pa_stream;
317
318 /** A generic callback for operation completion */
319 typedef void (*pa_stream_success_cb_t) (pa_stream*s, int success, void *userdata);
320
321 /** A generic request callback */
322 typedef void (*pa_stream_request_cb_t)(pa_stream *p, size_t bytes, void *userdata);
323
324 /** A generic notification callback */
325 typedef void (*pa_stream_notify_cb_t)(pa_stream *p, void *userdata);
326
327 /** Create a new, unconnected stream with the specified name and
328 * sample type. It is recommended to use pa_stream_new_with_proplist()
329 * instead and specify some initial properties. */
330 pa_stream* pa_stream_new(
331 pa_context *c /**< The context to create this stream in */,
332 const char *name /**< A name for this stream */,
333 const pa_sample_spec *ss /**< The desired sample format */,
334 const pa_channel_map *map /**< The desired channel map, or NULL for default */);
335
336 /** Create a new, unconnected stream with the specified name and
337 * sample type, and specify the the initial stream property
338 * list. \since 0.9.11 */
339 pa_stream* pa_stream_new_with_proplist(
340 pa_context *c /**< The context to create this stream in */,
341 const char *name /**< A name for this stream */,
342 const pa_sample_spec *ss /**< The desired sample format */,
343 const pa_channel_map *map /**< The desired channel map, or NULL for default */,
344 pa_proplist *p /**< The initial property list */);
345
346 /** Decrease the reference counter by one */
347 void pa_stream_unref(pa_stream *s);
348
349 /** Increase the reference counter by one */
350 pa_stream *pa_stream_ref(pa_stream *s);
351
352 /** Return the current state of the stream */
353 pa_stream_state_t pa_stream_get_state(pa_stream *p);
354
355 /** Return the context this stream is attached to */
356 pa_context* pa_stream_get_context(pa_stream *p);
357
358 /** Return the sink input resp. source output index this stream is
359 * identified in the server with. This is useful for usage with the
360 * introspection functions, such as pa_context_get_sink_input_info()
361 * resp. pa_context_get_source_output_info(). */
362 uint32_t pa_stream_get_index(pa_stream *s);
363
364 /** Return the index of the sink or source this stream is connected to
365 * in the server. This is useful for usage with the introspection
366 * functions, such as pa_context_get_sink_info_by_index()
367 * resp. pa_context_get_source_info_by_index(). Please note that
368 * streams may be moved between sinks/sources and thus it is
369 * recommended to use pa_stream_set_moved_callback() to be notified
370 * about this. This function will return with PA_ERR_NOTSUPPORTED when the
371 * server is older than 0.9.8. \since 0.9.8 */
372 uint32_t pa_stream_get_device_index(pa_stream *s);
373
374 /** Return the name of the sink or source this stream is connected to
375 * in the server. This is useful for usage with the introspection
376 * functions, such as pa_context_get_sink_info_by_name()
377 * resp. pa_context_get_source_info_by_name(). Please note that
378 * streams may be moved between sinks/sources and thus it is
379 * recommended to use pa_stream_set_moved_callback() to be notified
380 * about this. This function will return with PA_ERR_NOTSUPPORTED when the
381 * server is older than 0.9.8. \since 0.9.8 */
382 const char *pa_stream_get_device_name(pa_stream *s);
383
384 /** Return 1 if the sink or source this stream is connected to has
385 * been suspended. This will return 0 if not, and negative on
386 * error. This function will return with PA_ERR_NOTSUPPORTED when the
387 * server is older than 0.9.8. \since 0.9.8 */
388 int pa_stream_is_suspended(pa_stream *s);
389
390 /** Return 1 if the this stream has been corked. This will return 0 if
391 * not, and negative on error. \since 0.9.11 */
392 int pa_stream_is_corked(pa_stream *s);
393
394 /** Connect the stream to a sink */
395 int pa_stream_connect_playback(
396 pa_stream *s /**< The stream to connect to a sink */,
397 const char *dev /**< Name of the sink to connect to, or NULL for default */ ,
398 const pa_buffer_attr *attr /**< Buffering attributes, or NULL for default */,
399 pa_stream_flags_t flags /**< Additional flags, or 0 for default */,
400 pa_cvolume *volume /**< Initial volume, or NULL for default */,
401 pa_stream *sync_stream /**< Synchronize this stream with the specified one, or NULL for a standalone stream*/);
402
403 /** Connect the stream to a source */
404 int pa_stream_connect_record(
405 pa_stream *s /**< The stream to connect to a source */ ,
406 const char *dev /**< Name of the source to connect to, or NULL for default */,
407 const pa_buffer_attr *attr /**< Buffer attributes, or NULL for default */,
408 pa_stream_flags_t flags /**< Additional flags, or 0 for default */);
409
410 /** Disconnect a stream from a source/sink */
411 int pa_stream_disconnect(pa_stream *s);
412
413 /** Write some data to the server (for playback sinks), if free_cb is
414 * non-NULL this routine is called when all data has been written out
415 * and an internal reference to the specified data is kept, the data
416 * is not copied. If NULL, the data is copied into an internal
417 * buffer. The client my freely seek around in the output buffer. For
418 * most applications passing 0 and PA_SEEK_RELATIVE as arguments for
419 * offset and seek should be useful.*/
420 int pa_stream_write(
421 pa_stream *p /**< The stream to use */,
422 const void *data /**< The data to write */,
423 size_t nbytes /**< The length of the data to write in bytes*/,
424 pa_free_cb_t free_cb /**< A cleanup routine for the data or NULL to request an internal copy */,
425 int64_t offset, /**< Offset for seeking, must be 0 for upload streams */
426 pa_seek_mode_t seek /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */);
427
428 /** Read the next fragment from the buffer (for recording).
429 * data will point to the actual data and length will contain the size
430 * of the data in bytes (which can be less than a complete framgnet).
431 * Use pa_stream_drop() to actually remove the data from the
432 * buffer. If no data is available will return a NULL pointer */
433 int pa_stream_peek(
434 pa_stream *p /**< The stream to use */,
435 const void **data /**< Pointer to pointer that will point to data */,
436 size_t *nbytes /**< The length of the data read in bytes */);
437
438 /** Remove the current fragment on record streams. It is invalid to do this without first
439 * calling pa_stream_peek(). */
440 int pa_stream_drop(pa_stream *p);
441
442 /** Return the number of bytes that may be written using pa_stream_write() */
443 size_t pa_stream_writable_size(pa_stream *p);
444
445 /** Return the number of bytes that may be read using pa_stream_peek()*/
446 size_t pa_stream_readable_size(pa_stream *p);
447
448 /** Drain a playback stream. Use this for notification when the buffer is empty */
449 pa_operation* pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
450
451 /** Request a timing info structure update for a stream. Use
452 * pa_stream_get_timing_info() to get access to the raw timing data,
453 * or pa_stream_get_time() or pa_stream_get_latency() to get cleaned
454 * up values. */
455 pa_operation* pa_stream_update_timing_info(pa_stream *p, pa_stream_success_cb_t cb, void *userdata);
456
457 /** Set the callback function that is called whenever the state of the stream changes */
458 void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata);
459
460 /** Set the callback function that is called when new data may be
461 * written to the stream. */
462 void pa_stream_set_write_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata);
463
464 /** Set the callback function that is called when new data is available from the stream.
465 * Return the number of bytes read.*/
466 void pa_stream_set_read_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata);
467
468 /** Set the callback function that is called when a buffer overflow happens. (Only for playback streams) */
469 void pa_stream_set_overflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
470
471 /** Set the callback function that is called when a buffer underflow happens. (Only for playback streams) */
472 void pa_stream_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
473
474 /** Set the callback function that is called when a the server starts
475 * playback after an underrun or on initial startup. This only informs
476 * that audio is flowing again, it is no indication that audio started
477 * to reach the speakers already. (Only for playback streams). \since
478 * 0.9.11 */
479 void pa_stream_set_started_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
480
481 /** Set the callback function that is called whenever a latency
482 * information update happens. Useful on PA_STREAM_AUTO_TIMING_UPDATE
483 * streams only. (Only for playback streams) */
484 void pa_stream_set_latency_update_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
485
486 /** Set the callback function that is called whenever the stream is
487 * moved to a different sink/source. Use pa_stream_get_device_name()or
488 * pa_stream_get_device_index() to query the new sink/source. This
489 * notification is only generated when the server is at least
490 * 0.9.8. \since 0.9.8 */
491 void pa_stream_set_moved_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
492
493 /** Set the callback function that is called whenever the sink/source
494 * this stream is connected to is suspended or resumed. Use
495 * pa_stream_is_suspended() to query the new suspend status. Please
496 * note that the suspend status might also change when the stream is
497 * moved between devices. Thus if you call this function you very
498 * likely want to call pa_stream_set_moved_callback, too. This
499 * notification is only generated when the server is at least
500 * 0.9.8. \since 0.9.8 */
501 void pa_stream_set_suspended_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
502
503 /** Pause (or resume) playback of this stream temporarily. Available on both playback and recording streams. */
504 pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, void *userdata);
505
506 /** Flush the playback buffer of this stream. Most of the time you're
507 * better off using the parameter delta of pa_stream_write() instead
508 * of this function. Available on both playback and recording
509 * streams. */
510 pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
511
512 /** Reenable prebuffering as specified in the pa_buffer_attr
513 * structure. Available for playback streams only. */
514 pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
515
516 /** Request immediate start of playback on this stream. This disables
517 * prebuffering as specified in the pa_buffer_attr structure,
518 * temporarily. Available for playback streams only. */
519 pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
520
521 /** Rename the stream. */
522 pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_success_cb_t cb, void *userdata);
523
524 /** Return the current playback/recording time. This is based on the
525 * data in the timing info structure returned by
526 * pa_stream_get_timing_info(). This function will usually only return
527 * new data if a timing info update has been recieved. Only if timing
528 * interpolation has been requested (PA_STREAM_INTERPOLATE_TIMING)
529 * the data from the last timing update is used for an estimation of
530 * the current playback/recording time based on the local time that
531 * passed since the timing info structure has been acquired. The time
532 * value returned by this function is guaranteed to increase
533 * monotonically. (that means: the returned value is always greater or
534 * equal to the value returned on the last call) This behaviour can
535 * be disabled by using PA_STREAM_NOT_MONOTONIC. This may be
536 * desirable to deal better with bad estimations of transport
537 * latencies, but may have strange effects if the application is not
538 * able to deal with time going 'backwards'. */
539 int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec);
540
541 /** Return the total stream latency. This function is based on
542 * pa_stream_get_time(). In case the stream is a monitoring stream the
543 * result can be negative, i.e. the captured samples are not yet
544 * played. In this case *negative is set to 1. */
545 int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative);
546
547 /** Return the latest raw timing data structure. The returned pointer
548 * points to an internal read-only instance of the timing
549 * structure. The user should make a copy of this structure if he
550 * wants to modify it. An in-place update to this data structure may
551 * be requested using pa_stream_update_timing_info(). If no
552 * pa_stream_update_timing_info() call was issued before, this
553 * function will fail with PA_ERR_NODATA. Please note that the
554 * write_index member field (and only this field) is updated on each
555 * pa_stream_write() call, not just when a timing update has been
556 * recieved. */
557 const pa_timing_info* pa_stream_get_timing_info(pa_stream *s);
558
559 /** Return a pointer to the stream's sample specification. */
560 const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s);
561
562 /** Return a pointer to the stream's channel map. */
563 const pa_channel_map* pa_stream_get_channel_map(pa_stream *s);
564
565 /** Return the per-stream server-side buffer metrics of the
566 * stream. Only valid after the stream has been connected successfuly
567 * and if the server is at least PulseAudio 0.9. This will return the
568 * actual configured buffering metrics, which may differ from what was
569 * requested during pa_stream_connect_record() or
570 * pa_stream_connect_playback(). This call will always return the
571 * actually per-stream server-side buffer metrics, regardless whether
572 * PA_STREAM_ADJUST_LATENCY is set or not. \since 0.9.0 */
573 const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s);
574
575 /** Change the buffer metrics of the stream during playback. The
576 * server might have chosen different buffer metrics then
577 * requested. The selected metrics may be queried with
578 * pa_stream_get_buffer_attr() as soon as the callback is called. Only
579 * valid after the stream has been connected successfully and if the
580 * server is at least PulseAudio 0.9.8. Please be aware of the
581 * slightly different semantics of the call depending whether
582 * PA_STREAM_ADJUST_LATENCY is set or not. \since 0.9.8 */
583 pa_operation *pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr, pa_stream_success_cb_t cb, void *userdata);
584
585 /** Change the stream sampling rate during playback. You need to pass
586 * PA_STREAM_VARIABLE_RATE in the flags parameter of
587 * pa_stream_connect() if you plan to use this function. Only valid
588 * after the stream has been connected successfully and if the server
589 * is at least PulseAudio 0.9.8. \since 0.9.8 */
590 pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_stream_success_cb_t cb, void *userdata);
591
592 /** Update the property list of the sink input/source output of this
593 * stream, adding new entries. Please note that it is highly
594 * recommended to set as much properties initially via
595 * pa_stream_new_with_proplist() as possible instead a posteriori with
596 * this function, since that information may then be used to route
597 * this stream to the right device. \since 0.9.11 */
598 pa_operation *pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_proplist *p, pa_stream_success_cb_t cb, void *userdata);
599
600 /** Update the property list of the sink input/source output of this
601 * stream, remove entries. \since 0.9.11 */
602 pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[], pa_stream_success_cb_t cb, void *userdata);
603
604 /** For record streams connected to a monitor source: monitor only a
605 * very specific sink input of the sink. Thus function needs to be
606 * called before pa_stream_connect_record() is called. \since
607 * 0.9.11 */
608 int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx);
609
610 /** Return what has been set with pa_stream_set_monitor_stream()
611 * ebfore. \since 0.9.11 */
612 uint32_t pa_stream_get_monitor_stream(pa_stream *s);
613
614 PA_C_DECL_END
615
616 #endif