The RtAudio Home Page

Home Class/Enum List File List Compound Members C interface

rtaudio_c.h
Go to the documentation of this file.
1/************************************************************************/
13/************************************************************************/
14
18
19#ifndef RTAUDIO_C_H
20#define RTAUDIO_C_H
21
22#if defined(RTAUDIO_EXPORT)
23#if defined _WIN32 || defined __CYGWIN__
24#define RTAUDIOAPI __declspec(dllexport)
25#else
26#define RTAUDIOAPI __attribute__((visibility("default")))
27#endif
28#else
29#define RTAUDIOAPI //__declspec(dllimport)
30#endif
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
48 typedef unsigned long rtaudio_format_t;
49
50#define RTAUDIO_FORMAT_SINT8 0x01
51#define RTAUDIO_FORMAT_SINT16 0x02
52#define RTAUDIO_FORMAT_SINT24 0x04
53#define RTAUDIO_FORMAT_SINT32 0x08
54#define RTAUDIO_FORMAT_FLOAT32 0x10
55#define RTAUDIO_FORMAT_FLOAT64 0x20
56
71 typedef unsigned int rtaudio_stream_flags_t;
72
73#define RTAUDIO_FLAGS_NONINTERLEAVED 0x1
74#define RTAUDIO_FLAGS_MINIMIZE_LATENCY 0x2
75#define RTAUDIO_FLAGS_HOG_DEVICE 0x4
76#define RTAUDIO_FLAGS_SCHEDULE_REALTIME 0x8
77#define RTAUDIO_FLAGS_ALSA_USE_DEFAULT 0x10
78#define RTAUDIO_FLAGS_JACK_DONT_CONNECT 0x20
79
93 typedef unsigned int rtaudio_stream_status_t;
94
95#define RTAUDIO_STATUS_INPUT_OVERFLOW 0x1
96#define RTAUDIO_STATUS_OUTPUT_UNDERFLOW 0x2
97
99
107 typedef int (*rtaudio_cb_t)(void *out, void *in, unsigned int nFrames,
108 double stream_time, rtaudio_stream_status_t status,
109 void *userdata);
110
115 enum rtaudio_error {
116 RTAUDIO_ERROR_NONE = 0,
117 RTAUDIO_ERROR_WARNING,
118 RTAUDIO_ERROR_UNKNOWN,
119 RTAUDIO_ERROR_NO_DEVICES_FOUND,
120 RTAUDIO_ERROR_INVALID_DEVICE,
121 RTAUDIO_ERROR_DEVICE_DISCONNECT,
122 RTAUDIO_ERROR_MEMORY_ERROR,
123 RTAUDIO_ERROR_INVALID_PARAMETER,
124 RTAUDIO_ERROR_INVALID_USE,
125 RTAUDIO_ERROR_DRIVER_ERROR,
126 RTAUDIO_ERROR_SYSTEM_ERROR,
127 RTAUDIO_ERROR_THREAD_ERROR,
128};
129typedef int rtaudio_error_t;
130
132
138 typedef void (*rtaudio_error_cb_t)(rtaudio_error_t err, const char *msg);
139
141 enum rtaudio_api {
142 RTAUDIO_API_UNSPECIFIED,
143 RTAUDIO_API_MACOSX_CORE,
144 RTAUDIO_API_LINUX_ALSA,
145 RTAUDIO_API_UNIX_JACK,
146 RTAUDIO_API_LINUX_PULSE,
147 RTAUDIO_API_LINUX_OSS,
148 RTAUDIO_API_WINDOWS_ASIO,
149 RTAUDIO_API_WINDOWS_WASAPI,
150 RTAUDIO_API_WINDOWS_DS,
151 RTAUDIO_API_DUMMY,
152 RTAUDIO_API_NUM,
153};
154typedef int rtaudio_api_t;
155
156#define NUM_SAMPLE_RATES 16
157#define MAX_NAME_LENGTH 512
158
161 typedef struct rtaudio_device_info {
162 unsigned int id;
163 unsigned int output_channels;
164 unsigned int input_channels;
165 unsigned int duplex_channels;
166
167 int is_default_output;
168 int is_default_input;
169
170 rtaudio_format_t native_formats;
171
172 unsigned int preferred_sample_rate;
173 unsigned int sample_rates[NUM_SAMPLE_RATES];
174
175 char name[MAX_NAME_LENGTH];
176} rtaudio_device_info_t;
177
180 typedef struct rtaudio_stream_parameters {
181 unsigned int device_id;
182 unsigned int num_channels;
183 unsigned int first_channel;
184} rtaudio_stream_parameters_t;
185
188 typedef struct rtaudio_stream_options {
189 rtaudio_stream_flags_t flags;
190 unsigned int num_buffers;
191 int priority;
192 char name[MAX_NAME_LENGTH];
193} rtaudio_stream_options_t;
194
195typedef struct rtaudio *rtaudio_t;
196
198RTAUDIOAPI const char *rtaudio_version(void);
199
203RTAUDIOAPI unsigned int rtaudio_get_num_compiled_apis(void);
204
209RTAUDIOAPI const rtaudio_api_t *rtaudio_compiled_api(void);
210
214RTAUDIOAPI const char *rtaudio_api_name(rtaudio_api_t api);
215
218RTAUDIOAPI const char *rtaudio_api_display_name(rtaudio_api_t api);
219
222RTAUDIOAPI rtaudio_api_t rtaudio_compiled_api_by_name(const char *name);
223
224RTAUDIOAPI const char *rtaudio_error(rtaudio_t audio);
225
226RTAUDIOAPI rtaudio_error_t rtaudio_error_type(rtaudio_t audio);
227
229RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api);
230
232RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio);
233
236RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio);
237
240RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio);
241
247RTAUDIOAPI unsigned int rtaudio_get_device_id(rtaudio_t audio, int i);
248
251RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio,
252 unsigned int id);
253
256RTAUDIOAPI unsigned int rtaudio_get_default_output_device(rtaudio_t audio);
257
260RTAUDIOAPI unsigned int rtaudio_get_default_input_device(rtaudio_t audio);
261
264RTAUDIOAPI rtaudio_error_t
265rtaudio_open_stream(rtaudio_t audio, rtaudio_stream_parameters_t *output_params,
266 rtaudio_stream_parameters_t *input_params,
267 rtaudio_format_t format, unsigned int sample_rate,
268 unsigned int *buffer_frames, rtaudio_cb_t cb,
269 void *userdata, rtaudio_stream_options_t *options,
270 rtaudio_error_cb_t errcb);
271
273RTAUDIOAPI void rtaudio_close_stream(rtaudio_t audio);
274
276RTAUDIOAPI rtaudio_error_t rtaudio_start_stream(rtaudio_t audio);
277
280RTAUDIOAPI rtaudio_error_t rtaudio_stop_stream(rtaudio_t audio);
281
284RTAUDIOAPI rtaudio_error_t rtaudio_abort_stream(rtaudio_t audio);
285
287RTAUDIOAPI int rtaudio_is_stream_open(rtaudio_t audio);
288
291RTAUDIOAPI int rtaudio_is_stream_running(rtaudio_t audio);
292
295RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio);
296
299RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time);
300
303RTAUDIOAPI long rtaudio_get_stream_latency(rtaudio_t audio);
304
307RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(rtaudio_t audio);
308
311RTAUDIOAPI void rtaudio_show_warnings(rtaudio_t audio, int show);
312
313#ifdef __cplusplus
314}
315#endif
316#endif /* RTAUDIO_C_H */
317
rtaudio_api
rtaudio_api
Audio API specifier. See RtAudio::Api.
Definition rtaudio_c.h:141
rtaudio_create
RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api)
Create an instance of struct rtaudio.
rtaudio_stream_flags_t
unsigned int rtaudio_stream_flags_t
RtAudio stream option flags.
Definition rtaudio_c.h:71
rtaudio_error_cb_t
void(* rtaudio_error_cb_t)(rtaudio_error_t err, const char *msg)
RtAudio error callback function prototype.
Definition rtaudio_c.h:138
rtaudio_cb_t
int(* rtaudio_cb_t)(void *out, void *in, unsigned int nFrames, double stream_time, rtaudio_stream_status_t status, void *userdata)
RtAudio callback function prototype.
Definition rtaudio_c.h:107
rtaudio_error
rtaudio_error
Error codes for RtAudio.
Definition rtaudio_c.h:115
rtaudio_destroy
RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio)
Free an instance of struct rtaudio.
rtaudio_close_stream
RTAUDIOAPI void rtaudio_close_stream(rtaudio_t audio)
Closes a stream and frees any associated stream memory. See RtAudio::closeStream().
rtaudio_show_warnings
RTAUDIOAPI void rtaudio_show_warnings(rtaudio_t audio, int show)
rtaudio_get_default_input_device
RTAUDIOAPI unsigned int rtaudio_get_default_input_device(rtaudio_t audio)
rtaudio_is_stream_open
RTAUDIOAPI int rtaudio_is_stream_open(rtaudio_t audio)
Returns 1 if a stream is open and false if not. See RtAudio::isStreamOpen().
rtaudio_compiled_api_by_name
RTAUDIOAPI rtaudio_api_t rtaudio_compiled_api_by_name(const char *name)
rtaudio_api_display_name
RTAUDIOAPI const char * rtaudio_api_display_name(rtaudio_api_t api)
rtaudio_set_stream_time
RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time)
rtaudio_open_stream
RTAUDIOAPI rtaudio_error_t rtaudio_open_stream(rtaudio_t audio, rtaudio_stream_parameters_t *output_params, rtaudio_stream_parameters_t *input_params, rtaudio_format_t format, unsigned int sample_rate, unsigned int *buffer_frames, rtaudio_cb_t cb, void *userdata, rtaudio_stream_options_t *options, rtaudio_error_cb_t errcb)
rtaudio_stop_stream
RTAUDIOAPI rtaudio_error_t rtaudio_stop_stream(rtaudio_t audio)
rtaudio_format_t
unsigned long rtaudio_format_t
RtAudio data format type.
Definition rtaudio_c.h:48
rtaudio_get_stream_sample_rate
RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(rtaudio_t audio)
rtaudio_get_stream_latency
RTAUDIOAPI long rtaudio_get_stream_latency(rtaudio_t audio)
rtaudio_get_device_info
RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio, unsigned int id)
rtaudio_current_api
RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio)
rtaudio_get_device_id
RTAUDIOAPI unsigned int rtaudio_get_device_id(rtaudio_t audio, int i)
rtaudio_device_count
RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio)
rtaudio_abort_stream
RTAUDIOAPI rtaudio_error_t rtaudio_abort_stream(rtaudio_t audio)
rtaudio_get_stream_time
RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio)
rtaudio_stream_status_t
unsigned int rtaudio_stream_status_t
RtAudio stream status (over- or underflow) flags.
Definition rtaudio_c.h:93
rtaudio_get_num_compiled_apis
RTAUDIOAPI unsigned int rtaudio_get_num_compiled_apis(void)
rtaudio_is_stream_running
RTAUDIOAPI int rtaudio_is_stream_running(rtaudio_t audio)
rtaudio_get_default_output_device
RTAUDIOAPI unsigned int rtaudio_get_default_output_device(rtaudio_t audio)
rtaudio_version
RTAUDIOAPI const char * rtaudio_version(void)
Determine the current RtAudio version. See RtAudio::getVersion().
rtaudio_api_name
RTAUDIOAPI const char * rtaudio_api_name(rtaudio_api_t api)
rtaudio_start_stream
RTAUDIOAPI rtaudio_error_t rtaudio_start_stream(rtaudio_t audio)
Starts a stream. See RtAudio::startStream().
rtaudio_compiled_api
RTAUDIOAPI const rtaudio_api_t * rtaudio_compiled_api(void)
RTAUDIO_API_LINUX_PULSE
@ RTAUDIO_API_LINUX_PULSE
Definition rtaudio_c.h:146
RTAUDIO_API_WINDOWS_DS
@ RTAUDIO_API_WINDOWS_DS
Definition rtaudio_c.h:150
RTAUDIO_API_LINUX_ALSA
@ RTAUDIO_API_LINUX_ALSA
Definition rtaudio_c.h:144
RTAUDIO_API_MACOSX_CORE
@ RTAUDIO_API_MACOSX_CORE
Definition rtaudio_c.h:143
RTAUDIO_API_WINDOWS_WASAPI
@ RTAUDIO_API_WINDOWS_WASAPI
Definition rtaudio_c.h:149
RTAUDIO_API_NUM
@ RTAUDIO_API_NUM
Definition rtaudio_c.h:152
RTAUDIO_API_LINUX_OSS
@ RTAUDIO_API_LINUX_OSS
Definition rtaudio_c.h:147
RTAUDIO_API_UNSPECIFIED
@ RTAUDIO_API_UNSPECIFIED
Definition rtaudio_c.h:142
RTAUDIO_API_UNIX_JACK
@ RTAUDIO_API_UNIX_JACK
Definition rtaudio_c.h:145
RTAUDIO_API_DUMMY
@ RTAUDIO_API_DUMMY
Definition rtaudio_c.h:151
RTAUDIO_API_WINDOWS_ASIO
@ RTAUDIO_API_WINDOWS_ASIO
Definition rtaudio_c.h:148
RTAUDIO_ERROR_NONE
@ RTAUDIO_ERROR_NONE
Definition rtaudio_c.h:116
RTAUDIO_ERROR_INVALID_USE
@ RTAUDIO_ERROR_INVALID_USE
Definition rtaudio_c.h:124
RTAUDIO_ERROR_DEVICE_DISCONNECT
@ RTAUDIO_ERROR_DEVICE_DISCONNECT
Definition rtaudio_c.h:121
RTAUDIO_ERROR_UNKNOWN
@ RTAUDIO_ERROR_UNKNOWN
Definition rtaudio_c.h:118
RTAUDIO_ERROR_MEMORY_ERROR
@ RTAUDIO_ERROR_MEMORY_ERROR
Definition rtaudio_c.h:122
RTAUDIO_ERROR_INVALID_PARAMETER
@ RTAUDIO_ERROR_INVALID_PARAMETER
Definition rtaudio_c.h:123
RTAUDIO_ERROR_THREAD_ERROR
@ RTAUDIO_ERROR_THREAD_ERROR
Definition rtaudio_c.h:127
RTAUDIO_ERROR_WARNING
@ RTAUDIO_ERROR_WARNING
Definition rtaudio_c.h:117
RTAUDIO_ERROR_INVALID_DEVICE
@ RTAUDIO_ERROR_INVALID_DEVICE
Definition rtaudio_c.h:120
RTAUDIO_ERROR_NO_DEVICES_FOUND
@ RTAUDIO_ERROR_NO_DEVICES_FOUND
Definition rtaudio_c.h:119
RTAUDIO_ERROR_DRIVER_ERROR
@ RTAUDIO_ERROR_DRIVER_ERROR
Definition rtaudio_c.h:125
RTAUDIO_ERROR_SYSTEM_ERROR
@ RTAUDIO_ERROR_SYSTEM_ERROR
Definition rtaudio_c.h:126
rtaudio_device_info_t
Definition rtaudio_c.h:161
rtaudio_stream_options_t
Definition rtaudio_c.h:188
rtaudio_stream_parameters_t
Definition rtaudio_c.h:180

| ©2001-2023 Gary P. Scavone, McGill University. All Rights Reserved. Maintained by Gary P. Scavone.