]> code.delx.au - pulseaudio/blob - src/pulse/def.h
add new error code PA_ERR_NOTIMPLEMENTED
[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 /** Subscription event mask, as used by pa_context_subscribe() */
372 typedef enum pa_subscription_mask {
373 PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
374 /**< No events */
375
376 PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
377 /**< Sink events */
378
379 PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
380 /**< Source events */
381
382 PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
383 /**< Sink input events */
384
385 PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
386 /**< Source output events */
387
388 PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
389 /**< Module events */
390
391 PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
392 /**< Client events */
393
394 PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
395 /**< Sample cache events */
396
397 PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
398 /**< Other global server changes. */
399
400 /** \cond fulldocs */
401 PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
402 /**< \deprecated Autoload table events. */
403 /** \endcond */
404
405 PA_SUBSCRIPTION_MASK_CARD = 0x0200U,
406 /**< Card events. \since 0.9.15 */
407
408 PA_SUBSCRIPTION_MASK_ALL = 0x02ffU
409 /**< Catch all events */
410 } pa_subscription_mask_t;
411
412 /** Subscription event types, as used by pa_context_subscribe() */
413 typedef enum pa_subscription_event_type {
414 PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
415 /**< Event type: Sink */
416
417 PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
418 /**< Event type: Source */
419
420 PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
421 /**< Event type: Sink input */
422
423 PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
424 /**< Event type: Source output */
425
426 PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
427 /**< Event type: Module */
428
429 PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
430 /**< Event type: Client */
431
432 PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
433 /**< Event type: Sample cache item */
434
435 PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
436 /**< Event type: Global server change, only occuring with PA_SUBSCRIPTION_EVENT_CHANGE. */
437
438 /** \cond fulldocs */
439 PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
440 /**< \deprecated Event type: Autoload table changes. */
441 /** \endcond */
442
443 PA_SUBSCRIPTION_EVENT_CARD = 0x0009U,
444 /**< Event type: Card \since 0.9.15 */
445
446 PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
447 /**< A mask to extract the event type from an event value */
448
449 PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
450 /**< A new object was created */
451
452 PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
453 /**< A property of the object was modified */
454
455 PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
456 /**< An object was removed */
457
458 PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
459 /**< A mask to extract the event operation from an event value */
460
461 } pa_subscription_event_type_t;
462
463 /** Return one if an event type t matches an event mask bitfield */
464 #define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
465
466 /** A structure for all kinds of timing information of a stream. See
467 * pa_stream_update_timing_info() and pa_stream_get_timing_info(). The
468 * total output latency a sample that is written with
469 * pa_stream_write() takes to be played may be estimated by
470 * sink_usec+buffer_usec+transport_usec. (where buffer_usec is defined
471 * as pa_bytes_to_usec(write_index-read_index)) The output buffer
472 * which buffer_usec relates to may be manipulated freely (with
473 * pa_stream_write()'s seek argument, pa_stream_flush() and friends),
474 * the buffers sink_usec and source_usec relate to are first-in
475 * first-out (FIFO) buffers which cannot be flushed or manipulated in
476 * any way. The total input latency a sample that is recorded takes to
477 * be delivered to the application is:
478 * source_usec+buffer_usec+transport_usec-sink_usec. (Take care of
479 * sign issues!) When connected to a monitor source sink_usec contains
480 * the latency of the owning sink. The two latency estimations
481 * described here are implemented in pa_stream_get_latency(). Please
482 * note that this structure can be extended as part of evolutionary
483 * API updates at any time in any new release.*/
484 typedef struct pa_timing_info {
485 struct timeval timestamp;
486 /**< The time when this timing info structure was current */
487
488 int synchronized_clocks;
489 /**< Non-zero if the local and the remote machine have
490 * synchronized clocks. If synchronized clocks are detected
491 * transport_usec becomes much more reliable. However, the code
492 * that detects synchronized clocks is very limited und unreliable
493 * itself. */
494
495 pa_usec_t sink_usec;
496 /**< Time in usecs a sample takes to be played on the sink. For
497 * playback streams and record streams connected to a monitor
498 * source. */
499
500 pa_usec_t source_usec;
501 /**< Time in usecs a sample takes from being recorded to being
502 * delivered to the application. Only for record streams. */
503
504 pa_usec_t transport_usec;
505 /**< Estimated time in usecs a sample takes to be transferred
506 * to/from the daemon. For both playback and record streams. */
507
508 int playing;
509 /**< Non-zero when the stream is currently not underrun and data
510 * is being passed on to the device. Only for playback
511 * streams. This field does not say whether the data is actually
512 * already being played. To determine this check whether
513 * since_underrun (converted to usec) is larger than sink_usec.*/
514
515 int write_index_corrupt;
516 /**< Non-zero if write_index is not up-to-date because a local
517 * write command that corrupted it has been issued in the time
518 * since this latency info was current . Only write commands with
519 * SEEK_RELATIVE_ON_READ and SEEK_RELATIVE_END can corrupt
520 * write_index. */
521
522 int64_t write_index;
523 /**< Current write index into the playback buffer in bytes. Think
524 * twice before using this for seeking purposes: it might be out
525 * of date a the time you want to use it. Consider using
526 * PA_SEEK_RELATIVE instead. */
527
528 int read_index_corrupt;
529 /**< Non-zero if read_index is not up-to-date because a local
530 * pause or flush request that corrupted it has been issued in the
531 * time since this latency info was current. */
532
533 int64_t read_index;
534 /**< Current read index into the playback buffer in bytes. Think
535 * twice before using this for seeking purposes: it might be out
536 * of date a the time you want to use it. Consider using
537 * PA_SEEK_RELATIVE_ON_READ instead. */
538
539 pa_usec_t configured_sink_usec;
540 /**< The configured latency for the sink. \since 0.9.11 */
541
542 pa_usec_t configured_source_usec;
543 /**< The configured latency for * the source. \since 0.9.11 */
544
545 int64_t since_underrun;
546 /**< Bytes that were handed to the sink since the last underrun
547 * happened, or since playback started again after the last
548 * underrun. playing will tell you which case it is. \since
549 * 0.9.11 */
550
551 } pa_timing_info;
552
553 /** A structure for the spawn api. This may be used to integrate auto
554 * spawned daemons into your application. For more information see
555 * pa_context_connect(). When spawning a new child process the
556 * waitpid() is used on the child's PID. The spawn routine will not
557 * block or ignore SIGCHLD signals, since this cannot be done in a
558 * thread compatible way. You might have to do this in
559 * prefork/postfork. */
560 typedef struct pa_spawn_api {
561 void (*prefork)(void);
562 /**< Is called just before the fork in the parent process. May be
563 * NULL. */
564
565 void (*postfork)(void);
566 /**< Is called immediately after the fork in the parent
567 * process. May be NULL.*/
568
569 void (*atfork)(void);
570 /**< Is called immediately after the fork in the child
571 * process. May be NULL. It is not safe to close all file
572 * descriptors in this function unconditionally, since a UNIX
573 * socket (created using socketpair()) is passed to the new
574 * process. */
575 } pa_spawn_api;
576
577 /** Seek type for pa_stream_write(). */
578 typedef enum pa_seek_mode {
579 PA_SEEK_RELATIVE = 0,
580 /**< Seek relatively to the write index */
581
582 PA_SEEK_ABSOLUTE = 1,
583 /**< Seek relatively to the start of the buffer queue */
584
585 PA_SEEK_RELATIVE_ON_READ = 2,
586 /**< Seek relatively to the read index. */
587
588 PA_SEEK_RELATIVE_END = 3
589 /**< Seek relatively to the current end of the buffer queue. */
590 } pa_seek_mode_t;
591
592 /** Special sink flags. */
593 typedef enum pa_sink_flags {
594 PA_SINK_HW_VOLUME_CTRL = 0x0001U,
595 /**< Supports hardware volume control */
596
597 PA_SINK_LATENCY = 0x0002U,
598 /**< Supports latency querying */
599
600 PA_SINK_HARDWARE = 0x0004U,
601 /**< Is a hardware sink of some kind, in contrast to
602 * "virtual"/software sinks \since 0.9.3 */
603
604 PA_SINK_NETWORK = 0x0008U,
605 /**< Is a networked sink of some kind. \since 0.9.7 */
606
607 PA_SINK_HW_MUTE_CTRL = 0x0010U,
608 /**< Supports hardware mute control \since 0.9.11 */
609
610 PA_SINK_DECIBEL_VOLUME = 0x0020U,
611 /**< Volume can be translated to dB with pa_sw_volume_to_dB()
612 * \since 0.9.11 */
613
614 PA_SINK_FLAT_VOLUME = 0x0040U
615 /**< This sink is in flat volume mode, i.e. always the maximum of
616 * the volume of all connected inputs. \since 0.9.15 */
617 } pa_sink_flags_t;
618
619 /** \cond fulldocs */
620 #define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
621 #define PA_SINK_LATENCY PA_SINK_LATENCY
622 #define PA_SINK_HARDWARE PA_SINK_HARDWARE
623 #define PA_SINK_NETWORK PA_SINK_NETWORK
624 #define PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL
625 #define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
626 #define PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME
627 /** \endcond */
628
629 /** Sink state. \since 0.9.15 */
630 typedef enum pa_sink_state { /* enum serialized in u8 */
631 PA_SINK_INVALID_STATE = -1,
632 /**< This state is used when the server does not support sink state introspection \since 0.9.15 */
633
634 PA_SINK_RUNNING = 0,
635 /**< Running, sink is playing and used by at least one non-corked sink-input \since 0.9.15 */
636
637 PA_SINK_IDLE = 1,
638 /**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
639
640 PA_SINK_SUSPENDED = 2,
641 /**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
642
643 /** \cond fulldocs */
644 /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
645 * SIDE! These values are *not* considered part of the official PA
646 * API/ABI. If you use them your application might break when PA
647 * is upgraded. Also, please note that these values are not useful
648 * on the client side anyway. */
649
650 PA_SINK_INIT = -2,
651 /**< Initialization state */
652
653 PA_SINK_UNLINKED = -3
654 /**< The state when the sink is getting unregistered and removed from client access */
655 /** \endcond */
656
657 } pa_sink_state_t;
658
659 /** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
660 static inline int PA_SINK_IS_OPENED(pa_sink_state_t x) {
661 return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
662 }
663
664 /** \cond fulldocs */
665 #define PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE
666 #define PA_SINK_RUNNING PA_SINK_RUNNING
667 #define PA_SINK_IDLE PA_SINK_IDLE
668 #define PA_SINK_SUSPENDED PA_SINK_SUSPENDED
669 #define PA_SINK_IS_OPENED PA_SINK_IS_OPENED
670 /** \endcond */
671
672 /** Special source flags. */
673 typedef enum pa_source_flags {
674 PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
675 /**< Supports hardware volume control */
676
677 PA_SOURCE_LATENCY = 0x0002U,
678 /**< Supports latency querying */
679
680 PA_SOURCE_HARDWARE = 0x0004U,
681 /**< Is a hardware source of some kind, in contrast to
682 * "virtual"/software source \since 0.9.3 */
683
684 PA_SOURCE_NETWORK = 0x0008U,
685 /**< Is a networked source of some kind. \since 0.9.7 */
686
687 PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
688 /**< Supports hardware mute control \since 0.9.11 */
689
690 PA_SOURCE_DECIBEL_VOLUME = 0x0020U
691 /**< Volume can be translated to dB with pa_sw_volume_to_dB()
692 * \since 0.9.11 */
693 } pa_source_flags_t;
694
695 /** \cond fulldocs */
696 #define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
697 #define PA_SOURCE_LATENCY PA_SOURCE_LATENCY
698 #define PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE
699 #define PA_SOURCE_NETWORK PA_SOURCE_NETWORK
700 #define PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL
701 #define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
702 /** \endcond */
703
704 /** Source state. \since 0.9.15 */
705 typedef enum pa_source_state {
706 PA_SOURCE_INVALID_STATE = -1,
707 /**< This state is used when the server does not support source state introspection \since 0.9.15 */
708
709 PA_SOURCE_RUNNING = 0,
710 /**< Running, source is recording and used by at least one non-corked source-output \since 0.9.15 */
711
712 PA_SOURCE_IDLE = 1,
713 /**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
714
715 PA_SOURCE_SUSPENDED = 2,
716 /**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
717
718 /** \cond fulldocs */
719 /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
720 * SIDE! These values are *not* considered part of the official PA
721 * API/ABI. If you use them your application might break when PA
722 * is upgraded. Also, please note that these values are not useful
723 * on the client side anyway. */
724
725 PA_SOURCE_INIT = -2,
726 /**< Initialization state */
727
728 PA_SOURCE_UNLINKED = -3
729 /**< The state when the source is getting unregistered and removed from client access */
730 /** \endcond */
731
732 } pa_source_state_t;
733
734 /** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
735 static inline int PA_SOURCE_IS_OPENED(pa_source_state_t x) {
736 return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
737 }
738
739 /** \cond fulldocs */
740 #define PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE
741 #define PA_SOURCE_RUNNING PA_SOURCE_RUNNING
742 #define PA_SOURCE_IDLE PA_SOURCE_IDLE
743 #define PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED
744 #define PA_SOURCE_IS_OPENED PA_SOURCE_IS_OPENED
745 /** \endcond */
746
747 /** A generic free() like callback prototype */
748 typedef void (*pa_free_cb_t)(void *p);
749
750 PA_C_DECL_END
751
752 #endif