7#if !defined(CUBEB_c2f983e9_c96f_e71c_72c3_bbf62992a382)
8#define CUBEB_c2f983e9_c96f_e71c_72c3_bbf62992a382
10#include "cubeb_export.h"
14#if defined(__cplusplus)
142#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
161 CUBEB_LOG_DISABLED = 0,
171 CHANNEL_FRONT_LEFT = 1 << 0,
172 CHANNEL_FRONT_RIGHT = 1 << 1,
173 CHANNEL_FRONT_CENTER = 1 << 2,
174 CHANNEL_LOW_FREQUENCY = 1 << 3,
175 CHANNEL_BACK_LEFT = 1 << 4,
176 CHANNEL_BACK_RIGHT = 1 << 5,
177 CHANNEL_FRONT_LEFT_OF_CENTER = 1 << 6,
178 CHANNEL_FRONT_RIGHT_OF_CENTER = 1 << 7,
179 CHANNEL_BACK_CENTER = 1 << 8,
180 CHANNEL_SIDE_LEFT = 1 << 9,
181 CHANNEL_SIDE_RIGHT = 1 << 10,
182 CHANNEL_TOP_CENTER = 1 << 11,
183 CHANNEL_TOP_FRONT_LEFT = 1 << 12,
184 CHANNEL_TOP_FRONT_CENTER = 1 << 13,
185 CHANNEL_TOP_FRONT_RIGHT = 1 << 14,
186 CHANNEL_TOP_BACK_LEFT = 1 << 15,
187 CHANNEL_TOP_BACK_CENTER = 1 << 16,
188 CHANNEL_TOP_BACK_RIGHT = 1 << 17
197 CUBEB_LAYOUT_UNDEFINED = 0,
198 CUBEB_LAYOUT_MONO = CHANNEL_FRONT_CENTER,
199 CUBEB_LAYOUT_MONO_LFE = CUBEB_LAYOUT_MONO | CHANNEL_LOW_FREQUENCY,
200 CUBEB_LAYOUT_STEREO = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT,
201 CUBEB_LAYOUT_STEREO_LFE = CUBEB_LAYOUT_STEREO | CHANNEL_LOW_FREQUENCY,
203 CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_FRONT_CENTER,
204 CUBEB_LAYOUT_3F_LFE = CUBEB_LAYOUT_3F | CHANNEL_LOW_FREQUENCY,
206 CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_BACK_CENTER,
207 CUBEB_LAYOUT_2F1_LFE = CUBEB_LAYOUT_2F1 | CHANNEL_LOW_FREQUENCY,
208 CUBEB_LAYOUT_3F1 = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
209 CHANNEL_FRONT_CENTER | CHANNEL_BACK_CENTER,
210 CUBEB_LAYOUT_3F1_LFE = CUBEB_LAYOUT_3F1 | CHANNEL_LOW_FREQUENCY,
211 CUBEB_LAYOUT_2F2 = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
212 CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT,
213 CUBEB_LAYOUT_2F2_LFE = CUBEB_LAYOUT_2F2 | CHANNEL_LOW_FREQUENCY,
214 CUBEB_LAYOUT_QUAD = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
215 CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT,
216 CUBEB_LAYOUT_QUAD_LFE = CUBEB_LAYOUT_QUAD | CHANNEL_LOW_FREQUENCY,
217 CUBEB_LAYOUT_3F2 = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
218 CHANNEL_FRONT_CENTER | CHANNEL_SIDE_LEFT |
220 CUBEB_LAYOUT_3F2_LFE = CUBEB_LAYOUT_3F2 | CHANNEL_LOW_FREQUENCY,
221 CUBEB_LAYOUT_3F2_BACK = CUBEB_LAYOUT_QUAD | CHANNEL_FRONT_CENTER,
222 CUBEB_LAYOUT_3F2_LFE_BACK = CUBEB_LAYOUT_3F2_BACK | CHANNEL_LOW_FREQUENCY,
223 CUBEB_LAYOUT_3F3R_LFE = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
224 CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
225 CHANNEL_BACK_CENTER | CHANNEL_SIDE_LEFT |
227 CUBEB_LAYOUT_3F4_LFE = CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
228 CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
229 CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT |
230 CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT,
268 CUBEB_INPUT_PROCESSING_PARAM_NONE = 0x00,
269 CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION = 0x01,
270 CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION = 0x02,
271 CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL = 0x04,
272 CUBEB_INPUT_PROCESSING_PARAM_VOICE_ISOLATION = 0x08,
321 CUBEB_DEVICE_TYPE_UNKNOWN,
322 CUBEB_DEVICE_TYPE_INPUT,
323 CUBEB_DEVICE_TYPE_OUTPUT
347#if defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
349#define CUBEB_DEVICE_FMT_S16NE CUBEB_DEVICE_FMT_S16BE
352#define CUBEB_DEVICE_FMT_F32NE CUBEB_DEVICE_FMT_F32BE
355#define CUBEB_DEVICE_FMT_S16NE CUBEB_DEVICE_FMT_S16LE
358#define CUBEB_DEVICE_FMT_F32NE CUBEB_DEVICE_FMT_F32LE
361#define CUBEB_DEVICE_FMT_S16_MASK \
362 (CUBEB_DEVICE_FMT_S16LE | CUBEB_DEVICE_FMT_S16BE)
364#define CUBEB_DEVICE_FMT_F32_MASK \
365 (CUBEB_DEVICE_FMT_F32LE | CUBEB_DEVICE_FMT_F32BE)
367#define CUBEB_DEVICE_FMT_ALL \
368 (CUBEB_DEVICE_FMT_S16_MASK | CUBEB_DEVICE_FMT_F32_MASK)
375 CUBEB_DEVICE_PREF_NONE = 0x00,
376 CUBEB_DEVICE_PREF_MULTIMEDIA = 0x01,
377 CUBEB_DEVICE_PREF_VOICE = 0x02,
378 CUBEB_DEVICE_PREF_NOTIFICATION = 0x04,
379 CUBEB_DEVICE_PREF_ALL = 0x0F
452 void const * input_buffer,
453 void * output_buffer,
long nframes);
500 char const * backend_name);
505CUBEB_EXPORT
char const *
537 uint32_t * latency_frames);
601 char const * stream_name,
cubeb_devid input_device,
795#if defined(__cplusplus)
CUBEB_EXPORT cubeb_backend_names cubeb_get_backend_names()
Get a read-only array of strings identifying available backends.
CUBEB_EXPORT int cubeb_get_preferred_sample_rate(cubeb *context, uint32_t *rate)
Get the preferred sample rate for this backend: this is hardware and platform dependent,...
void const * cubeb_devid
An opaque handle used to refer a particular input or output device across calls.
Definition cubeb.h:157
CUBEB_EXPORT int cubeb_stream_get_current_device(cubeb_stream *stm, cubeb_device **const device)
Get the current output device for this stream.
cubeb_channel
A single channel position, to be used in a bitmask.
Definition cubeb.h:169
CUBEB_EXPORT char const * cubeb_get_backend_id(cubeb *context)
Get a read-only string identifying this context's current backend.
void(* cubeb_device_collection_changed_callback)(cubeb *context, void *user_ptr)
User supplied callback called when the underlying device collection changed.
Definition cubeb.h:474
cubeb_device_type
Whether a particular device is an input device (e.g.
Definition cubeb.h:320
CUBEB_EXPORT int cubeb_register_device_collection_changed(cubeb *context, cubeb_device_type devtype, cubeb_device_collection_changed_callback callback, void *user_ptr)
Registers a callback which is called when the system detects a new device or a device is removed,...
CUBEB_EXPORT int cubeb_enumerate_devices(cubeb *context, cubeb_device_type devtype, cubeb_device_collection *collection)
Returns enumerated devices.
CUBEB_EXPORT int cubeb_stream_device_destroy(cubeb_stream *stream, cubeb_device *devices)
Destroy a cubeb_device structure.
CUBEB_EXPORT int cubeb_stream_get_input_latency(cubeb_stream *stream, uint32_t *latency)
Get the input latency for this stream, in frames.
cubeb_device_pref
Channel type for a cubeb_stream.
Definition cubeb.h:374
CUBEB_EXPORT int cubeb_stream_set_volume(cubeb_stream *stream, float volume)
Set the volume for a stream.
void(* cubeb_log_callback)(char const *fmt,...)
User supplied callback called when a message needs logging.
Definition cubeb.h:478
CUBEB_EXPORT int cubeb_set_log_callback(cubeb_log_level log_level, cubeb_log_callback log_callback)
Set a callback to be called with a message.
CUBEB_EXPORT int cubeb_stream_set_input_processing_params(cubeb_stream *stream, cubeb_input_processing_params params)
Set what input processing features to enable for this stream.
void(* cubeb_device_changed_callback)(void *user_ptr)
User supplied callback called when the underlying device changed.
Definition cubeb.h:465
struct cubeb cubeb
Opaque handle referencing the application state.
Definition cubeb.h:127
CUBEB_EXPORT int cubeb_stream_register_device_changed_callback(cubeb_stream *stream, cubeb_device_changed_callback device_changed_callback)
Set a callback to be notified when the output device changes.
CUBEB_EXPORT int cubeb_stream_start(cubeb_stream *stream)
Start playback.
CUBEB_EXPORT int cubeb_stream_init(cubeb *context, cubeb_stream **stream, char const *stream_name, cubeb_devid input_device, cubeb_stream_params *input_stream_params, cubeb_devid output_device, cubeb_stream_params *output_stream_params, uint32_t latency_frames, cubeb_data_callback data_callback, cubeb_state_callback state_callback, void *user_ptr)
Initialize a stream associated with the supplied application context.
long(* cubeb_data_callback)(cubeb_stream *stream, void *user_ptr, void const *input_buffer, void *output_buffer, long nframes)
User supplied data callback.
Definition cubeb.h:451
cubeb_sample_format
Sample format enumeration.
Definition cubeb.h:133
@ CUBEB_SAMPLE_FLOAT32LE
Big endian 32-bit IEEE floating point PCM.
Definition cubeb.h:139
@ CUBEB_SAMPLE_FLOAT32BE
Native endian 16-bit signed PCM.
Definition cubeb.h:141
@ CUBEB_SAMPLE_S16BE
Little endian 32-bit IEEE floating point PCM.
Definition cubeb.h:137
@ CUBEB_SAMPLE_S16LE
Little endian 16-bit signed PCM.
Definition cubeb.h:135
@ CUBEB_SAMPLE_S16NE
Native endian 32-bit IEEE floating point PCM.
Definition cubeb.h:149
cubeb_device_state
The state of a device.
Definition cubeb.h:329
@ CUBEB_DEVICE_STATE_DISABLED
The device has been disabled at the system level.
Definition cubeb.h:330
@ CUBEB_DEVICE_STATE_ENABLED
The device is enabled.
Definition cubeb.h:334
@ CUBEB_DEVICE_STATE_UNPLUGGED
The device is enabled, but nothing is plugged into it.
Definition cubeb.h:332
CUBEB_EXPORT int cubeb_stream_set_input_mute(cubeb_stream *stream, int mute)
Set input mute state for this stream.
CUBEB_EXPORT int cubeb_get_max_channel_count(cubeb *context, uint32_t *max_channels)
Get the maximum possible number of channels.
CUBEB_EXPORT int cubeb_get_supported_input_processing_params(cubeb *context, cubeb_input_processing_params *params)
Get the supported input processing features for this backend.
cubeb_stream_prefs
Miscellaneous stream preferences.
Definition cubeb.h:234
@ CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT
Don't automatically try to connect ports.
Definition cubeb.h:258
@ CUBEB_STREAM_PREF_NONE
No stream preferences are requested.
Definition cubeb.h:235
@ CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING
Disable switching default device on OS changes.
Definition cubeb.h:241
@ CUBEB_STREAM_PREF_PERSIST
Request that the volume and mute settings should persist across restarts of the stream and/or applica...
Definition cubeb.h:254
@ CUBEB_STREAM_PREF_RAW
Windows only.
Definition cubeb.h:251
@ CUBEB_STREAM_PREF_VOICE
This stream is going to transport voice data.
Definition cubeb.h:244
@ CUBEB_STREAM_PREF_LOOPBACK
Request a loopback stream.
Definition cubeb.h:236
CUBEB_EXPORT int cubeb_stream_get_latency(cubeb_stream *stream, uint32_t *latency)
Get the latency for this stream, in frames.
CUBEB_EXPORT int cubeb_init(cubeb **context, char const *context_name, char const *backend_name)
Initialize an application context.
struct cubeb_stream cubeb_stream
Opaque handle referencing the stream state.
Definition cubeb.h:129
CUBEB_EXPORT int cubeb_stream_stop(cubeb_stream *stream)
Stop playback.
CUBEB_EXPORT int cubeb_device_collection_destroy(cubeb *context, cubeb_device_collection *collection)
Destroy a cubeb_device_collection, and its cubeb_device_info.
CUBEB_EXPORT int cubeb_stream_get_position(cubeb_stream *stream, uint64_t *position)
Get the current stream playback position.
void(* cubeb_state_callback)(cubeb_stream *stream, void *user_ptr, cubeb_state state)
User supplied state callback.
Definition cubeb.h:459
uint32_t cubeb_channel_layout
A bitmask representing the channel layout of a cubeb stream.
Definition cubeb.h:194
CUBEB_EXPORT void cubeb_stream_destroy(cubeb_stream *stream)
Destroy a stream.
CUBEB_EXPORT int cubeb_stream_set_name(cubeb_stream *stream, char const *stream_name)
Change a stream's name.
cubeb_device_fmt
Architecture specific sample type.
Definition cubeb.h:340
@ CUBEB_DEVICE_FMT_S16BE
16-bit integers, Big Endian.
Definition cubeb.h:342
@ CUBEB_DEVICE_FMT_F32BE
32-bit floating point, Big Endian.
Definition cubeb.h:344
@ CUBEB_DEVICE_FMT_S16LE
16-bit integers, Little Endian.
Definition cubeb.h:341
@ CUBEB_DEVICE_FMT_F32LE
32-bit floating point, Little Endian.
Definition cubeb.h:343
@ CUBEB_ERROR
Unclassified error.
Definition cubeb.h:307
@ CUBEB_ERROR_INVALID_FORMAT
Unsupported cubeb_stream_params requested.
Definition cubeb.h:308
@ CUBEB_ERROR_NOT_SUPPORTED
Optional function not implemented in current backend.
Definition cubeb.h:311
@ CUBEB_ERROR_DEVICE_UNAVAILABLE
Device specified by cubeb_devid not available.
Definition cubeb.h:313
@ CUBEB_OK
Success.
Definition cubeb.h:306
@ CUBEB_ERROR_INVALID_PARAMETER
Invalid parameter specified.
Definition cubeb.h:310
CUBEB_EXPORT void cubeb_destroy(cubeb *context)
Destroy an application context.
cubeb_log_level
Level (verbosity) of logging for a particular cubeb context.
Definition cubeb.h:160
@ CUBEB_LOG_NORMAL
< Logging disabled
Definition cubeb.h:162
@ CUBEB_LOG_VERBOSE
Verbose logging of callbacks, can have performance implications.
Definition cubeb.h:164
cubeb_input_processing_params
Input stream audio processing parameters.
Definition cubeb.h:267
CUBEB_EXPORT int cubeb_get_min_latency(cubeb *context, cubeb_stream_params *params, uint32_t *latency_frames)
Get the minimal latency value, in frames, that is guaranteed to work when creating a stream for the s...
cubeb_state
Stream states signaled via state_callback.
Definition cubeb.h:297
@ CUBEB_STATE_STARTED
Stream started.
Definition cubeb.h:298
@ CUBEB_STATE_ERROR
Stream disabled due to error.
Definition cubeb.h:301
@ CUBEB_STATE_DRAINED
Stream drained.
Definition cubeb.h:300
@ CUBEB_STATE_STOPPED
Stream stopped.
Definition cubeb.h:299
CUBEB_EXPORT void * cubeb_stream_user_ptr(cubeb_stream *stream)
Return the user data pointer registered with the stream with cubeb_stream_init.
Array of compiled backends returned by cubeb_get_backend_names.
Definition cubeb.h:423
const char *const * names
Array of strings representing backend names.
Definition cubeb.h:425
size_t count
Length of the array.
Definition cubeb.h:426
Device collection.
Definition cubeb.h:417
size_t count
Device count in collection.
Definition cubeb.h:419
cubeb_device_info * device
Array of pointers to device info.
Definition cubeb.h:418
This structure holds the characteristics of an input or output audio device.
Definition cubeb.h:387
cubeb_device_state state
State of device disabled/enabled/unplugged.
Definition cubeb.h:399
uint32_t max_rate
Maximum sample rate supported.
Definition cubeb.h:407
uint32_t min_rate
Minimum sample rate supported.
Definition cubeb.h:408
cubeb_device_type type
Type of device (Input/Output).
Definition cubeb.h:398
cubeb_device_pref preferred
Preferred device.
Definition cubeb.h:400
cubeb_device_fmt default_format
The default sample format for this device.
Definition cubeb.h:404
char const * group_id
Two devices have the same group identifier if they belong to the same physical device; for example a ...
Definition cubeb.h:393
uint32_t max_channels
Channels.
Definition cubeb.h:405
uint32_t default_rate
Default/Preferred sample rate.
Definition cubeb.h:406
uint32_t latency_lo
Lowest possible latency in frames.
Definition cubeb.h:410
char const * vendor_name
Optional vendor name, may be NULL.
Definition cubeb.h:396
uint32_t latency_hi
Higest possible latency in frames.
Definition cubeb.h:411
char const * device_id
Device identifier which might be presented in a UI.
Definition cubeb.h:390
cubeb_devid devid
Device identifier handle.
Definition cubeb.h:388
char const * friendly_name
Friendly device name which might be presented in a UI.
Definition cubeb.h:391
cubeb_device_fmt format
Sample format supported.
Definition cubeb.h:402
Audio device description.
Definition cubeb.h:291
char * input_name
The name of the input device.
Definition cubeb.h:293
char * output_name
The name of the output device.
Definition cubeb.h:292
Stream format initialization parameters.
Definition cubeb.h:276
cubeb_input_processing_params input_params
Requested input processing params.
Definition cubeb.h:285
cubeb_sample_format format
Requested sample format.
Definition cubeb.h:277
cubeb_channel_layout layout
Requested channel layout.
Definition cubeb.h:282
cubeb_stream_prefs prefs
Requested preferences.
Definition cubeb.h:284
uint32_t rate
Requested sample rate.
Definition cubeb.h:279
uint32_t channels
Requested channel count.
Definition cubeb.h:280