Home Class/Enum List File List Compound Members C interface

rtaudio_c.h
Go to the documentation of this file.
1 /************************************************************************/
13 /************************************************************************/
14
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
33 extern "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 typedef enum rtaudio_error {
116 RTAUDIO_NO_ERROR = -1,
117 RTAUDIO_ERROR_WARNING,
118 RTAUDIO_ERROR_DEBUG_WARNING,
119 RTAUDIO_ERROR_UNSPECIFIED,
120 RTAUDIO_ERROR_NO_DEVICES_FOUND,
121 RTAUDIO_ERROR_INVALID_DEVICE,
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 } rtaudio_error_t;
129
131
137 typedef void (*rtaudio_error_cb_t)(rtaudio_error_t err, const char *msg);
138
140 typedef enum rtaudio_api {
141 RTAUDIO_API_UNSPECIFIED,
142 RTAUDIO_API_LINUX_ALSA,
143 RTAUDIO_API_LINUX_PULSE,
144 RTAUDIO_API_LINUX_OSS,
145 RTAUDIO_API_UNIX_JACK,
146 RTAUDIO_API_MACOSX_CORE,
147 RTAUDIO_API_WINDOWS_WASAPI,
148 RTAUDIO_API_WINDOWS_ASIO,
149 RTAUDIO_API_WINDOWS_DS,
150 RTAUDIO_API_DUMMY,
151 RTAUDIO_API_NUM,
152 } rtaudio_api_t;
153
154 #define NUM_SAMPLE_RATES 16
155 #define MAX_NAME_LENGTH 512
156
159 typedef struct rtaudio_device_info {
160 int probed;
161 unsigned int output_channels;
162 unsigned int input_channels;
163 unsigned int duplex_channels;
164
165 int is_default_output;
166 int is_default_input;
167
168 rtaudio_format_t native_formats;
169
170 unsigned int preferred_sample_rate;
171 int sample_rates[NUM_SAMPLE_RATES];
172
173 char name[MAX_NAME_LENGTH];
174 } rtaudio_device_info_t;
175
178 typedef struct rtaudio_stream_parameters {
179 unsigned int device_id;
180 unsigned int num_channels;
181 unsigned int first_channel;
182 } rtaudio_stream_parameters_t;
183
186 typedef struct rtaudio_stream_options {
187 rtaudio_stream_flags_t flags;
188 unsigned int num_buffers;
189 int priority;
190 char name[MAX_NAME_LENGTH];
191 } rtaudio_stream_options_t;
192
193 typedef struct rtaudio *rtaudio_t;
194
196 RTAUDIOAPI const char *rtaudio_version(void);
197
201 RTAUDIOAPI unsigned int rtaudio_get_num_compiled_apis(void);
202
207 RTAUDIOAPI const rtaudio_api_t *rtaudio_compiled_api(void);
208
212 RTAUDIOAPI const char *rtaudio_api_name(rtaudio_api_t api);
213
216 RTAUDIOAPI const char *rtaudio_api_display_name(rtaudio_api_t api);
217
220 RTAUDIOAPI rtaudio_api_t rtaudio_compiled_api_by_name(const char *name);
221
222 RTAUDIOAPI const char *rtaudio_error(rtaudio_t audio);
223
224 RTAUDIOAPI rtaudio_error_t rtaudio_error_type(rtaudio_t audio);
225
227 RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api);
228
230 RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio);
231
234 RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio);
235
238 RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio);
239
242 RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio,
243 int i);
244
247 RTAUDIOAPI unsigned int rtaudio_get_default_output_device(rtaudio_t audio);
248
251 RTAUDIOAPI unsigned int rtaudio_get_default_input_device(rtaudio_t audio);
252
255 RTAUDIOAPI int
256 rtaudio_open_stream(rtaudio_t audio, rtaudio_stream_parameters_t *output_params,
257 rtaudio_stream_parameters_t *input_params,
258 rtaudio_format_t format, unsigned int sample_rate,
259 unsigned int *buffer_frames, rtaudio_cb_t cb,
260 void *userdata, rtaudio_stream_options_t *options,
261 rtaudio_error_cb_t errcb);
262
264 RTAUDIOAPI void rtaudio_close_stream(rtaudio_t audio);
265
267 RTAUDIOAPI int rtaudio_start_stream(rtaudio_t audio);
268
271 RTAUDIOAPI int rtaudio_stop_stream(rtaudio_t audio);
272
275 RTAUDIOAPI int rtaudio_abort_stream(rtaudio_t audio);
276
278 RTAUDIOAPI int rtaudio_is_stream_open(rtaudio_t audio);
279
282 RTAUDIOAPI int rtaudio_is_stream_running(rtaudio_t audio);
283
286 RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio);
287
290 RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time);
291
294 RTAUDIOAPI int rtaudio_get_stream_latency(rtaudio_t audio);
295
298 RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(rtaudio_t audio);
299
302 RTAUDIOAPI void rtaudio_show_warnings(rtaudio_t audio, int show);
303
304 #ifdef __cplusplus
305 }
306 #endif
307 #endif /* RTAUDIO_C_H */
308
rtaudio_create
RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api)
Create an instance of struct rtaudio.
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:137
rtaudio_start_stream
RTAUDIOAPI int rtaudio_start_stream(rtaudio_t audio)
Starts a stream. See RtAudio::startStream().
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_destroy
RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio)
Free an instance of struct rtaudio.
rtaudio_abort_stream
RTAUDIOAPI int rtaudio_abort_stream(rtaudio_t audio)
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_stream_status_t
unsigned int rtaudio_stream_status_t
RtAudio stream status (over- or underflow) flags.
Definition: rtaudio_c.h:93
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_set_stream_time
RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time)
rtaudio_api_t
rtaudio_api_t
Audio API specifier. See RtAudio::Api.
Definition: rtaudio_c.h:140
rtaudio_error_t
rtaudio_error_t
Error codes for RtAudio.
Definition: rtaudio_c.h:115
rtaudio_open_stream
RTAUDIOAPI int 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_stream_flags_t
unsigned int rtaudio_stream_flags_t
RtAudio stream option flags.
Definition: rtaudio_c.h:71
rtaudio_format_t
unsigned long rtaudio_format_t
RtAudio data format type.
Definition: rtaudio_c.h:48
rtaudio_get_stream_latency
RTAUDIOAPI int rtaudio_get_stream_latency(rtaudio_t audio)
rtaudio_get_device_info
RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio, int i)
rtaudio_get_stream_sample_rate
RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(rtaudio_t audio)
rtaudio_stop_stream
RTAUDIOAPI int rtaudio_stop_stream(rtaudio_t audio)
rtaudio_api_display_name
RTAUDIOAPI const char * rtaudio_api_display_name(rtaudio_api_t api)
rtaudio_current_api
RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio)
rtaudio_device_count
RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio)
rtaudio_get_stream_time
RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio)
rtaudio_api_name
RTAUDIOAPI const char * rtaudio_api_name(rtaudio_api_t api)
rtaudio_version
RTAUDIOAPI const char * rtaudio_version(void)
Determine the current RtAudio version. See RtAudio::getVersion().
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_compiled_api
RTAUDIOAPI const rtaudio_api_t * rtaudio_compiled_api(void)
RTAUDIO_API_LINUX_PULSE
@ RTAUDIO_API_LINUX_PULSE
Definition: rtaudio_c.h:143
RTAUDIO_API_WINDOWS_DS
@ RTAUDIO_API_WINDOWS_DS
Definition: rtaudio_c.h:149
RTAUDIO_API_LINUX_ALSA
@ RTAUDIO_API_LINUX_ALSA
Definition: rtaudio_c.h:142
RTAUDIO_API_MACOSX_CORE
@ RTAUDIO_API_MACOSX_CORE
Definition: rtaudio_c.h:146
RTAUDIO_API_WINDOWS_WASAPI
@ RTAUDIO_API_WINDOWS_WASAPI
Definition: rtaudio_c.h:147
RTAUDIO_API_NUM
@ RTAUDIO_API_NUM
Definition: rtaudio_c.h:151
RTAUDIO_API_LINUX_OSS
@ RTAUDIO_API_LINUX_OSS
Definition: rtaudio_c.h:144
RTAUDIO_API_UNSPECIFIED
@ RTAUDIO_API_UNSPECIFIED
Definition: rtaudio_c.h:141
RTAUDIO_API_UNIX_JACK
@ RTAUDIO_API_UNIX_JACK
Definition: rtaudio_c.h:145
RTAUDIO_API_DUMMY
@ RTAUDIO_API_DUMMY
Definition: rtaudio_c.h:150
RTAUDIO_API_WINDOWS_ASIO
@ RTAUDIO_API_WINDOWS_ASIO
Definition: rtaudio_c.h:148
RTAUDIO_ERROR_INVALID_USE
@ RTAUDIO_ERROR_INVALID_USE
Definition: rtaudio_c.h:124
RTAUDIO_ERROR_DEBUG_WARNING
@ RTAUDIO_ERROR_DEBUG_WARNING
Definition: rtaudio_c.h:118
RTAUDIO_NO_ERROR
@ RTAUDIO_NO_ERROR
Definition: rtaudio_c.h:116
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:121
RTAUDIO_ERROR_NO_DEVICES_FOUND
@ RTAUDIO_ERROR_NO_DEVICES_FOUND
Definition: rtaudio_c.h:120
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_ERROR_UNSPECIFIED
@ RTAUDIO_ERROR_UNSPECIFIED
Definition: rtaudio_c.h:119
rtaudio_device_info_t
Definition: rtaudio_c.h:159
rtaudio_stream_options_t
Definition: rtaudio_c.h:186
rtaudio_stream_parameters_t
Definition: rtaudio_c.h:178

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