• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, see <http://www.gnu.org/licenses/>.
22 ***/
23 
24 #include <inttypes.h>
25 #include <sys/time.h>
26 
27 #include <pulse/cdecl.h>
28 #include <pulse/sample.h>
29 #include <pulse/version.h>
30 
31 /** \file
32  * Global definitions */
33 
34 PA_C_DECL_BEGIN
35 
36 /** The state of a connection context */
37 typedef enum pa_context_state {
38     PA_CONTEXT_UNCONNECTED,    /**< The context hasn't been connected yet */
39     PA_CONTEXT_CONNECTING,     /**< A connection is being established */
40     PA_CONTEXT_AUTHORIZING,    /**< The client is authorizing itself to the daemon */
41     PA_CONTEXT_SETTING_NAME,   /**< The client is passing its application name to the daemon */
42     PA_CONTEXT_READY,          /**< The connection is established, the context is ready to execute operations */
43     PA_CONTEXT_FAILED,         /**< The connection failed or was disconnected */
44     PA_CONTEXT_TERMINATED      /**< The connection was terminated cleanly */
45 } pa_context_state_t;
46 
47 /** Return non-zero if the passed state is one of the connected states. \since 0.9.11 */
PA_CONTEXT_IS_GOOD(pa_context_state_t x)48 static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
49     return
50         x == PA_CONTEXT_CONNECTING ||
51         x == PA_CONTEXT_AUTHORIZING ||
52         x == PA_CONTEXT_SETTING_NAME ||
53         x == PA_CONTEXT_READY;
54 }
55 
56 /** \cond fulldocs */
57 #define PA_CONTEXT_UNCONNECTED PA_CONTEXT_UNCONNECTED
58 #define PA_CONTEXT_CONNECTING PA_CONTEXT_CONNECTING
59 #define PA_CONTEXT_AUTHORIZING PA_CONTEXT_AUTHORIZING
60 #define PA_CONTEXT_SETTING_NAME PA_CONTEXT_SETTING_NAME
61 #define PA_CONTEXT_READY PA_CONTEXT_READY
62 #define PA_CONTEXT_FAILED PA_CONTEXT_FAILED
63 #define PA_CONTEXT_TERMINATED PA_CONTEXT_TERMINATED
64 #define PA_CONTEXT_IS_GOOD PA_CONTEXT_IS_GOOD
65 /** \endcond */
66 
67 /** The state of a stream */
68 typedef enum pa_stream_state {
69     PA_STREAM_UNCONNECTED,  /**< The stream is not yet connected to any sink or source */
70     PA_STREAM_CREATING,     /**< The stream is being created */
71     PA_STREAM_READY,        /**< The stream is established, you may pass audio data to it now */
72     PA_STREAM_FAILED,       /**< An error occurred that made the stream invalid */
73     PA_STREAM_TERMINATED    /**< The stream has been terminated cleanly */
74 } pa_stream_state_t;
75 
76 /** Return non-zero if the passed state is one of the connected states. \since 0.9.11 */
PA_STREAM_IS_GOOD(pa_stream_state_t x)77 static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
78     return
79         x == PA_STREAM_CREATING ||
80         x == PA_STREAM_READY;
81 }
82 
83 /** \cond fulldocs */
84 #define PA_STREAM_UNCONNECTED PA_STREAM_UNCONNECTED
85 #define PA_STREAM_CREATING PA_STREAM_CREATING
86 #define PA_STREAM_READY PA_STREAM_READY
87 #define PA_STREAM_FAILED PA_STREAM_FAILED
88 #define PA_STREAM_TERMINATED PA_STREAM_TERMINATED
89 #define PA_STREAM_IS_GOOD PA_STREAM_IS_GOOD
90 /** \endcond */
91 
92 /** The state of an operation */
93 typedef enum pa_operation_state {
94     PA_OPERATION_RUNNING,
95     /**< The operation is still running */
96     PA_OPERATION_DONE,
97     /**< The operation has completed */
98     PA_OPERATION_CANCELLED
99     /**< The operation has been cancelled. Operations may get cancelled by the
100      * application, or as a result of the context getting disconnected while the
101      * operation is pending. */
102 } pa_operation_state_t;
103 
104 /** \cond fulldocs */
105 #define PA_OPERATION_RUNNING PA_OPERATION_RUNNING
106 #define PA_OPERATION_DONE PA_OPERATION_DONE
107 #define PA_OPERATION_CANCELED PA_OPERATION_CANCELLED
108 #define PA_OPERATION_CANCELLED PA_OPERATION_CANCELLED
109 /** \endcond */
110 
111 /** An invalid index */
112 #define PA_INVALID_INDEX ((uint32_t) -1)
113 
114 /** Some special flags for contexts. */
115 typedef enum pa_context_flags {
116     PA_CONTEXT_NOFLAGS = 0x0000U,
117     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
118     PA_CONTEXT_NOAUTOSPAWN = 0x0001U,
119     /**< Disabled autospawning of the PulseAudio daemon if required */
120     PA_CONTEXT_NOFAIL = 0x0002U
121     /**< Don't fail if the daemon is not available when pa_context_connect() is
122      * called, instead enter PA_CONTEXT_CONNECTING state and wait for the daemon
123      * to appear.  \since 0.9.15 */
124 } pa_context_flags_t;
125 
126 /** \cond fulldocs */
127 /* Allow clients to check with #ifdef for those flags */
128 #define PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN
129 #define PA_CONTEXT_NOFAIL PA_CONTEXT_NOFAIL
130 /** \endcond */
131 
132 /** Direction bitfield - while we currently do not expose anything bidirectional,
133   one should test against the bit instead of the value (e.g.\ if (d & PA_DIRECTION_OUTPUT)),
134   because we might add bidirectional stuff in the future. \since 2.0
135 */
136 typedef enum pa_direction {
137     PA_DIRECTION_OUTPUT = 0x0001U,  /**< Output direction */
138     PA_DIRECTION_INPUT = 0x0002U    /**< Input direction */
139 } pa_direction_t;
140 
141 /** \cond fulldocs */
142 #define PA_DIRECTION_OUTPUT PA_DIRECTION_OUTPUT
143 #define PA_DIRECTION_INPUT PA_DIRECTION_INPUT
144 /** \endcond */
145 
146 /** The type of device we are dealing with */
147 typedef enum pa_device_type {
148     PA_DEVICE_TYPE_SINK,     /**< Playback device */
149     PA_DEVICE_TYPE_SOURCE    /**< Recording device */
150 } pa_device_type_t;
151 
152 /** \cond fulldocs */
153 #define PA_DEVICE_TYPE_SINK PA_DEVICE_TYPE_SINK
154 #define PA_DEVICE_TYPE_SOURCE PA_DEVICE_TYPE_SOURCE
155 /** \endcond */
156 
157 /** The direction of a pa_stream object */
158 typedef enum pa_stream_direction {
159     PA_STREAM_NODIRECTION,   /**< Invalid direction */
160     PA_STREAM_PLAYBACK,      /**< Playback stream */
161     PA_STREAM_RECORD,        /**< Record stream */
162     PA_STREAM_UPLOAD         /**< Sample upload stream */
163 } pa_stream_direction_t;
164 
165 /** \cond fulldocs */
166 #define PA_STREAM_NODIRECTION PA_STREAM_NODIRECTION
167 #define PA_STREAM_PLAYBACK PA_STREAM_PLAYBACK
168 #define PA_STREAM_RECORD PA_STREAM_RECORD
169 #define PA_STREAM_UPLOAD PA_STREAM_UPLOAD
170 /** \endcond */
171 
172 /** Some special flags for stream connections. */
173 typedef enum pa_stream_flags {
174 
175     PA_STREAM_NOFLAGS = 0x0000U,
176     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
177 
178     PA_STREAM_START_CORKED = 0x0001U,
179     /**< Create the stream corked, requiring an explicit
180      * pa_stream_cork() call to uncork it. */
181 
182     PA_STREAM_INTERPOLATE_TIMING = 0x0002U,
183     /**< Interpolate the latency for this stream. When enabled,
184      * pa_stream_get_latency() and pa_stream_get_time() will try to
185      * estimate the current record/playback time based on the local
186      * time that passed since the last timing info update.  Using this
187      * option has the advantage of not requiring a whole roundtrip
188      * when the current playback/recording time is needed. Consider
189      * using this option when requesting latency information
190      * frequently. This is especially useful on long latency network
191      * connections. It makes a lot of sense to combine this option
192      * with PA_STREAM_AUTO_TIMING_UPDATE. */
193 
194     PA_STREAM_NOT_MONOTONIC = 0x0004U,
195     /**< Don't force the time to increase monotonically. If this
196      * option is enabled, pa_stream_get_time() will not necessarily
197      * return always monotonically increasing time values on each
198      * call. This may confuse applications which cannot deal with time
199      * going 'backwards', but has the advantage that bad transport
200      * latency estimations that caused the time to jump ahead can
201      * be corrected quickly, without the need to wait. (Please note
202      * that this flag was named PA_STREAM_NOT_MONOTONOUS in releases
203      * prior to 0.9.11. The old name is still defined too, for
204      * compatibility reasons. */
205 
206     PA_STREAM_AUTO_TIMING_UPDATE = 0x0008U,
207     /**< If set timing update requests are issued periodically
208      * automatically. Combined with PA_STREAM_INTERPOLATE_TIMING you
209      * will be able to query the current time and latency with
210      * pa_stream_get_time() and pa_stream_get_latency() at all times
211      * without a packet round trip.*/
212 
213     PA_STREAM_NO_REMAP_CHANNELS = 0x0010U,
214     /**< Don't remap channels by their name, instead map them simply
215      * by their index. Implies PA_STREAM_NO_REMIX_CHANNELS. Only
216      * supported when the server is at least PA 0.9.8. It is ignored
217      * on older servers.\since 0.9.8 */
218 
219     PA_STREAM_NO_REMIX_CHANNELS = 0x0020U,
220     /**< When remapping channels by name, don't upmix or downmix them
221      * to related channels. Copy them into matching channels of the
222      * device 1:1. Only supported when the server is at least PA
223      * 0.9.8. It is ignored on older servers. \since 0.9.8 */
224 
225     PA_STREAM_FIX_FORMAT = 0x0040U,
226     /**< Use the sample format of the sink/device this stream is being
227      * connected to, and possibly ignore the format the sample spec
228      * contains -- but you still have to pass a valid value in it as a
229      * hint to PulseAudio what would suit your stream best. If this is
230      * used you should query the used sample format after creating the
231      * stream by using pa_stream_get_sample_spec(). Also, if you
232      * specified manual buffer metrics it is recommended to update
233      * them with pa_stream_set_buffer_attr() to compensate for the
234      * changed frame sizes. Only supported when the server is at least
235      * PA 0.9.8. It is ignored on older servers.
236      *
237      * When creating streams with pa_stream_new_extended(), this flag has no
238      * effect. If you specify a format with PCM encoding, and you want the
239      * server to choose the sample format, then you should leave the sample
240      * format unspecified in the pa_format_info object. This also means that
241      * you can't use pa_format_info_from_sample_spec(), because that function
242      * always sets the sample format.
243      *
244      * \since 0.9.8 */
245 
246     PA_STREAM_FIX_RATE = 0x0080U,
247     /**< Use the sample rate of the sink, and possibly ignore the rate
248      * the sample spec contains. Usage similar to
249      * PA_STREAM_FIX_FORMAT. Only supported when the server is at least
250      * PA 0.9.8. It is ignored on older servers.
251      *
252      * When creating streams with pa_stream_new_extended(), this flag has no
253      * effect. If you specify a format with PCM encoding, and you want the
254      * server to choose the sample rate, then you should leave the rate
255      * unspecified in the pa_format_info object. This also means that you can't
256      * use pa_format_info_from_sample_spec(), because that function always sets
257      * the sample rate.
258      *
259      * \since 0.9.8 */
260 
261     PA_STREAM_FIX_CHANNELS = 0x0100,
262     /**< Use the number of channels and the channel map of the sink,
263      * and possibly ignore the number of channels and the map the
264      * sample spec and the passed channel map contain. Usage similar
265      * to PA_STREAM_FIX_FORMAT. Only supported when the server is at
266      * least PA 0.9.8. It is ignored on older servers.
267      *
268      * When creating streams with pa_stream_new_extended(), this flag has no
269      * effect. If you specify a format with PCM encoding, and you want the
270      * server to choose the channel count and/or channel map, then you should
271      * leave the channels and/or the channel map unspecified in the
272      * pa_format_info object. This also means that you can't use
273      * pa_format_info_from_sample_spec(), because that function always sets
274      * the channel count (but if you only want to leave the channel map
275      * unspecified, then pa_format_info_from_sample_spec() works, because it
276      * accepts a NULL channel map).
277      *
278      * \since 0.9.8 */
279 
280     PA_STREAM_DONT_MOVE = 0x0200U,
281     /**< Don't allow moving of this stream to another
282      * sink/device. Useful if you use any of the PA_STREAM_FIX_ flags
283      * and want to make sure that resampling never takes place --
284      * which might happen if the stream is moved to another
285      * sink/source with a different sample spec/channel map. Only
286      * supported when the server is at least PA 0.9.8. It is ignored
287      * on older servers. \since 0.9.8 */
288 
289     PA_STREAM_VARIABLE_RATE = 0x0400U,
290     /**< Allow dynamic changing of the sampling rate during playback
291      * with pa_stream_update_sample_rate(). Only supported when the
292      * server is at least PA 0.9.8. It is ignored on older
293      * servers. \since 0.9.8 */
294 
295     PA_STREAM_PEAK_DETECT = 0x0800U,
296     /**< Find peaks instead of resampling. \since 0.9.11 */
297 
298     PA_STREAM_START_MUTED = 0x1000U,
299     /**< Create in muted state. If neither PA_STREAM_START_UNMUTED nor
300      * PA_STREAM_START_MUTED are set, it is left to the server to decide
301      * whether to create the stream in muted or in unmuted
302      * state. \since 0.9.11 */
303 
304     PA_STREAM_ADJUST_LATENCY = 0x2000U,
305     /**< Try to adjust the latency of the sink/source based on the
306      * requested buffer metrics and adjust buffer metrics
307      * accordingly. Also see pa_buffer_attr. This option may not be
308      * specified at the same time as PA_STREAM_EARLY_REQUESTS. \since
309      * 0.9.11 */
310 
311     PA_STREAM_EARLY_REQUESTS = 0x4000U,
312     /**< Enable compatibility mode for legacy clients that rely on a
313      * "classic" hardware device fragment-style playback model. If
314      * this option is set, the minreq value of the buffer metrics gets
315      * a new meaning: instead of just specifying that no requests
316      * asking for less new data than this value will be made to the
317      * client it will also guarantee that requests are generated as
318      * early as this limit is reached. This flag should only be set in
319      * very few situations where compatibility with a fragment-based
320      * playback model needs to be kept and the client applications
321      * cannot deal with data requests that are delayed to the latest
322      * moment possible. (Usually these are programs that use usleep()
323      * or a similar call in their playback loops instead of sleeping
324      * on the device itself.) Also see pa_buffer_attr. This option may
325      * not be specified at the same time as
326      * PA_STREAM_ADJUST_LATENCY. \since 0.9.12 */
327 
328     PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND = 0x8000U,
329     /**< If set this stream won't be taken into account when it is
330      * checked whether the device this stream is connected to should
331      * auto-suspend. \since 0.9.15 */
332 
333     PA_STREAM_START_UNMUTED = 0x10000U,
334     /**< Create in unmuted state. If neither PA_STREAM_START_UNMUTED
335      * nor PA_STREAM_START_MUTED are set it is left to the server to decide
336      * whether to create the stream in muted or in unmuted
337      * state. \since 0.9.15 */
338 
339     PA_STREAM_FAIL_ON_SUSPEND = 0x20000U,
340     /**< If the sink/source this stream is connected to is suspended
341      * during the creation of this stream, cause it to fail. If the
342      * sink/source is being suspended during creation of this stream,
343      * make sure this stream is terminated. \since 0.9.15 */
344 
345     PA_STREAM_RELATIVE_VOLUME = 0x40000U,
346     /**< If a volume is passed when this stream is created, consider
347      * it relative to the sink's current volume, never as absolute
348      * device volume. If this is not specified the volume will be
349      * consider absolute when the sink is in flat volume mode,
350      * relative otherwise. \since 0.9.20 */
351 
352     PA_STREAM_PASSTHROUGH = 0x80000U
353     /**< Used to tag content that will be rendered by passthrough sinks.
354      * The data will be left as is and not reformatted, resampled.
355      * \since 1.0 */
356 
357 } pa_stream_flags_t;
358 
359 /** \cond fulldocs */
360 
361 /* English is an evil language */
362 #define PA_STREAM_NOT_MONOTONOUS PA_STREAM_NOT_MONOTONIC
363 
364 /* Allow clients to check with #ifdef for those flags */
365 #define PA_STREAM_START_CORKED PA_STREAM_START_CORKED
366 #define PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING
367 #define PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC
368 #define PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE
369 #define PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS
370 #define PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS
371 #define PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT
372 #define PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE
373 #define PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS
374 #define PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE
375 #define PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE
376 #define PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT
377 #define PA_STREAM_START_MUTED PA_STREAM_START_MUTED
378 #define PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY
379 #define PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS
380 #define PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
381 #define PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED
382 #define PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND
383 #define PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME
384 #define PA_STREAM_PASSTHROUGH PA_STREAM_PASSTHROUGH
385 
386 /** \endcond */
387 
388 /** Playback and record buffer metrics */
389 typedef struct pa_buffer_attr {
390     uint32_t maxlength;
391     /**< Maximum length of the buffer in bytes. Setting this to (uint32_t) -1
392      * will initialize this to the maximum value supported by server,
393      * which is recommended.
394      *
395      * In strict low-latency playback scenarios you might want to set this to
396      * a lower value, likely together with the PA_STREAM_ADJUST_LATENCY flag.
397      * If you do so, you ensure that the latency doesn't grow beyond what is
398      * acceptable for the use case, at the cost of getting more underruns if
399      * the latency is lower than what the server can reliably handle. */
400 
401     uint32_t tlength;
402     /**< Playback only: target length of the buffer. The server tries
403      * to assure that at least tlength bytes are always available in
404      * the per-stream server-side playback buffer. The server will
405      * only send requests for more data as long as the buffer has
406      * less than this number of bytes of data.
407      *
408      * It is recommended to set this to (uint32_t) -1, which will
409      * initialize this to a value that is deemed sensible by the
410      * server. However, this value will default to something like 2s;
411      * for applications that have specific latency requirements
412      * this value should be set to the maximum latency that the
413      * application can deal with.
414      *
415      * When PA_STREAM_ADJUST_LATENCY is not set this value will
416      * influence only the per-stream playback buffer size. When
417      * PA_STREAM_ADJUST_LATENCY is set the overall latency of the sink
418      * plus the playback buffer size is configured to this value. Set
419      * PA_STREAM_ADJUST_LATENCY if you are interested in adjusting the
420      * overall latency. Don't set it if you are interested in
421      * configuring the server-side per-stream playback buffer
422      * size. */
423 
424     uint32_t prebuf;
425     /**< Playback only: pre-buffering. The server does not start with
426      * playback before at least prebuf bytes are available in the
427      * buffer. It is recommended to set this to (uint32_t) -1, which
428      * will initialize this to the same value as tlength, whatever
429      * that may be.
430      *
431      * Initialize to 0 to enable manual start/stop control of the stream.
432      * This means that playback will not stop on underrun and playback
433      * will not start automatically, instead pa_stream_cork() needs to
434      * be called explicitly. If you set this value to 0 you should also
435      * set PA_STREAM_START_CORKED. Should underrun occur, the read index
436      * of the output buffer overtakes the write index, and hence the
437      * fill level of the buffer is negative.
438      *
439      * Start of playback can be forced using pa_stream_trigger() even
440      * though the prebuffer size hasn't been reached. If a buffer
441      * underrun occurs, this prebuffering will be again enabled. */
442 
443     uint32_t minreq;
444     /**< Playback only: minimum request. The server does not request
445      * less than minreq bytes from the client, instead waits until the
446      * buffer is free enough to request more bytes at once. It is
447      * recommended to set this to (uint32_t) -1, which will initialize
448      * this to a value that is deemed sensible by the server. This
449      * should be set to a value that gives PulseAudio enough time to
450      * move the data from the per-stream playback buffer into the
451      * hardware playback buffer. */
452 
453     uint32_t fragsize;
454     /**< Recording only: fragment size. The server sends data in
455      * blocks of fragsize bytes size. Large values diminish
456      * interactivity with other operations on the connection context
457      * but decrease control overhead. It is recommended to set this to
458      * (uint32_t) -1, which will initialize this to a value that is
459      * deemed sensible by the server. However, this value will default
460      * to something like 2s; For applications that have specific
461      * latency requirements this value should be set to the maximum
462      * latency that the application can deal with.
463      *
464      * If PA_STREAM_ADJUST_LATENCY is set the overall source latency
465      * will be adjusted according to this value. If it is not set the
466      * source latency is left unmodified. */
467 
468 } pa_buffer_attr;
469 
470 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
471 typedef enum pa_error_code {
472     PA_OK = 0,                     /**< No error */
473     PA_ERR_ACCESS,                 /**< Access failure */
474     PA_ERR_COMMAND,                /**< Unknown command */
475     PA_ERR_INVALID,                /**< Invalid argument */
476     PA_ERR_EXIST,                  /**< Entity exists */
477     PA_ERR_NOENTITY,               /**< No such entity */
478     PA_ERR_CONNECTIONREFUSED,      /**< Connection refused */
479     PA_ERR_PROTOCOL,               /**< Protocol error */
480     PA_ERR_TIMEOUT,                /**< Timeout */
481     PA_ERR_AUTHKEY,                /**< No authentication key */
482     PA_ERR_INTERNAL,               /**< Internal error */
483     PA_ERR_CONNECTIONTERMINATED,   /**< Connection terminated */
484     PA_ERR_KILLED,                 /**< Entity killed */
485     PA_ERR_INVALIDSERVER,          /**< Invalid server */
486     PA_ERR_MODINITFAILED,          /**< Module initialization failed */
487     PA_ERR_BADSTATE,               /**< Bad state */
488     PA_ERR_NODATA,                 /**< No data */
489     PA_ERR_VERSION,                /**< Incompatible protocol version */
490     PA_ERR_TOOLARGE,               /**< Data too large */
491     PA_ERR_NOTSUPPORTED,           /**< Operation not supported \since 0.9.5 */
492     PA_ERR_UNKNOWN,                /**< The error code was unknown to the client */
493     PA_ERR_NOEXTENSION,            /**< Extension does not exist. \since 0.9.12 */
494     PA_ERR_OBSOLETE,               /**< Obsolete functionality. \since 0.9.15 */
495     PA_ERR_NOTIMPLEMENTED,         /**< Missing implementation. \since 0.9.15 */
496     PA_ERR_FORKED,                 /**< The caller forked without calling execve() and tried to reuse the context. \since 0.9.15 */
497     PA_ERR_IO,                     /**< An IO error happened. \since 0.9.16 */
498     PA_ERR_BUSY,                   /**< Device or resource busy. \since 0.9.17 */
499     PA_ERR_MAX                     /**< Not really an error but the first invalid error code */
500 } pa_error_code_t;
501 
502 /** \cond fulldocs */
503 #define PA_OK PA_OK
504 #define PA_ERR_ACCESS PA_ERR_ACCESS
505 #define PA_ERR_COMMAND PA_ERR_COMMAND
506 #define PA_ERR_INVALID PA_ERR_INVALID
507 #define PA_ERR_EXIST PA_ERR_EXIST
508 #define PA_ERR_NOENTITY PA_ERR_NOENTITY
509 #define PA_ERR_CONNECTIONREFUSED PA_ERR_CONNECTIONREFUSED
510 #define PA_ERR_PROTOCOL PA_ERR_PROTOCOL
511 #define PA_ERR_TIMEOUT PA_ERR_TIMEOUT
512 #define PA_ERR_AUTHKEY PA_ERR_AUTHKEY
513 #define PA_ERR_INTERNAL PA_ERR_INTERNAL
514 #define PA_ERR_CONNECTIONTERMINATED PA_ERR_CONNECTIONTERMINATED
515 #define PA_ERR_KILLED PA_ERR_KILLED
516 #define PA_ERR_INVALIDSERVER PA_ERR_INVALIDSERVER
517 #define PA_ERR_MODINITFAILED PA_ERR_MODINITFAILED
518 #define PA_ERR_BADSTATE PA_ERR_BADSTATE
519 #define PA_ERR_NODATA PA_ERR_NODATA
520 #define PA_ERR_VERSION PA_ERR_VERSION
521 #define PA_ERR_TOOLARGE PA_ERR_TOOLARGE
522 #define PA_ERR_NOTSUPPORTED PA_ERR_NOTSUPPORTED
523 #define PA_ERR_UNKNOWN PA_ERR_UNKNOWN
524 #define PA_ERR_NOEXTENSION PA_ERR_NOEXTENSION
525 #define PA_ERR_OBSOLETE PA_ERR_OBSOLETE
526 #define PA_ERR_NOTIMPLEMENTED PA_ERR_NOTIMPLEMENTED
527 #define PA_ERR_FORKED PA_ERR_FORKED
528 #define PA_ERR_MAX PA_ERR_MAX
529 /** \endcond */
530 
531 /** Subscription event mask, as used by pa_context_subscribe() */
532 typedef enum pa_subscription_mask {
533     PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
534     /**< No events */
535 
536     PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
537     /**< Sink events */
538 
539     PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
540     /**< Source events */
541 
542     PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
543     /**< Sink input events */
544 
545     PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
546     /**< Source output events */
547 
548     PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
549     /**< Module events */
550 
551     PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
552     /**< Client events */
553 
554     PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
555     /**< Sample cache events */
556 
557     PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
558     /**< Other global server changes. */
559 
560 /** \cond fulldocs */
561     PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
562     /**< \deprecated Autoload table events. */
563 /** \endcond */
564 
565     PA_SUBSCRIPTION_MASK_CARD = 0x0200U,
566     /**< Card events. \since 0.9.15 */
567 
568     PA_SUBSCRIPTION_MASK_ALL = 0x02ffU
569     /**< Catch all events */
570 } pa_subscription_mask_t;
571 
572 /** Subscription event types, as used by pa_context_subscribe() */
573 typedef enum pa_subscription_event_type {
574     PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
575     /**< Event type: Sink */
576 
577     PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
578     /**< Event type: Source */
579 
580     PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
581     /**< Event type: Sink input */
582 
583     PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
584     /**< Event type: Source output */
585 
586     PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
587     /**< Event type: Module */
588 
589     PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
590     /**< Event type: Client */
591 
592     PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
593     /**< Event type: Sample cache item */
594 
595     PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
596     /**< Event type: Global server change, only occurring with PA_SUBSCRIPTION_EVENT_CHANGE. */
597 
598 /** \cond fulldocs */
599     PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
600     /**< \deprecated Event type: Autoload table changes. */
601 /** \endcond */
602 
603     PA_SUBSCRIPTION_EVENT_CARD = 0x0009U,
604     /**< Event type: Card \since 0.9.15 */
605 
606     PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
607     /**< A mask to extract the event type from an event value */
608 
609     PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
610     /**< A new object was created */
611 
612     PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
613     /**< A property of the object was modified */
614 
615     PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
616     /**< An object was removed */
617 
618     PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U
619     /**< A mask to extract the event operation from an event value */
620 
621 } pa_subscription_event_type_t;
622 
623 /** Return one if an event type t matches an event mask bitfield */
624 #define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
625 
626 /** \cond fulldocs */
627 #define PA_SUBSCRIPTION_MASK_NULL PA_SUBSCRIPTION_MASK_NULL
628 #define PA_SUBSCRIPTION_MASK_SINK PA_SUBSCRIPTION_MASK_SINK
629 #define PA_SUBSCRIPTION_MASK_SOURCE PA_SUBSCRIPTION_MASK_SOURCE
630 #define PA_SUBSCRIPTION_MASK_SINK_INPUT PA_SUBSCRIPTION_MASK_SINK_INPUT
631 #define PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT
632 #define PA_SUBSCRIPTION_MASK_MODULE PA_SUBSCRIPTION_MASK_MODULE
633 #define PA_SUBSCRIPTION_MASK_CLIENT PA_SUBSCRIPTION_MASK_CLIENT
634 #define PA_SUBSCRIPTION_MASK_SAMPLE_CACHE PA_SUBSCRIPTION_MASK_SAMPLE_CACHE
635 #define PA_SUBSCRIPTION_MASK_SERVER PA_SUBSCRIPTION_MASK_SERVER
636 #define PA_SUBSCRIPTION_MASK_AUTOLOAD PA_SUBSCRIPTION_MASK_AUTOLOAD
637 #define PA_SUBSCRIPTION_MASK_CARD PA_SUBSCRIPTION_MASK_CARD
638 #define PA_SUBSCRIPTION_MASK_ALL PA_SUBSCRIPTION_MASK_ALL
639 #define PA_SUBSCRIPTION_EVENT_SINK PA_SUBSCRIPTION_EVENT_SINK
640 #define PA_SUBSCRIPTION_EVENT_SOURCE PA_SUBSCRIPTION_EVENT_SOURCE
641 #define PA_SUBSCRIPTION_EVENT_SINK_INPUT PA_SUBSCRIPTION_EVENT_SINK_INPUT
642 #define PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT
643 #define PA_SUBSCRIPTION_EVENT_MODULE PA_SUBSCRIPTION_EVENT_MODULE
644 #define PA_SUBSCRIPTION_EVENT_CLIENT PA_SUBSCRIPTION_EVENT_CLIENT
645 #define PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE
646 #define PA_SUBSCRIPTION_EVENT_SERVER PA_SUBSCRIPTION_EVENT_SERVER
647 #define PA_SUBSCRIPTION_EVENT_AUTOLOAD PA_SUBSCRIPTION_EVENT_AUTOLOAD
648 #define PA_SUBSCRIPTION_EVENT_CARD PA_SUBSCRIPTION_EVENT_CARD
649 #define PA_SUBSCRIPTION_EVENT_FACILITY_MASK PA_SUBSCRIPTION_EVENT_FACILITY_MASK
650 #define PA_SUBSCRIPTION_EVENT_NEW PA_SUBSCRIPTION_EVENT_NEW
651 #define PA_SUBSCRIPTION_EVENT_CHANGE PA_SUBSCRIPTION_EVENT_CHANGE
652 #define PA_SUBSCRIPTION_EVENT_REMOVE PA_SUBSCRIPTION_EVENT_REMOVE
653 #define PA_SUBSCRIPTION_EVENT_TYPE_MASK PA_SUBSCRIPTION_EVENT_TYPE_MASK
654 /** \endcond */
655 
656 /** A structure for all kinds of timing information of a stream. See
657  * pa_stream_update_timing_info() and pa_stream_get_timing_info(). The
658  * total output latency a sample that is written with
659  * pa_stream_write() takes to be played may be estimated by
660  * sink_usec+buffer_usec+transport_usec (where buffer_usec is defined
661  * as pa_bytes_to_usec(write_index-read_index)). The output buffer
662  * which buffer_usec relates to may be manipulated freely (with
663  * pa_stream_write()'s seek argument, pa_stream_flush() and friends),
664  * the buffers sink_usec and source_usec relate to are first-in
665  * first-out (FIFO) buffers which cannot be flushed or manipulated in
666  * any way. The total input latency a sample that is recorded takes to
667  * be delivered to the application is:
668  * source_usec+buffer_usec+transport_usec-sink_usec. (Take care of
669  * sign issues!) When connected to a monitor source sink_usec contains
670  * the latency of the owning sink. The two latency estimations
671  * described here are implemented in pa_stream_get_latency().
672  *
673  * All time values are in the sound card clock domain, unless noted
674  * otherwise. The sound card clock usually runs at a slightly different
675  * rate than the system clock.
676  *
677  * Please note that this structure can be extended as part of evolutionary
678  * API updates at any time in any new release.
679  * */
680 typedef struct pa_timing_info {
681     struct timeval timestamp;
682     /**< The system clock time when this timing info structure was
683      * current. */
684 
685     int synchronized_clocks;
686     /**< Non-zero if the local and the remote machine have
687      * synchronized clocks. If synchronized clocks are detected
688      * transport_usec becomes much more reliable. However, the code
689      * that detects synchronized clocks is very limited and unreliable
690      * itself. */
691 
692     pa_usec_t sink_usec;
693     /**< Time in usecs a sample takes to be played on the sink. For
694      * playback streams and record streams connected to a monitor
695      * source. */
696 
697     pa_usec_t source_usec;
698     /**< Time in usecs a sample takes from being recorded to being
699      * delivered to the application. Only for record streams. */
700 
701     pa_usec_t transport_usec;
702     /**< Estimated time in usecs a sample takes to be transferred
703      * to/from the daemon. For both playback and record streams. */
704 
705     int playing;
706     /**< Non-zero when the stream is currently not underrun and data
707      * is being passed on to the device. Only for playback
708      * streams. This field does not say whether the data is actually
709      * already being played. To determine this check whether
710      * since_underrun (converted to usec) is larger than sink_usec.*/
711 
712     int write_index_corrupt;
713     /**< Non-zero if write_index is not up-to-date because a local
714      * write command that corrupted it has been issued in the time
715      * since this latency info was current . Only write commands with
716      * SEEK_RELATIVE_ON_READ and SEEK_RELATIVE_END can corrupt
717      * write_index. */
718 
719     int64_t write_index;
720     /**< Current write index into the playback buffer in bytes. Think
721      * twice before using this for seeking purposes: it might be out
722      * of date at the time you want to use it. Consider using
723      * PA_SEEK_RELATIVE instead. */
724 
725     int read_index_corrupt;
726     /**< Non-zero if read_index is not up-to-date because a local
727      * pause or flush request that corrupted it has been issued in the
728      * time since this latency info was current. */
729 
730     int64_t read_index;
731     /**< Current read index into the playback buffer in bytes. Think
732      * twice before using this for seeking purposes: it might be out
733      * of date at the time you want to use it. Consider using
734      * PA_SEEK_RELATIVE_ON_READ instead. */
735 
736     pa_usec_t configured_sink_usec;
737     /**< The configured latency for the sink. \since 0.9.11 */
738 
739     pa_usec_t configured_source_usec;
740     /**< The configured latency for the source. \since 0.9.11 */
741 
742     int64_t since_underrun;
743     /**< Bytes that were handed to the sink since the last underrun
744      * happened, or since playback started again after the last
745      * underrun. playing will tell you which case it is. \since
746      * 0.9.11 */
747 
748 } pa_timing_info;
749 
750 /** A structure for the spawn api. This may be used to integrate auto
751  * spawned daemons into your application. For more information see
752  * pa_context_connect(). When spawning a new child process the
753  * waitpid() is used on the child's PID. The spawn routine will not
754  * block or ignore SIGCHLD signals, since this cannot be done in a
755  * thread compatible way. You might have to do this in
756  * prefork/postfork. */
757 typedef struct pa_spawn_api {
758     void (*prefork)(void);
759     /**< Is called just before the fork in the parent process. May be
760      * NULL. */
761 
762     void (*postfork)(void);
763     /**< Is called immediately after the fork in the parent
764      * process. May be NULL.*/
765 
766     void (*atfork)(void);
767     /**< Is called immediately after the fork in the child
768      * process. May be NULL. It is not safe to close all file
769      * descriptors in this function unconditionally, since a UNIX
770      * socket (created using socketpair()) is passed to the new
771      * process. */
772 } pa_spawn_api;
773 
774 /** Seek type for pa_stream_write(). */
775 typedef enum pa_seek_mode {
776     PA_SEEK_RELATIVE = 0,
777     /**< Seek relative to the write index. */
778 
779     PA_SEEK_ABSOLUTE = 1,
780     /**< Seek relative to the start of the buffer queue. */
781 
782     PA_SEEK_RELATIVE_ON_READ = 2,
783     /**< Seek relative to the read index. */
784 
785     PA_SEEK_RELATIVE_END = 3
786     /**< Seek relative to the current end of the buffer queue. */
787 } pa_seek_mode_t;
788 
789 /** \cond fulldocs */
790 #define PA_SEEK_RELATIVE PA_SEEK_RELATIVE
791 #define PA_SEEK_ABSOLUTE PA_SEEK_ABSOLUTE
792 #define PA_SEEK_RELATIVE_ON_READ PA_SEEK_RELATIVE_ON_READ
793 #define PA_SEEK_RELATIVE_END PA_SEEK_RELATIVE_END
794 /** \endcond */
795 
796 /** Special sink flags. */
797 typedef enum pa_sink_flags {
798     PA_SINK_NOFLAGS = 0x0000U,
799     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
800 
801     PA_SINK_HW_VOLUME_CTRL = 0x0001U,
802     /**< Supports hardware volume control. This is a dynamic flag and may
803      * change at runtime after the sink has initialized */
804 
805     PA_SINK_LATENCY = 0x0002U,
806     /**< Supports latency querying */
807 
808     PA_SINK_HARDWARE = 0x0004U,
809     /**< Is a hardware sink of some kind, in contrast to
810      * "virtual"/software sinks \since 0.9.3 */
811 
812     PA_SINK_NETWORK = 0x0008U,
813     /**< Is a networked sink of some kind. \since 0.9.7 */
814 
815     PA_SINK_HW_MUTE_CTRL = 0x0010U,
816     /**< Supports hardware mute control. This is a dynamic flag and may
817      * change at runtime after the sink has initialized \since 0.9.11 */
818 
819     PA_SINK_DECIBEL_VOLUME = 0x0020U,
820     /**< Volume can be translated to dB with pa_sw_volume_to_dB(). This is a
821      * dynamic flag and may change at runtime after the sink has initialized
822      * \since 0.9.11 */
823 
824     PA_SINK_FLAT_VOLUME = 0x0040U,
825     /**< This sink is in flat volume mode, i.e.\ always the maximum of
826      * the volume of all connected inputs. \since 0.9.15 */
827 
828     PA_SINK_DYNAMIC_LATENCY = 0x0080U,
829     /**< The latency can be adjusted dynamically depending on the
830      * needs of the connected streams. \since 0.9.15 */
831 
832     PA_SINK_SET_FORMATS = 0x0100U,
833     /**< The sink allows setting what formats are supported by the connected
834      * hardware. The actual functionality to do this might be provided by an
835      * extension. \since 1.0 */
836 
837 #ifdef __INCLUDED_FROM_PULSE_AUDIO
838 /** \cond fulldocs */
839     /* PRIVATE: Server-side values -- do not try to use these at client-side.
840      * The server will filter out these flags anyway, so you should never see
841      * these flags in sinks. */
842 
843     PA_SINK_SHARE_VOLUME_WITH_MASTER = 0x1000000U,
844     /**< This sink shares the volume with the master sink (used by some filter
845      * sinks). */
846 
847     PA_SINK_DEFERRED_VOLUME = 0x2000000U,
848     /**< The HW volume changes are syncronized with SW volume. */
849 /** \endcond */
850 #endif
851 
852 } pa_sink_flags_t;
853 
854 /** \cond fulldocs */
855 #define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
856 #define PA_SINK_LATENCY PA_SINK_LATENCY
857 #define PA_SINK_HARDWARE PA_SINK_HARDWARE
858 #define PA_SINK_NETWORK PA_SINK_NETWORK
859 #define PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL
860 #define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
861 #define PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME
862 #define PA_SINK_DYNAMIC_LATENCY PA_SINK_DYNAMIC_LATENCY
863 #define PA_SINK_SET_FORMATS PA_SINK_SET_FORMATS
864 #ifdef __INCLUDED_FROM_PULSE_AUDIO
865 #define PA_SINK_CLIENT_FLAGS_MASK 0xFFFFFF
866 #endif
867 
868 /** \endcond */
869 
870 /** Sink state. \since 0.9.15 */
871 typedef enum pa_sink_state { /* enum serialized in u8 */
872     PA_SINK_INVALID_STATE = -1,
873     /**< This state is used when the server does not support sink state introspection \since 0.9.15 */
874 
875     PA_SINK_RUNNING = 0,
876     /**< Running, sink is playing and used by at least one non-corked sink-input \since 0.9.15 */
877 
878     PA_SINK_IDLE = 1,
879     /**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
880 
881     PA_SINK_SUSPENDED = 2,
882     /**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
883 
884 /** \cond fulldocs */
885     /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
886      * SIDE! These values are *not* considered part of the official PA
887      * API/ABI. If you use them your application might break when PA
888      * is upgraded. Also, please note that these values are not useful
889      * on the client side anyway. */
890 
891     PA_SINK_INIT = -2,
892     /**< Initialization state */
893 
894     PA_SINK_UNLINKED = -3
895     /**< The state when the sink is getting unregistered and removed from client access */
896 /** \endcond */
897 
898 } pa_sink_state_t;
899 
900 /** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
PA_SINK_IS_OPENED(pa_sink_state_t x)901 static inline int PA_SINK_IS_OPENED(pa_sink_state_t x) {
902     return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
903 }
904 
905 /** Returns non-zero if sink is running. \since 1.0 */
PA_SINK_IS_RUNNING(pa_sink_state_t x)906 static inline int PA_SINK_IS_RUNNING(pa_sink_state_t x) {
907     return x == PA_SINK_RUNNING;
908 }
909 
910 /** \cond fulldocs */
911 #define PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE
912 #define PA_SINK_RUNNING PA_SINK_RUNNING
913 #define PA_SINK_IDLE PA_SINK_IDLE
914 #define PA_SINK_SUSPENDED PA_SINK_SUSPENDED
915 #define PA_SINK_INIT PA_SINK_INIT
916 #define PA_SINK_UNLINKED PA_SINK_UNLINKED
917 #define PA_SINK_IS_OPENED PA_SINK_IS_OPENED
918 /** \endcond */
919 
920 /** Special source flags.  */
921 typedef enum pa_source_flags {
922     PA_SOURCE_NOFLAGS = 0x0000U,
923     /**< Flag to pass when no specific options are needed (used to avoid casting)  \since 0.9.19 */
924 
925     PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
926     /**< Supports hardware volume control. This is a dynamic flag and may
927      * change at runtime after the source has initialized */
928 
929     PA_SOURCE_LATENCY = 0x0002U,
930     /**< Supports latency querying */
931 
932     PA_SOURCE_HARDWARE = 0x0004U,
933     /**< Is a hardware source of some kind, in contrast to
934      * "virtual"/software source \since 0.9.3 */
935 
936     PA_SOURCE_NETWORK = 0x0008U,
937     /**< Is a networked source of some kind. \since 0.9.7 */
938 
939     PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
940     /**< Supports hardware mute control. This is a dynamic flag and may
941      * change at runtime after the source has initialized \since 0.9.11 */
942 
943     PA_SOURCE_DECIBEL_VOLUME = 0x0020U,
944     /**< Volume can be translated to dB with pa_sw_volume_to_dB(). This is a
945      * dynamic flag and may change at runtime after the source has initialized
946      * \since 0.9.11 */
947 
948     PA_SOURCE_DYNAMIC_LATENCY = 0x0040U,
949     /**< The latency can be adjusted dynamically depending on the
950      * needs of the connected streams. \since 0.9.15 */
951 
952     PA_SOURCE_FLAT_VOLUME = 0x0080U,
953     /**< This source is in flat volume mode, i.e.\ always the maximum of
954      * the volume of all connected outputs. \since 1.0 */
955 
956 #ifdef __INCLUDED_FROM_PULSE_AUDIO
957 /** \cond fulldocs */
958     /* PRIVATE: Server-side values -- do not try to use these at client-side.
959      * The server will filter out these flags anyway, so you should never see
960      * these flags in sources. */
961 
962     PA_SOURCE_SHARE_VOLUME_WITH_MASTER = 0x1000000U,
963     /**< This source shares the volume with the master source (used by some filter
964      * sources). */
965 
966     PA_SOURCE_DEFERRED_VOLUME = 0x2000000U,
967     /**< The HW volume changes are syncronized with SW volume. */
968 #endif
969 } pa_source_flags_t;
970 
971 /** \cond fulldocs */
972 #define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
973 #define PA_SOURCE_LATENCY PA_SOURCE_LATENCY
974 #define PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE
975 #define PA_SOURCE_NETWORK PA_SOURCE_NETWORK
976 #define PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL
977 #define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
978 #define PA_SOURCE_DYNAMIC_LATENCY PA_SOURCE_DYNAMIC_LATENCY
979 #define PA_SOURCE_FLAT_VOLUME PA_SOURCE_FLAT_VOLUME
980 #ifdef __INCLUDED_FROM_PULSE_AUDIO
981 #define PA_SOURCE_CLIENT_FLAGS_MASK 0xFFFFFF
982 #endif
983 
984 /** \endcond */
985 
986 /** Source state. \since 0.9.15 */
987 typedef enum pa_source_state {
988     PA_SOURCE_INVALID_STATE = -1,
989     /**< This state is used when the server does not support source state introspection \since 0.9.15 */
990 
991     PA_SOURCE_RUNNING = 0,
992     /**< Running, source is recording and used by at least one non-corked source-output \since 0.9.15 */
993 
994     PA_SOURCE_IDLE = 1,
995     /**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
996 
997     PA_SOURCE_SUSPENDED = 2,
998     /**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
999 
1000 /** \cond fulldocs */
1001     /* PRIVATE: Server-side values -- DO NOT USE THIS ON THE CLIENT
1002      * SIDE! These values are *not* considered part of the official PA
1003      * API/ABI. If you use them your application might break when PA
1004      * is upgraded. Also, please note that these values are not useful
1005      * on the client side anyway. */
1006 
1007     PA_SOURCE_INIT = -2,
1008     /**< Initialization state */
1009 
1010     PA_SOURCE_UNLINKED = -3
1011     /**< The state when the source is getting unregistered and removed from client access */
1012 /** \endcond */
1013 
1014 } pa_source_state_t;
1015 
1016 /** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
PA_SOURCE_IS_OPENED(pa_source_state_t x)1017 static inline int PA_SOURCE_IS_OPENED(pa_source_state_t x) {
1018     return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
1019 }
1020 
1021 /** Returns non-zero if source is running \since 1.0 */
PA_SOURCE_IS_RUNNING(pa_source_state_t x)1022 static inline int PA_SOURCE_IS_RUNNING(pa_source_state_t x) {
1023     return x == PA_SOURCE_RUNNING;
1024 }
1025 
1026 /** \cond fulldocs */
1027 #define PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE
1028 #define PA_SOURCE_RUNNING PA_SOURCE_RUNNING
1029 #define PA_SOURCE_IDLE PA_SOURCE_IDLE
1030 #define PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED
1031 #define PA_SOURCE_INIT PA_SOURCE_INIT
1032 #define PA_SOURCE_UNLINKED PA_SOURCE_UNLINKED
1033 #define PA_SOURCE_IS_OPENED PA_SOURCE_IS_OPENED
1034 /** \endcond */
1035 
1036 /** A generic free() like callback prototype */
1037 typedef void (*pa_free_cb_t)(void *p);
1038 
1039 /** A stream policy/meta event requesting that an application should
1040  * cork a specific stream. See pa_stream_event_cb_t for more
1041  * information. \since 0.9.15 */
1042 #define PA_STREAM_EVENT_REQUEST_CORK "request-cork"
1043 
1044 /** A stream policy/meta event requesting that an application should
1045  * cork a specific stream. See pa_stream_event_cb_t for more
1046  * information, \since 0.9.15 */
1047 #define PA_STREAM_EVENT_REQUEST_UNCORK "request-uncork"
1048 
1049 /** A stream event notifying that the stream is going to be
1050  * disconnected because the underlying sink changed and no longer
1051  * supports the format that was originally negotiated. Clients need
1052  * to connect a new stream to renegotiate a format and continue
1053  * playback. \since 1.0 */
1054 #define PA_STREAM_EVENT_FORMAT_LOST "format-lost"
1055 
1056 #ifndef __INCLUDED_FROM_PULSE_AUDIO
1057 /** Port availability / jack detection status
1058  * \since 2.0 */
1059 typedef enum pa_port_available {
1060     PA_PORT_AVAILABLE_UNKNOWN = 0, /**< This port does not support jack detection \since 2.0 */
1061     PA_PORT_AVAILABLE_NO = 1,      /**< This port is not available, likely because the jack is not plugged in. \since 2.0 */
1062     PA_PORT_AVAILABLE_YES = 2,     /**< This port is available, likely because the jack is plugged in. \since 2.0 */
1063 } pa_port_available_t;
1064 
1065 /** \cond fulldocs */
1066 #define PA_PORT_AVAILABLE_UNKNOWN PA_PORT_AVAILABLE_UNKNOWN
1067 #define PA_PORT_AVAILABLE_NO PA_PORT_AVAILABLE_NO
1068 #define PA_PORT_AVAILABLE_YES PA_PORT_AVAILABLE_YES
1069 
1070 /** \endcond */
1071 #endif
1072 
1073 /** Port type. New types can be added in the future, so applications should
1074  * gracefully handle situations where a type identifier doesn't match any item
1075  * in this enumeration. \since 14.0 */
1076 typedef enum pa_device_port_type {
1077     PA_DEVICE_PORT_TYPE_UNKNOWN = 0,
1078     PA_DEVICE_PORT_TYPE_AUX = 1,
1079     PA_DEVICE_PORT_TYPE_SPEAKER = 2,
1080     PA_DEVICE_PORT_TYPE_HEADPHONES = 3,
1081     PA_DEVICE_PORT_TYPE_LINE = 4,
1082     PA_DEVICE_PORT_TYPE_MIC = 5,
1083     PA_DEVICE_PORT_TYPE_HEADSET = 6,
1084     PA_DEVICE_PORT_TYPE_HANDSET = 7,
1085     PA_DEVICE_PORT_TYPE_EARPIECE = 8,
1086     PA_DEVICE_PORT_TYPE_SPDIF = 9,
1087     PA_DEVICE_PORT_TYPE_HDMI = 10,
1088     PA_DEVICE_PORT_TYPE_TV = 11,
1089     PA_DEVICE_PORT_TYPE_RADIO = 12,
1090     PA_DEVICE_PORT_TYPE_VIDEO = 13,
1091     PA_DEVICE_PORT_TYPE_USB = 14,
1092     PA_DEVICE_PORT_TYPE_BLUETOOTH = 15,
1093     PA_DEVICE_PORT_TYPE_PORTABLE = 16,
1094     PA_DEVICE_PORT_TYPE_HANDSFREE = 17,
1095     PA_DEVICE_PORT_TYPE_CAR = 18,
1096     PA_DEVICE_PORT_TYPE_HIFI = 19,
1097     PA_DEVICE_PORT_TYPE_PHONE = 20,
1098     PA_DEVICE_PORT_TYPE_NETWORK = 21,
1099     PA_DEVICE_PORT_TYPE_ANALOG = 22,
1100 } pa_device_port_type_t;
1101 
1102 PA_C_DECL_END
1103 
1104 #endif
1105