Merge commit 'origin/master-tx'
[platform/upstream/pulseaudio.git] / src / pulse / def.h
1 #ifndef foodefhfoo
2 #define foodefhfoo
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
12   published by the Free Software Foundation; either version 2.1 of the
13   License, 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   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public
21   License 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 <inttypes.h>
27 #include <sys/time.h>
28 #include <time.h>
29
30 #include <pulse/cdecl.h>
31 #include <pulse/sample.h>
32 #include <pulse/version.h>
33
34 /** \file
35  * Global definitions */
36
37 PA_C_DECL_BEGIN
38
39 /** The state of a connection context */
40 typedef enum pa_context_state {
41     PA_CONTEXT_UNCONNECTED,    /**< The context hasn't been connected yet */
42     PA_CONTEXT_CONNECTING,     /**< A connection is being established */
43     PA_CONTEXT_AUTHORIZING,    /**< The client is authorizing itself to the daemon */
44     PA_CONTEXT_SETTING_NAME,   /**< The client is passing its application name to the daemon */
45     PA_CONTEXT_READY,          /**< The connection is established, the context is ready to execute operations */
46     PA_CONTEXT_FAILED,         /**< The connection failed or was disconnected */
47     PA_CONTEXT_TERMINATED      /**< The connection was terminated cleanly */
48 } pa_context_state_t;
49
50 /** Return non-zero if the passed state is one of the connected states. \since 0.9.11 */
51 static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
52     return
53         x == PA_CONTEXT_CONNECTING ||
54         x == PA_CONTEXT_AUTHORIZING ||
55         x == PA_CONTEXT_SETTING_NAME ||
56         x == PA_CONTEXT_READY;
57 }
58
59 /** \cond fulldocs */
60 #define PA_CONTEXT_IS_GOOD PA_CONTEXT_IS_GOOD
61 /** \endcond */
62
63 /** The state of a stream */
64 typedef enum pa_stream_state {
65     PA_STREAM_UNCONNECTED,  /**< The stream is not yet connected to any sink or source */
66     PA_STREAM_CREATING,     /**< The stream is being created */
67     PA_STREAM_READY,        /**< The stream is established, you may pass audio data to it now */
68     PA_STREAM_FAILED,       /**< An error occured that made the stream invalid */
69     PA_STREAM_TERMINATED    /**< The stream has been terminated cleanly */
70 } pa_stream_state_t;
71
72 /** Return non-zero if the passed state is one of the connected states. \since 0.9.11 */
73 static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
74     return
75         x == PA_STREAM_CREATING ||
76         x == PA_STREAM_READY;
77 }
78
79 /** \cond fulldocs */
80 #define PA_STREAM_IS_GOOD PA_STREAM_IS_GOOD
81 /** \endcond */
82
83 /** The state of an operation */
84 typedef enum pa_operation_state {
85     PA_OPERATION_RUNNING,      /**< The operation is still running */
86     PA_OPERATION_DONE,         /**< The operation has been completed */
87     PA_OPERATION_CANCELED      /**< The operation has been canceled */
88 } pa_operation_state_t;
89
90 /** An invalid index */
91 #define PA_INVALID_INDEX ((uint32_t) -1)
92
93 /** Some special flags for contexts. */
94 typedef enum pa_context_flags {
95     PA_CONTEXT_NOAUTOSPAWN = 1
96     /**< Disabled autospawning of the PulseAudio daemon if required */
97 } pa_context_flags_t;
98
99 /** \cond fulldocs */
100 /* Allow clients to check with #ifdef for those flags */
101 #define PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN
102 /** \endcond */
103
104 /** The direction of a pa_stream object */
105 typedef enum pa_stream_direction {
106     PA_STREAM_NODIRECTION,   /**< Invalid direction */
107     PA_STREAM_PLAYBACK,      /**< Playback stream */
108     PA_STREAM_RECORD,        /**< Record stream */
109     PA_STREAM_UPLOAD         /**< Sample upload stream */
110 } pa_stream_direction_t;
111
112 /** Some special flags for stream connections. */
113 typedef enum pa_stream_flags {
114
115     PA_STREAM_START_CORKED = 0x0001U,
116     /**< Create the stream corked, requiring an explicit
117      * pa_stream_cork() call to uncork it. */
118
119     PA_STREAM_INTERPOLATE_TIMING = 0x0002U,
120     /**< Interpolate the latency for this stream. When enabled,
121      * pa_stream_get_latency() and pa_stream_get_time() will try to
122      * estimate the current record/playback time based on the local
123      * time that passed since the last timing info update.  Using this
124      * option has the advantage of not requiring a whole roundtrip
125      * when the current playback/recording time is needed. Consider
126      * using this option when requesting latency information
127      * frequently. This is especially useful on long latency network
128      * connections. It makes a lot of sense to combine this option
129      * with PA_STREAM_AUTO_TIMING_UPDATE. */
130
131     PA_STREAM_NOT_MONOTONIC = 0x0004U,
132     /**< Don't force the time to increase monotonically. If this
133      * option is enabled, pa_stream_get_time() will not necessarily
134      * return always monotonically increasing time values on each
135      * call. This may confuse applications which cannot deal with time
136      * going 'backwards', but has the advantage that bad transport
137      * latency estimations that caused the time to to jump ahead can
138      * be corrected quickly, without the need to wait. (Please note
139      * that this flag was named PA_STREAM_NOT_MONOTONOUS in releases
140      * prior to 0.9.11. The old name is still defined too, for
141      * compatibility reasons. */
142
143     PA_STREAM_AUTO_TIMING_UPDATE = 0x0008U,
144     /**< If set timing update requests are issued periodically
145      * automatically. Combined with PA_STREAM_INTERPOLATE_TIMING you
146      * will be able to query the current time and latency with
147      * pa_stream_get_time() and pa_stream_get_latency() at all times
148      * without a packet round trip.*/
149
150     PA_STREAM_NO_REMAP_CHANNELS = 0x0010U,
151     /**< Don't remap channels by their name, instead map them simply
152      * by their index. Implies PA_STREAM_NO_REMIX_CHANNELS. Only
153      * supported when the server is at least PA 0.9.8. It is ignored
154      * on older servers.\since 0.9.8 */
155
156     PA_STREAM_NO_REMIX_CHANNELS = 0x0020U,
157     /**< When remapping channels by name, don't upmix or downmix them
158      * to related channels. Copy them into matching channels of the
159      * device 1:1. Only supported when the server is at least PA
160      * 0.9.8. It is ignored on older servers. \since 0.9.8 */
161
162     PA_STREAM_FIX_FORMAT = 0x0040U,
163     /**< Use the sample format of the sink/device this stream is being
164      * connected to, and possibly ignore the format the sample spec
165      * contains -- but you still have to pass a valid value in it as a
166      * hint to PulseAudio what would suit your stream best. If this is
167      * used you should query the used sample format after creating the
168      * stream by using pa_stream_get_sample_spec(). Also, if you
169      * specified manual buffer metrics it is recommended to update
170      * them with pa_stream_set_buffer_attr() to compensate for the
171      * changed frame sizes. Only supported when the server is at least
172      * PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
173
174     PA_STREAM_FIX_RATE = 0x0080U,
175     /**< Use the sample rate of the sink, and possibly ignore the rate
176      * the sample spec contains. Usage similar to
177      * PA_STREAM_FIX_FORMAT.Only supported when the server is at least
178      * PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
179
180     PA_STREAM_FIX_CHANNELS = 0x0100,
181     /**< Use the number of channels and the channel map of the sink,
182      * and possibly ignore the number of channels and the map the
183      * sample spec and the passed channel map contains. Usage similar
184      * to PA_STREAM_FIX_FORMAT. Only supported when the server is at
185      * least PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
186
187     PA_STREAM_DONT_MOVE = 0x0200U,
188     /**< Don't allow moving of this stream to another
189      * sink/device. Useful if you use any of the PA_STREAM_FIX_ flags
190      * and want to make sure that resampling never takes place --
191      * which might happen if the stream is moved to another
192      * sink/source whith a different sample spec/channel map. Only
193      * supported when the server is at least PA 0.9.8. It is ignored
194      * on older servers. \since 0.9.8 */
195
196     PA_STREAM_VARIABLE_RATE = 0x0400U,
197     /**< Allow dynamic changing of the sampling rate during playback
198      * with pa_stream_update_sample_rate(). Only supported when the
199      * server is at least PA 0.9.8. It is ignored on older
200      * servers. \since 0.9.8 */
201
202     PA_STREAM_PEAK_DETECT = 0x0800U,
203     /**< Find peaks instead of resampling. \since 0.9.11 */
204
205     PA_STREAM_START_MUTED = 0x1000U,
206     /**< Create in muted state. If neither PA_STREAM_START_UNMUTED nor
207      * PA_STREAM_START_MUTED it is left to the server to decide
208      * whether to create the stream in muted or in unmuted
209      * state. \since 0.9.11 */
210
211     PA_STREAM_ADJUST_LATENCY = 0x2000U,
212     /**< Try to adjust the latency of the sink/source based on the
213      * requested buffer metrics and adjust buffer metrics
214      * accordingly. Also see pa_buffer_attr. This option may not be
215      * specified at the same time as PA_STREAM_EARLY_REQUESTS. \since
216      * 0.9.11 */
217
218     PA_STREAM_EARLY_REQUESTS = 0x4000U,
219     /**< Enable compatibility mode for legacy clients that rely on a
220      * "classic" hardware device fragment-style playback model. If
221      * this option is set, the minreq value of the buffer metrics gets
222      * a new meaning: instead of just specifying that no requests
223      * asking for less new data than this value will be made to the
224      * client it will also guarantee that requests are generated as
225      * early as this limit is reached. This flag should only be set in
226      * very few situations where compatiblity with a fragment-based
227      * playback model needs to be kept and the client applications
228      * cannot deal with data requests that are delayed to the latest
229      * moment possible. (Usually these are programs that use usleep()
230      * or a similar call in their playback loops instead of sleeping
231      * on the device itself.) Also see pa_buffer_attr. This option may
232      * not be specified at the same time as
233      * PA_STREAM_ADJUST_LATENCY. \since 0.9.12 */
234
235     PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND = 0x8000U,
236     /**< If set this stream won't be taken into account when we it is
237      * checked whether the device this stream is connected to should
238      * auto-suspend. \since 0.9.15 */
239
240     PA_STREAM_START_UNMUTED = 0x10000U
241     /**< Create in unmuted state. If neither PA_STREAM_START_UNMUTED
242      * nor PA_STREAM_START_MUTED it is left to the server to decide
243      * whether to create the stream in muted or in unmuted
244      * state. \since 0.9.15 */
245
246 } pa_stream_flags_t;
247
248 /** \cond fulldocs */
249
250 /* English is an evil language */
251 #define PA_STREAM_NOT_MONOTONOUS PA_STREAM_NOT_MONOTONIC
252
253 /* Allow clients to check with #ifdef for those flags */
254 #define PA_STREAM_START_CORKED PA_STREAM_START_CORKED
255 #define PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING
256 #define PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC
257 #define PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE
258 #define PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS
259 #define PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS
260 #define PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT
261 #define PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE
262 #define PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS
263 #define PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE
264 #define PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE
265 #define PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT
266 #define PA_STREAM_START_MUTED PA_STREAM_START_MUTED
267 #define PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY
268 #define PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS
269 #define PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
270 #define PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED
271
272 /** \endcond */
273
274 /** Playback and record buffer metrics */
275 typedef struct pa_buffer_attr {
276     uint32_t maxlength;
277     /**< Maximum length of the buffer. Setting this to (uint32_t) -1
278      * will initialize this to the maximum value supported by server,
279      * which is recommended. */
280
281     uint32_t tlength;
282     /**< Playback only: target length of the buffer. The server tries
283      * to assure that at least tlength bytes are always available in
284      * the per-stream server-side playback buffer. It is recommended
285      * to set this to (uint32_t) -1, which will initialize this to a
286      * value that is deemed sensible by the server. However, this
287      * value will default to something like 2s, i.e. for applications
288      * that have specific latency requirements this value should be
289      * set to the maximum latency that the application can deal
290      * with. When PA_STREAM_ADJUST_LATENCY is not set this value will
291      * influence only the per-stream playback buffer size. When
292      * PA_STREAM_ADJUST_LATENCY is set the overall latency of the sink
293      * plus the playback buffer size is configured to this value. Set
294      * PA_STREAM_ADJUST_LATENCY if you are interested in adjusting the
295      * overall latency. Don't set it if you are interested in
296      * configuring the server-sider per-stream playback buffer
297      * size. */
298
299     uint32_t prebuf;
300     /**< Playback only: pre-buffering. The server does not start with
301      * playback before at least prebug bytes are available in the
302      * buffer. It is recommended to set this to (uint32_t) -1, which
303      * will initialize this to the same value as tlength, whatever
304      * that may be. Initialize to 0 to enable manual start/stop
305      * control of the stream. This means that playback will not stop
306      * on underrun and playback will not start automatically. Instead
307      * pa_stream_corked() needs to be called explicitly. If you set
308      * this value to 0 you should also set PA_STREAM_START_CORKED. */
309
310     uint32_t minreq;
311     /**< Playback only: minimum request. The server does not request
312      * less than minreq bytes from the client, instead waits until the
313      * buffer is free enough to request more bytes at once. It is
314      * recommended to set this to (uint32_t) -1, which will initialize
315      * this to a value that is deemed sensible by the server. This
316      * should be set to a value that gives PulseAudio enough time to
317      * move the data from the per-stream playback buffer into the
318      * hardware playback buffer. */
319
320     uint32_t fragsize;
321     /**< Recording only: fragment size. The server sends data in
322      * blocks of fragsize bytes size. Large values deminish
323      * interactivity with other operations on the connection context
324      * but decrease control overhead. It is recommended to set this to
325      * (uint32_t) -1, which will initialize this to a value that is
326      * deemed sensible by the server. However, this value will default
327      * to something like 2s, i.e. for applications that have specific
328      * latency requirements this value should be set to the maximum
329      * latency that the application can deal with. If
330      * PA_STREAM_ADJUST_LATENCY is set the overall source latency will
331      * be adjusted according to this value. If it is not set the
332      * source latency is left unmodified. */
333
334 } pa_buffer_attr;
335
336 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
337 enum {
338     PA_OK = 0,                     /**< No error */
339     PA_ERR_ACCESS,                 /**< Access failure */
340     PA_ERR_COMMAND,                /**< Unknown command */
341     PA_ERR_INVALID,                /**< Invalid argument */
342     PA_ERR_EXIST,                  /**< Entity exists */
343     PA_ERR_NOENTITY,               /**< No such entity */
344     PA_ERR_CONNECTIONREFUSED,      /**< Connection refused */
345     PA_ERR_PROTOCOL,               /**< Protocol error */
346     PA_ERR_TIMEOUT,                /**< Timeout */
347     PA_ERR_AUTHKEY,                /**< No authorization key */
348     PA_ERR_INTERNAL,               /**< Internal error */
349     PA_ERR_CONNECTIONTERMINATED,   /**< Connection terminated */
350     PA_ERR_KILLED,                 /**< Entity killed */
351     PA_ERR_INVALIDSERVER,          /**< Invalid server */
352     PA_ERR_MODINITFAILED,          /**< Module initialization failed */
353     PA_ERR_BADSTATE,               /**< Bad state */
354     PA_ERR_NODATA,                 /**< No data */
355     PA_ERR_VERSION,                /**< Incompatible protocol version */
356     PA_ERR_TOOLARGE,               /**< Data too large */
357     PA_ERR_NOTSUPPORTED,           /**< Operation not supported \since 0.9.5 */
358     PA_ERR_UNKNOWN,                /**< The error code was unknown to the client */
359     PA_ERR_NOEXTENSION,            /**< Extension does not exist. \since 0.9.12 */
360     PA_ERR_OBSOLETE,               /**< Obsolete functionality. \since 0.9.15 */
361     PA_ERR_MAX                     /**< Not really an error but the first invalid error code */
362 };
363
364 /** Subscription event mask, as used by pa_context_subscribe() */
365 typedef enum pa_subscription_mask {
366     PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
367     /**< No events */
368
369     PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
370     /**< Sink events */
371
372     PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
373     /**< Source events */
374
375     PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
376     /**< Sink input events */
377
378     PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
379     /**< Source output events */
380
381     PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
382     /**< Module events */
383
384     PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
385     /**< Client events */
386
387     PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
388     /**< Sample cache events */
389
390     PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
391     /**< Other global server changes. */
392
393 /** \cond fulldocs */
394     PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
395     /**< \deprecated Autoload table events. */
396 /** \endcond */
397
398     PA_SUBSCRIPTION_MASK_CARD = 0x0200U,
399     /**< Card events. \since 0.9.15 */
400
401     PA_SUBSCRIPTION_MASK_ALL = 0x02ffU
402     /**< Catch all events */
403 } pa_subscription_mask_t;
404
405 /** Subscription event types, as used by pa_context_subscribe() */
406 typedef enum pa_subscription_event_type {
407     PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
408     /**< Event type: Sink */
409
410     PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
411     /**< Event type: Source */
412
413     PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
414     /**< Event type: Sink input */
415
416     PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
417     /**< Event type: Source output */
418
419     PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
420     /**< Event type: Module */
421
422     PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
423     /**< Event type: Client */
424
425     PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
426     /**< Event type: Sample cache item */
427
428     PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
429     /**< Event type: Global server change, only occuring with PA_SUBSCRIPTION_EVENT_CHANGE. */
430
431 /** \cond fulldocs */
432     PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
433     /**< \deprecated Event type: Autoload table changes. */
434 /** \endcond */
435
436     PA_SUBSCRIPTION_EVENT_CARD = 0x0009U,
437     /**< Event type: Card \since 0.9.15 */
438
439     PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
440     /**< A mask to extract the event type from an event value */
441
442     PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
443     /**< A new object was created */
444
445     PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
446     /**< A property of the object was modified */
447
448     PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
449     /**< An object was removed */
450
451     PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
452     /**< A mask to extract the event operation from an event value */
453
454 } pa_subscription_event_type_t;
455
456 /** Return one if an event type t matches an event mask bitfield */
457 #define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
458
459 /** A structure for all kinds of timing information of a stream. See
460  * pa_stream_update_timing_info() and pa_stream_get_timing_info(). The
461  * total output latency a sample that is written with
462  * pa_stream_write() takes to be played may be estimated by
463  * sink_usec+buffer_usec+transport_usec. (where buffer_usec is defined
464  * as pa_bytes_to_usec(write_index-read_index)) The output buffer
465  * which buffer_usec relates to may be manipulated freely (with
466  * pa_stream_write()'s seek argument, pa_stream_flush() and friends),
467  * the buffers sink_usec and source_usec relate to are first-in
468  * first-out (FIFO) buffers which cannot be flushed or manipulated in
469  * any way. The total input latency a sample that is recorded takes to
470  * be delivered to the application is:
471  * source_usec+buffer_usec+transport_usec-sink_usec. (Take care of
472  * sign issues!) When connected to a monitor source sink_usec contains
473  * the latency of the owning sink. The two latency estimations
474  * described here are implemented in pa_stream_get_latency(). Please
475  * note that this structure can be extended as part of evolutionary
476  * API updates at any time in any new release.*/
477 typedef struct pa_timing_info {
478     struct timeval timestamp;
479     /**< The time when this timing info structure was current */
480
481     int synchronized_clocks;
482     /**< Non-zero if the local and the remote machine have
483      * synchronized clocks. If synchronized clocks are detected
484      * transport_usec becomes much more reliable. However, the code
485      * that detects synchronized clocks is very limited und unreliable
486      * itself. */
487
488     pa_usec_t sink_usec;
489     /**< Time in usecs a sample takes to be played on the sink. For
490      * playback streams and record streams connected to a monitor
491      * source. */
492
493     pa_usec_t source_usec;
494     /**< Time in usecs a sample takes from being recorded to being
495      * delivered to the application. Only for record streams. */
496
497     pa_usec_t transport_usec;
498     /**< Estimated time in usecs a sample takes to be transferred
499      * to/from the daemon. For both playback and record streams. */
500
501     int playing;
502     /**< Non-zero when the stream is currently not underrun and data
503      * is being passed on to the device. Only for playback
504      * streams. This field does not say whether the data is actually
505      * already being played. To determine this check whether
506      * since_underrun (converted to usec) is larger than sink_usec.*/
507
508     int write_index_corrupt;
509     /**< Non-zero if write_index is not up-to-date because a local
510      * write command that corrupted it has been issued in the time
511      * since this latency info was current . Only write commands with
512      * SEEK_RELATIVE_ON_READ and SEEK_RELATIVE_END can corrupt
513      * write_index. */
514
515     int64_t write_index;
516     /**< Current write index into the playback buffer in bytes. Think
517      * twice before using this for seeking purposes: it might be out
518      * of date a the time you want to use it. Consider using
519      * PA_SEEK_RELATIVE instead. */
520
521     int read_index_corrupt;
522     /**< Non-zero if read_index is not up-to-date because a local
523      * pause or flush request that corrupted it has been issued in the
524      * time since this latency info was current. */
525
526     int64_t read_index;
527     /**< Current read index into the playback buffer in bytes. Think
528      * twice before using this for seeking purposes: it might be out
529      * of date a the time you want to use it. Consider using
530      * PA_SEEK_RELATIVE_ON_READ instead. */
531
532     pa_usec_t configured_sink_usec;
533     /**< The configured latency for the sink. \since 0.9.11 */
534
535     pa_usec_t configured_source_usec;
536     /**< The configured latency for * the source. \since 0.9.11 */
537
538     int64_t since_underrun;
539     /**< Bytes that were handed to the sink since the last underrun
540      * happened, or since playback started again after the last
541      * underrun. playing will tell you which case it is. \since
542      * 0.9.11 */
543
544 } pa_timing_info;
545
546 /** A structure for the spawn api. This may be used to integrate auto
547  * spawned daemons into your application. For more information see
548  * pa_context_connect(). When spawning a new child process the
549  * waitpid() is used on the child's PID. The spawn routine will not
550  * block or ignore SIGCHLD signals, since this cannot be done in a
551  * thread compatible way. You might have to do this in
552  * prefork/postfork. */
553 typedef struct pa_spawn_api {
554     void (*prefork)(void);
555     /**< Is called just before the fork in the parent process. May be
556      * NULL. */
557
558     void (*postfork)(void);
559     /**< Is called immediately after the fork in the parent
560      * process. May be NULL.*/
561
562     void (*atfork)(void);
563     /**< Is called immediately after the fork in the child
564      * process. May be NULL. It is not safe to close all file
565      * descriptors in this function unconditionally, since a UNIX
566      * socket (created using socketpair()) is passed to the new
567      * process. */
568 } pa_spawn_api;
569
570 /** Seek type for pa_stream_write(). */
571 typedef enum pa_seek_mode {
572     PA_SEEK_RELATIVE = 0,
573     /**< Seek relatively to the write index */
574
575     PA_SEEK_ABSOLUTE = 1,
576     /**< Seek relatively to the start of the buffer queue */
577
578     PA_SEEK_RELATIVE_ON_READ = 2,
579     /**< Seek relatively to the read index.  */
580
581     PA_SEEK_RELATIVE_END = 3
582     /**< Seek relatively to the current end of the buffer queue. */
583 } pa_seek_mode_t;
584
585 /** Special sink flags. */
586 typedef enum pa_sink_flags {
587     PA_SINK_HW_VOLUME_CTRL = 0x0001U,
588     /**< Supports hardware volume control */
589
590     PA_SINK_LATENCY = 0x0002U,
591     /**< Supports latency querying */
592
593     PA_SINK_HARDWARE = 0x0004U,
594     /**< Is a hardware sink of some kind, in contrast to
595      * "virtual"/software sinks \since 0.9.3 */
596
597     PA_SINK_NETWORK = 0x0008U,
598     /**< Is a networked sink of some kind. \since 0.9.7 */
599
600     PA_SINK_HW_MUTE_CTRL = 0x0010U,
601     /**< Supports hardware mute control \since 0.9.11 */
602
603     PA_SINK_DECIBEL_VOLUME = 0x0020U,
604     /**< Volume can be translated to dB with pa_sw_volume_to_dB()
605      * \since 0.9.11 */
606
607     PA_SINK_FLAT_VOLUME = 0x0040U
608     /**< This sink is in flat volume mode, i.e. always the maximum of
609      * the volume of all connected inputs. \since 0.9.15 */
610 } pa_sink_flags_t;
611
612 /** \cond fulldocs */
613 #define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
614 #define PA_SINK_LATENCY PA_SINK_LATENCY
615 #define PA_SINK_HARDWARE PA_SINK_HARDWARE
616 #define PA_SINK_NETWORK PA_SINK_NETWORK
617 #define PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL
618 #define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
619 #define PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME
620 /** \endcond */
621
622 /** Sink state. \since 0.9.15 */
623 typedef enum pa_sink_state { /* enum serialized in u8 */
624     PA_SINK_INVALID_STATE = -1,
625     /**< This state is used when the server does not support sink state introspection \since 0.9.15 */
626
627     PA_SINK_RUNNING = 0,
628     /**< Running, sink is playing and used by at least one non-corked sink-input \since 0.9.15 */
629
630     PA_SINK_IDLE = 1,
631     /**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
632
633     PA_SINK_SUSPENDED = 2,
634     /**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
635
636 /** \cond fulldocs */
637     /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
638      * SIDE! These values are *not* considered part of the official PA
639      * API/ABI. If you use them your application might break when PA
640      * is upgraded. Also, please note that these values are not useful
641      * on the client side anyway. */
642
643     PA_SINK_INIT = -2,
644     /**< Initialization state */
645
646     PA_SINK_UNLINKED = -3
647     /**< The state when the sink is getting unregistered and removed from client access */
648 /** \endcond */
649
650 } pa_sink_state_t;
651
652 /** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
653 static inline int PA_SINK_IS_OPENED(pa_sink_state_t x) {
654     return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
655 }
656
657 /** \cond fulldocs */
658 #define PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE
659 #define PA_SINK_RUNNING PA_SINK_RUNNING
660 #define PA_SINK_IDLE PA_SINK_IDLE
661 #define PA_SINK_SUSPENDED PA_SINK_SUSPENDED
662 #define PA_SINK_IS_OPENED PA_SINK_IS_OPENED
663 /** \endcond */
664
665 /** Special source flags.  */
666 typedef enum pa_source_flags {
667     PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
668     /**< Supports hardware volume control */
669
670     PA_SOURCE_LATENCY = 0x0002U,
671     /**< Supports latency querying */
672
673     PA_SOURCE_HARDWARE = 0x0004U,
674     /**< Is a hardware source of some kind, in contrast to
675      * "virtual"/software source \since 0.9.3 */
676
677     PA_SOURCE_NETWORK = 0x0008U,
678     /**< Is a networked source of some kind. \since 0.9.7 */
679
680     PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
681     /**< Supports hardware mute control \since 0.9.11 */
682
683     PA_SOURCE_DECIBEL_VOLUME = 0x0020U
684     /**< Volume can be translated to dB with pa_sw_volume_to_dB()
685      * \since 0.9.11 */
686 } pa_source_flags_t;
687
688 /** \cond fulldocs */
689 #define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
690 #define PA_SOURCE_LATENCY PA_SOURCE_LATENCY
691 #define PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE
692 #define PA_SOURCE_NETWORK PA_SOURCE_NETWORK
693 #define PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL
694 #define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
695 /** \endcond */
696
697 /** Source state. \since 0.9.15 */
698 typedef enum pa_source_state {
699     PA_SOURCE_INVALID_STATE = -1,
700     /**< This state is used when the server does not support source state introspection \since 0.9.15 */
701
702     PA_SOURCE_RUNNING = 0,
703     /**< Running, source is recording and used by at least one non-corked source-output \since 0.9.15 */
704
705     PA_SOURCE_IDLE = 1,
706     /**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
707
708     PA_SOURCE_SUSPENDED = 2,
709     /**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
710
711 /** \cond fulldocs */
712     /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
713      * SIDE! These values are *not* considered part of the official PA
714      * API/ABI. If you use them your application might break when PA
715      * is upgraded. Also, please note that these values are not useful
716      * on the client side anyway. */
717
718     PA_SOURCE_INIT = -2,
719     /**< Initialization state */
720
721     PA_SOURCE_UNLINKED = -3
722     /**< The state when the source is getting unregistered and removed from client access */
723 /** \endcond */
724
725 } pa_source_state_t;
726
727 /** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
728 static inline int PA_SOURCE_IS_OPENED(pa_source_state_t x) {
729     return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
730 }
731
732 /** \cond fulldocs */
733 #define PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE
734 #define PA_SOURCE_RUNNING PA_SOURCE_RUNNING
735 #define PA_SOURCE_IDLE PA_SOURCE_IDLE
736 #define PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED
737 #define PA_SOURCE_IS_OPENED PA_SOURCE_IS_OPENED
738 /** \endcond */
739
740 /** A generic free() like callback prototype */
741 typedef void (*pa_free_cb_t)(void *p);
742
743 PA_C_DECL_END
744
745 #endif