]> code.delx.au - pulseaudio/blob - src/pulse/def.h
Merge commit 'flameeyes/flameeyes'
[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_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_FAIL_ON_SUSPEND = 0x20000U
247 /**< If the sink/source this stream is connected to is suspended
248 * during the creation of this stream, cause it to fail. If the
249 * sink/source is being suspended during creation of this stream,
250 * make sure this stream is terminated. \since 0.9.15 */
251 } pa_stream_flags_t;
252
253 /** \cond fulldocs */
254
255 /* English is an evil language */
256 #define PA_STREAM_NOT_MONOTONOUS PA_STREAM_NOT_MONOTONIC
257
258 /* Allow clients to check with #ifdef for those flags */
259 #define PA_STREAM_START_CORKED PA_STREAM_START_CORKED
260 #define PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING
261 #define PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC
262 #define PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE
263 #define PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS
264 #define PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS
265 #define PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT
266 #define PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE
267 #define PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS
268 #define PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE
269 #define PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE
270 #define PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT
271 #define PA_STREAM_START_MUTED PA_STREAM_START_MUTED
272 #define PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY
273 #define PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS
274 #define PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
275 #define PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED
276 #define PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND
277
278 /** \endcond */
279
280 /** Playback and record buffer metrics */
281 typedef struct pa_buffer_attr {
282 uint32_t maxlength;
283 /**< Maximum length of the buffer. Setting this to (uint32_t) -1
284 * will initialize this to the maximum value supported by server,
285 * which is recommended. */
286
287 uint32_t tlength;
288 /**< Playback only: target length of the buffer. The server tries
289 * to assure that at least tlength bytes are always available in
290 * the per-stream server-side playback buffer. It is recommended
291 * to set this to (uint32_t) -1, which will initialize this to a
292 * value that is deemed sensible by the server. However, this
293 * value will default to something like 2s, i.e. for applications
294 * that have specific latency requirements this value should be
295 * set to the maximum latency that the application can deal
296 * with. When PA_STREAM_ADJUST_LATENCY is not set this value will
297 * influence only the per-stream playback buffer size. When
298 * PA_STREAM_ADJUST_LATENCY is set the overall latency of the sink
299 * plus the playback buffer size is configured to this value. Set
300 * PA_STREAM_ADJUST_LATENCY if you are interested in adjusting the
301 * overall latency. Don't set it if you are interested in
302 * configuring the server-sider per-stream playback buffer
303 * size. */
304
305 uint32_t prebuf;
306 /**< Playback only: pre-buffering. The server does not start with
307 * playback before at least prebug bytes are available in the
308 * buffer. It is recommended to set this to (uint32_t) -1, which
309 * will initialize this to the same value as tlength, whatever
310 * that may be. Initialize to 0 to enable manual start/stop
311 * control of the stream. This means that playback will not stop
312 * on underrun and playback will not start automatically. Instead
313 * pa_stream_corked() needs to be called explicitly. If you set
314 * this value to 0 you should also set PA_STREAM_START_CORKED. */
315
316 uint32_t minreq;
317 /**< Playback only: minimum request. The server does not request
318 * less than minreq bytes from the client, instead waits until the
319 * buffer is free enough to request more bytes at once. It is
320 * recommended to set this to (uint32_t) -1, which will initialize
321 * this to a value that is deemed sensible by the server. This
322 * should be set to a value that gives PulseAudio enough time to
323 * move the data from the per-stream playback buffer into the
324 * hardware playback buffer. */
325
326 uint32_t fragsize;
327 /**< Recording only: fragment size. The server sends data in
328 * blocks of fragsize bytes size. Large values deminish
329 * interactivity with other operations on the connection context
330 * but decrease control overhead. It is recommended to set this to
331 * (uint32_t) -1, which will initialize this to a value that is
332 * deemed sensible by the server. However, this value will default
333 * to something like 2s, i.e. for applications that have specific
334 * latency requirements this value should be set to the maximum
335 * latency that the application can deal with. If
336 * PA_STREAM_ADJUST_LATENCY is set the overall source latency will
337 * be adjusted according to this value. If it is not set the
338 * source latency is left unmodified. */
339
340 } pa_buffer_attr;
341
342 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
343 enum {
344 PA_OK = 0, /**< No error */
345 PA_ERR_ACCESS, /**< Access failure */
346 PA_ERR_COMMAND, /**< Unknown command */
347 PA_ERR_INVALID, /**< Invalid argument */
348 PA_ERR_EXIST, /**< Entity exists */
349 PA_ERR_NOENTITY, /**< No such entity */
350 PA_ERR_CONNECTIONREFUSED, /**< Connection refused */
351 PA_ERR_PROTOCOL, /**< Protocol error */
352 PA_ERR_TIMEOUT, /**< Timeout */
353 PA_ERR_AUTHKEY, /**< No authorization key */
354 PA_ERR_INTERNAL, /**< Internal error */
355 PA_ERR_CONNECTIONTERMINATED, /**< Connection terminated */
356 PA_ERR_KILLED, /**< Entity killed */
357 PA_ERR_INVALIDSERVER, /**< Invalid server */
358 PA_ERR_MODINITFAILED, /**< Module initialization failed */
359 PA_ERR_BADSTATE, /**< Bad state */
360 PA_ERR_NODATA, /**< No data */
361 PA_ERR_VERSION, /**< Incompatible protocol version */
362 PA_ERR_TOOLARGE, /**< Data too large */
363 PA_ERR_NOTSUPPORTED, /**< Operation not supported \since 0.9.5 */
364 PA_ERR_UNKNOWN, /**< The error code was unknown to the client */
365 PA_ERR_NOEXTENSION, /**< Extension does not exist. \since 0.9.12 */
366 PA_ERR_OBSOLETE, /**< Obsolete functionality. \since 0.9.15 */
367 PA_ERR_NOTIMPLEMENTED, /**< Missing implementation. \since 0.9.15 */
368 PA_ERR_MAX /**< Not really an error but the first invalid error code */
369 };
370
371 /** \cond fulldocs */
372 #define PA_OK PA_OK
373 #define PA_ERR_ACCESS PA_ERR_ACCESS
374 #define PA_ERR_COMMAND PA_ERR_COMMAND
375 #define PA_ERR_INVALID PA_ERR_INVALID
376 #define PA_ERR_EXIST PA_ERR_EXIST
377 #define PA_ERR_NOENTITY PA_ERR_NOENTITY
378 #define PA_ERR_CONNECTIONREFUSED PA_ERR_CONNECTIONREFUSED
379 #define PA_ERR_PROTOCOL PA_ERR_PROTOCOL
380 #define PA_ERR_TIMEOUT PA_ERR_TIMEOUT
381 #define PA_ERR_AUTHKEY PA_ERR_AUTHKEY
382 #define PA_ERR_INTERNAL PA_ERR_INTERNAL
383 #define PA_ERR_CONNECTIONTERMINATED PA_ERR_CONNECTIONTERMINATED
384 #define PA_ERR_KILLED PA_ERR_KILLED
385 #define PA_ERR_INVALIDSERVER PA_ERR_INVALIDSERVER
386 #define PA_ERR_MODINITFAILED PA_ERR_MODINITFAILED
387 #define PA_ERR_BADSTATE PA_ERR_BADSTATE
388 #define PA_ERR_NODATA PA_ERR_NODATA
389 #define PA_ERR_VERSION PA_ERR_VERSION
390 #define PA_ERR_TOOLARGE PA_ERR_TOOLARGE
391 #define PA_ERR_NOTSUPPORTED PA_ERR_NOTSUPPORTED
392 #define PA_ERR_UNKNOWN PA_ERR_UNKNOWN
393 #define PA_ERR_NOEXTENSION PA_ERR_NOEXTENSION
394 #define PA_ERR_OBSOLETE PA_ERR_OBSOLETE
395 #define PA_ERR_NOTIMPLEMENTED PA_ERR_NOTIMPLEMENTED
396 #define PA_ERR_MAX PA_ERR_MAX
397 /** \endcond */
398
399 /** Subscription event mask, as used by pa_context_subscribe() */
400 typedef enum pa_subscription_mask {
401 PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
402 /**< No events */
403
404 PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
405 /**< Sink events */
406
407 PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
408 /**< Source events */
409
410 PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
411 /**< Sink input events */
412
413 PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
414 /**< Source output events */
415
416 PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
417 /**< Module events */
418
419 PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
420 /**< Client events */
421
422 PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
423 /**< Sample cache events */
424
425 PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
426 /**< Other global server changes. */
427
428 /** \cond fulldocs */
429 PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
430 /**< \deprecated Autoload table events. */
431 /** \endcond */
432
433 PA_SUBSCRIPTION_MASK_CARD = 0x0200U,
434 /**< Card events. \since 0.9.15 */
435
436 PA_SUBSCRIPTION_MASK_ALL = 0x02ffU
437 /**< Catch all events */
438 } pa_subscription_mask_t;
439
440 /** Subscription event types, as used by pa_context_subscribe() */
441 typedef enum pa_subscription_event_type {
442 PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
443 /**< Event type: Sink */
444
445 PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
446 /**< Event type: Source */
447
448 PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
449 /**< Event type: Sink input */
450
451 PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
452 /**< Event type: Source output */
453
454 PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
455 /**< Event type: Module */
456
457 PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
458 /**< Event type: Client */
459
460 PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
461 /**< Event type: Sample cache item */
462
463 PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
464 /**< Event type: Global server change, only occuring with PA_SUBSCRIPTION_EVENT_CHANGE. */
465
466 /** \cond fulldocs */
467 PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
468 /**< \deprecated Event type: Autoload table changes. */
469 /** \endcond */
470
471 PA_SUBSCRIPTION_EVENT_CARD = 0x0009U,
472 /**< Event type: Card \since 0.9.15 */
473
474 PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
475 /**< A mask to extract the event type from an event value */
476
477 PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
478 /**< A new object was created */
479
480 PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
481 /**< A property of the object was modified */
482
483 PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
484 /**< An object was removed */
485
486 PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
487 /**< A mask to extract the event operation from an event value */
488
489 } pa_subscription_event_type_t;
490
491 /** Return one if an event type t matches an event mask bitfield */
492 #define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
493
494 /** A structure for all kinds of timing information of a stream. See
495 * pa_stream_update_timing_info() and pa_stream_get_timing_info(). The
496 * total output latency a sample that is written with
497 * pa_stream_write() takes to be played may be estimated by
498 * sink_usec+buffer_usec+transport_usec. (where buffer_usec is defined
499 * as pa_bytes_to_usec(write_index-read_index)) The output buffer
500 * which buffer_usec relates to may be manipulated freely (with
501 * pa_stream_write()'s seek argument, pa_stream_flush() and friends),
502 * the buffers sink_usec and source_usec relate to are first-in
503 * first-out (FIFO) buffers which cannot be flushed or manipulated in
504 * any way. The total input latency a sample that is recorded takes to
505 * be delivered to the application is:
506 * source_usec+buffer_usec+transport_usec-sink_usec. (Take care of
507 * sign issues!) When connected to a monitor source sink_usec contains
508 * the latency of the owning sink. The two latency estimations
509 * described here are implemented in pa_stream_get_latency(). Please
510 * note that this structure can be extended as part of evolutionary
511 * API updates at any time in any new release.*/
512 typedef struct pa_timing_info {
513 struct timeval timestamp;
514 /**< The time when this timing info structure was current */
515
516 int synchronized_clocks;
517 /**< Non-zero if the local and the remote machine have
518 * synchronized clocks. If synchronized clocks are detected
519 * transport_usec becomes much more reliable. However, the code
520 * that detects synchronized clocks is very limited und unreliable
521 * itself. */
522
523 pa_usec_t sink_usec;
524 /**< Time in usecs a sample takes to be played on the sink. For
525 * playback streams and record streams connected to a monitor
526 * source. */
527
528 pa_usec_t source_usec;
529 /**< Time in usecs a sample takes from being recorded to being
530 * delivered to the application. Only for record streams. */
531
532 pa_usec_t transport_usec;
533 /**< Estimated time in usecs a sample takes to be transferred
534 * to/from the daemon. For both playback and record streams. */
535
536 int playing;
537 /**< Non-zero when the stream is currently not underrun and data
538 * is being passed on to the device. Only for playback
539 * streams. This field does not say whether the data is actually
540 * already being played. To determine this check whether
541 * since_underrun (converted to usec) is larger than sink_usec.*/
542
543 int write_index_corrupt;
544 /**< Non-zero if write_index is not up-to-date because a local
545 * write command that corrupted it has been issued in the time
546 * since this latency info was current . Only write commands with
547 * SEEK_RELATIVE_ON_READ and SEEK_RELATIVE_END can corrupt
548 * write_index. */
549
550 int64_t write_index;
551 /**< Current write index into the playback buffer in bytes. Think
552 * twice before using this for seeking purposes: it might be out
553 * of date a the time you want to use it. Consider using
554 * PA_SEEK_RELATIVE instead. */
555
556 int read_index_corrupt;
557 /**< Non-zero if read_index is not up-to-date because a local
558 * pause or flush request that corrupted it has been issued in the
559 * time since this latency info was current. */
560
561 int64_t read_index;
562 /**< Current read index into the playback buffer in bytes. Think
563 * twice before using this for seeking purposes: it might be out
564 * of date a the time you want to use it. Consider using
565 * PA_SEEK_RELATIVE_ON_READ instead. */
566
567 pa_usec_t configured_sink_usec;
568 /**< The configured latency for the sink. \since 0.9.11 */
569
570 pa_usec_t configured_source_usec;
571 /**< The configured latency for * the source. \since 0.9.11 */
572
573 int64_t since_underrun;
574 /**< Bytes that were handed to the sink since the last underrun
575 * happened, or since playback started again after the last
576 * underrun. playing will tell you which case it is. \since
577 * 0.9.11 */
578
579 } pa_timing_info;
580
581 /** A structure for the spawn api. This may be used to integrate auto
582 * spawned daemons into your application. For more information see
583 * pa_context_connect(). When spawning a new child process the
584 * waitpid() is used on the child's PID. The spawn routine will not
585 * block or ignore SIGCHLD signals, since this cannot be done in a
586 * thread compatible way. You might have to do this in
587 * prefork/postfork. */
588 typedef struct pa_spawn_api {
589 void (*prefork)(void);
590 /**< Is called just before the fork in the parent process. May be
591 * NULL. */
592
593 void (*postfork)(void);
594 /**< Is called immediately after the fork in the parent
595 * process. May be NULL.*/
596
597 void (*atfork)(void);
598 /**< Is called immediately after the fork in the child
599 * process. May be NULL. It is not safe to close all file
600 * descriptors in this function unconditionally, since a UNIX
601 * socket (created using socketpair()) is passed to the new
602 * process. */
603 } pa_spawn_api;
604
605 /** Seek type for pa_stream_write(). */
606 typedef enum pa_seek_mode {
607 PA_SEEK_RELATIVE = 0,
608 /**< Seek relatively to the write index */
609
610 PA_SEEK_ABSOLUTE = 1,
611 /**< Seek relatively to the start of the buffer queue */
612
613 PA_SEEK_RELATIVE_ON_READ = 2,
614 /**< Seek relatively to the read index. */
615
616 PA_SEEK_RELATIVE_END = 3
617 /**< Seek relatively to the current end of the buffer queue. */
618 } pa_seek_mode_t;
619
620 /** Special sink flags. */
621 typedef enum pa_sink_flags {
622 PA_SINK_HW_VOLUME_CTRL = 0x0001U,
623 /**< Supports hardware volume control */
624
625 PA_SINK_LATENCY = 0x0002U,
626 /**< Supports latency querying */
627
628 PA_SINK_HARDWARE = 0x0004U,
629 /**< Is a hardware sink of some kind, in contrast to
630 * "virtual"/software sinks \since 0.9.3 */
631
632 PA_SINK_NETWORK = 0x0008U,
633 /**< Is a networked sink of some kind. \since 0.9.7 */
634
635 PA_SINK_HW_MUTE_CTRL = 0x0010U,
636 /**< Supports hardware mute control \since 0.9.11 */
637
638 PA_SINK_DECIBEL_VOLUME = 0x0020U,
639 /**< Volume can be translated to dB with pa_sw_volume_to_dB()
640 * \since 0.9.11 */
641
642 PA_SINK_FLAT_VOLUME = 0x0040U
643 /**< This sink is in flat volume mode, i.e. always the maximum of
644 * the volume of all connected inputs. \since 0.9.15 */
645 } pa_sink_flags_t;
646
647 /** \cond fulldocs */
648 #define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
649 #define PA_SINK_LATENCY PA_SINK_LATENCY
650 #define PA_SINK_HARDWARE PA_SINK_HARDWARE
651 #define PA_SINK_NETWORK PA_SINK_NETWORK
652 #define PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL
653 #define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
654 #define PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME
655 /** \endcond */
656
657 /** Sink state. \since 0.9.15 */
658 typedef enum pa_sink_state { /* enum serialized in u8 */
659 PA_SINK_INVALID_STATE = -1,
660 /**< This state is used when the server does not support sink state introspection \since 0.9.15 */
661
662 PA_SINK_RUNNING = 0,
663 /**< Running, sink is playing and used by at least one non-corked sink-input \since 0.9.15 */
664
665 PA_SINK_IDLE = 1,
666 /**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
667
668 PA_SINK_SUSPENDED = 2,
669 /**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
670
671 /** \cond fulldocs */
672 /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
673 * SIDE! These values are *not* considered part of the official PA
674 * API/ABI. If you use them your application might break when PA
675 * is upgraded. Also, please note that these values are not useful
676 * on the client side anyway. */
677
678 PA_SINK_INIT = -2,
679 /**< Initialization state */
680
681 PA_SINK_UNLINKED = -3
682 /**< The state when the sink is getting unregistered and removed from client access */
683 /** \endcond */
684
685 } pa_sink_state_t;
686
687 /** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
688 static inline int PA_SINK_IS_OPENED(pa_sink_state_t x) {
689 return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
690 }
691
692 /** \cond fulldocs */
693 #define PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE
694 #define PA_SINK_RUNNING PA_SINK_RUNNING
695 #define PA_SINK_IDLE PA_SINK_IDLE
696 #define PA_SINK_SUSPENDED PA_SINK_SUSPENDED
697 #define PA_SINK_IS_OPENED PA_SINK_IS_OPENED
698 /** \endcond */
699
700 /** Special source flags. */
701 typedef enum pa_source_flags {
702 PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
703 /**< Supports hardware volume control */
704
705 PA_SOURCE_LATENCY = 0x0002U,
706 /**< Supports latency querying */
707
708 PA_SOURCE_HARDWARE = 0x0004U,
709 /**< Is a hardware source of some kind, in contrast to
710 * "virtual"/software source \since 0.9.3 */
711
712 PA_SOURCE_NETWORK = 0x0008U,
713 /**< Is a networked source of some kind. \since 0.9.7 */
714
715 PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
716 /**< Supports hardware mute control \since 0.9.11 */
717
718 PA_SOURCE_DECIBEL_VOLUME = 0x0020U
719 /**< Volume can be translated to dB with pa_sw_volume_to_dB()
720 * \since 0.9.11 */
721 } pa_source_flags_t;
722
723 /** \cond fulldocs */
724 #define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
725 #define PA_SOURCE_LATENCY PA_SOURCE_LATENCY
726 #define PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE
727 #define PA_SOURCE_NETWORK PA_SOURCE_NETWORK
728 #define PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL
729 #define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
730 /** \endcond */
731
732 /** Source state. \since 0.9.15 */
733 typedef enum pa_source_state {
734 PA_SOURCE_INVALID_STATE = -1,
735 /**< This state is used when the server does not support source state introspection \since 0.9.15 */
736
737 PA_SOURCE_RUNNING = 0,
738 /**< Running, source is recording and used by at least one non-corked source-output \since 0.9.15 */
739
740 PA_SOURCE_IDLE = 1,
741 /**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
742
743 PA_SOURCE_SUSPENDED = 2,
744 /**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
745
746 /** \cond fulldocs */
747 /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
748 * SIDE! These values are *not* considered part of the official PA
749 * API/ABI. If you use them your application might break when PA
750 * is upgraded. Also, please note that these values are not useful
751 * on the client side anyway. */
752
753 PA_SOURCE_INIT = -2,
754 /**< Initialization state */
755
756 PA_SOURCE_UNLINKED = -3
757 /**< The state when the source is getting unregistered and removed from client access */
758 /** \endcond */
759
760 } pa_source_state_t;
761
762 /** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
763 static inline int PA_SOURCE_IS_OPENED(pa_source_state_t x) {
764 return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
765 }
766
767 /** \cond fulldocs */
768 #define PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE
769 #define PA_SOURCE_RUNNING PA_SOURCE_RUNNING
770 #define PA_SOURCE_IDLE PA_SOURCE_IDLE
771 #define PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED
772 #define PA_SOURCE_IS_OPENED PA_SOURCE_IS_OPENED
773 /** \endcond */
774
775 /** A generic free() like callback prototype */
776 typedef void (*pa_free_cb_t)(void *p);
777
778 PA_C_DECL_END
779
780 #endif