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