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