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
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_ERROR_WARNING,
117 RTAUDIO_ERROR_DEBUG_WARNING,
118 RTAUDIO_ERROR_UNSPECIFIED,
119 RTAUDIO_ERROR_NO_DEVICES_FOUND,
120 RTAUDIO_ERROR_INVALID_DEVICE,
121 RTAUDIO_ERROR_MEMORY_ERROR,
122 RTAUDIO_ERROR_INVALID_PARAMETER,
123 RTAUDIO_ERROR_INVALID_USE,
124 RTAUDIO_ERROR_DRIVER_ERROR,
125 RTAUDIO_ERROR_SYSTEM_ERROR,
126 RTAUDIO_ERROR_THREAD_ERROR,
127 } rtaudio_error_t;
128
130
136 typedef void (*rtaudio_error_cb_t)(rtaudio_error_t err, const char *msg);
137
139 typedef enum rtaudio_api {
140 RTAUDIO_API_UNSPECIFIED,
141 RTAUDIO_API_LINUX_ALSA,
142 RTAUDIO_API_LINUX_PULSE,
143 RTAUDIO_API_LINUX_OSS,
144 RTAUDIO_API_UNIX_JACK,
145 RTAUDIO_API_MACOSX_CORE,
146 RTAUDIO_API_WINDOWS_WASAPI,
147 RTAUDIO_API_WINDOWS_ASIO,
148 RTAUDIO_API_WINDOWS_DS,
149 RTAUDIO_API_DUMMY,
150 RTAUDIO_API_NUM,
151 } rtaudio_api_t;
152
153 #define NUM_SAMPLE_RATES 16
154 #define MAX_NAME_LENGTH 512
155
158 typedef struct rtaudio_device_info {
159 int probed;
160 unsigned int output_channels;
161 unsigned int input_channels;
162 unsigned int duplex_channels;
163
164 int is_default_output;
165 int is_default_input;
166
167 rtaudio_format_t native_formats;
168
169 unsigned int preferred_sample_rate;
170 int sample_rates[NUM_SAMPLE_RATES];
171
172 char name[MAX_NAME_LENGTH];
173 } rtaudio_device_info_t;
174
177 typedef struct rtaudio_stream_parameters {
178 unsigned int device_id;
179 unsigned int num_channels;
180 unsigned int first_channel;
181 } rtaudio_stream_parameters_t;
182
185 typedef struct rtaudio_stream_options {
186 rtaudio_stream_flags_t flags;
187 unsigned int num_buffers;
188 int priority;
189 char name[MAX_NAME_LENGTH];
190 } rtaudio_stream_options_t;
191
192 typedef struct rtaudio *rtaudio_t;
193
195 RTAUDIOAPI const char *rtaudio_version(void);
196
200 RTAUDIOAPI unsigned int rtaudio_get_num_compiled_apis(void);
201
206 RTAUDIOAPI const rtaudio_api_t *rtaudio_compiled_api(void);
207
211 RTAUDIOAPI const char *rtaudio_api_name(rtaudio_api_t api);
212
215 RTAUDIOAPI const char *rtaudio_api_display_name(rtaudio_api_t api);
216
219 RTAUDIOAPI rtaudio_api_t rtaudio_compiled_api_by_name(const char *name);
220
221 RTAUDIOAPI const char *rtaudio_error(rtaudio_t audio);
222
224 RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api);
225
227 RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio);
228
231 RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio);
232
235 RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio);
236
239 RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio,
240 int i);
241
244 RTAUDIOAPI unsigned int rtaudio_get_default_output_device(rtaudio_t audio);
245
248 RTAUDIOAPI unsigned int rtaudio_get_default_input_device(rtaudio_t audio);
249
252 RTAUDIOAPI int
253 rtaudio_open_stream(rtaudio_t audio, rtaudio_stream_parameters_t *output_params,
254 rtaudio_stream_parameters_t *input_params,
255 rtaudio_format_t format, unsigned int sample_rate,
256 unsigned int *buffer_frames, rtaudio_cb_t cb,
257 void *userdata, rtaudio_stream_options_t *options,
258 rtaudio_error_cb_t errcb);
259
261 RTAUDIOAPI void rtaudio_close_stream(rtaudio_t audio);
262
264 RTAUDIOAPI int rtaudio_start_stream(rtaudio_t audio);
265
268 RTAUDIOAPI int rtaudio_stop_stream(rtaudio_t audio);
269
272 RTAUDIOAPI int rtaudio_abort_stream(rtaudio_t audio);
273
275 RTAUDIOAPI int rtaudio_is_stream_open(rtaudio_t audio);
276
279 RTAUDIOAPI int rtaudio_is_stream_running(rtaudio_t audio);
280
283 RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio);
284
287 RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time);
288
291 RTAUDIOAPI int rtaudio_get_stream_latency(rtaudio_t audio);
292
295 RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(rtaudio_t audio);
296
299 RTAUDIOAPI void rtaudio_show_warnings(rtaudio_t audio, int show);
300
301 #ifdef __cplusplus
302 }
303 #endif
304 #endif /* RTAUDIO_C_H */
305
RTAUDIO_API_LINUX_PULSE
Definition: rtaudio_c.h:142
RTAUDIO_API_UNSPECIFIED
Definition: rtaudio_c.h:140
rtaudio_show_warnings
RTAUDIOAPI void rtaudio_show_warnings(rtaudio_t audio, int show)
RTAUDIO_API_WINDOWS_DS
Definition: rtaudio_c.h:148
rtaudio_get_num_compiled_apis
RTAUDIOAPI unsigned int rtaudio_get_num_compiled_apis(void)
RTAUDIO_API_NUM
Definition: rtaudio_c.h:150
rtaudio_api_t
rtaudio_api_t
Audio API specifier. See RtAudio::Api.
Definition: rtaudio_c.h:139
RTAUDIO_ERROR_INVALID_USE
Definition: rtaudio_c.h:123
rtaudio_api_name
RTAUDIOAPI const char * rtaudio_api_name(rtaudio_api_t api)
rtaudio_device_count
RTAUDIOAPI int rtaudio_device_count(rtaudio_t audio)
rtaudio_stop_stream
RTAUDIOAPI int rtaudio_stop_stream(rtaudio_t audio)
rtaudio_error_t
rtaudio_error_t
Error codes for RtAudio.
Definition: rtaudio_c.h:115
RTAUDIO_API_WINDOWS_ASIO
Definition: rtaudio_c.h:147
rtaudio_destroy
RTAUDIOAPI void rtaudio_destroy(rtaudio_t audio)
Free an instance of struct rtaudio.
RTAUDIO_ERROR_SYSTEM_ERROR
Definition: rtaudio_c.h:125
RTAUDIO_ERROR_THREAD_ERROR
Definition: rtaudio_c.h:126
rtaudio_start_stream
RTAUDIOAPI int rtaudio_start_stream(rtaudio_t audio)
Starts a stream. See RtAudio::startStream().
rtaudio_create
RTAUDIOAPI rtaudio_t rtaudio_create(rtaudio_api_t api)
Create an instance of struct rtaudio.
RTAUDIO_API_LINUX_OSS
Definition: rtaudio_c.h:143
rtaudio_set_stream_time
RTAUDIOAPI void rtaudio_set_stream_time(rtaudio_t audio, double time)
rtaudio_get_stream_sample_rate
RTAUDIOAPI unsigned int rtaudio_get_stream_sample_rate(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_get_default_input_device
RTAUDIOAPI unsigned int rtaudio_get_default_input_device(rtaudio_t audio)
rtaudio_get_stream_time
RTAUDIOAPI double rtaudio_get_stream_time(rtaudio_t audio)
rtaudio_stream_options_t
Definition: rtaudio_c.h:185
rtaudio_compiled_api
RTAUDIOAPI const rtaudio_api_t * rtaudio_compiled_api(void)
RTAUDIO_ERROR_NO_DEVICES_FOUND
Definition: rtaudio_c.h:119
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_stream_parameters_t
Definition: rtaudio_c.h:177
rtaudio_abort_stream
RTAUDIOAPI int rtaudio_abort_stream(rtaudio_t audio)
RTAUDIO_API_DUMMY
Definition: rtaudio_c.h:149
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_get_stream_latency
RTAUDIOAPI int rtaudio_get_stream_latency(rtaudio_t audio)
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:136
RTAUDIO_ERROR_DEBUG_WARNING
Definition: rtaudio_c.h:117
rtaudio_is_stream_running
RTAUDIOAPI int rtaudio_is_stream_running(rtaudio_t audio)
RTAUDIO_ERROR_INVALID_DEVICE
Definition: rtaudio_c.h:120
RTAUDIO_API_UNIX_JACK
Definition: rtaudio_c.h:144
RTAUDIO_ERROR_WARNING
Definition: rtaudio_c.h:116
rtaudio_api_display_name
RTAUDIOAPI const char * rtaudio_api_display_name(rtaudio_api_t api)
rtaudio_get_default_output_device
RTAUDIOAPI unsigned int rtaudio_get_default_output_device(rtaudio_t audio)
rtaudio_current_api
RTAUDIOAPI rtaudio_api_t rtaudio_current_api(rtaudio_t audio)
RTAUDIO_API_LINUX_ALSA
Definition: rtaudio_c.h:141
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_API_MACOSX_CORE
Definition: rtaudio_c.h:145
RTAUDIO_ERROR_UNSPECIFIED
Definition: rtaudio_c.h:118
RTAUDIO_ERROR_INVALID_PARAMETER
Definition: rtaudio_c.h:122
rtaudio_device_info_t
Definition: rtaudio_c.h:158
rtaudio_get_device_info
RTAUDIOAPI rtaudio_device_info_t rtaudio_get_device_info(rtaudio_t audio, int i)
rtaudio_version
RTAUDIOAPI const char * rtaudio_version(void)
Determine the current RtAudio version. See RtAudio::getVersion().
RTAUDIO_ERROR_MEMORY_ERROR
Definition: rtaudio_c.h:121
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_API_WINDOWS_WASAPI
Definition: rtaudio_c.h:146
rtaudio_stream_status_t
unsigned int rtaudio_stream_status_t
RtAudio stream status (over- or underflow) flags.
Definition: rtaudio_c.h:93
rtaudio_compiled_api_by_name
RTAUDIOAPI rtaudio_api_t rtaudio_compiled_api_by_name(const char *name)
RTAUDIO_ERROR_DRIVER_ERROR
Definition: rtaudio_c.h:124

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