def.h 44 KB

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