use SoundIoError for return type instead of int

closes #116
This commit is contained in:
Andrew Kelley 2016-10-23 18:55:09 -04:00
parent f9ccb19e35
commit 4a8376a704
15 changed files with 152 additions and 150 deletions

View file

@ -359,7 +359,7 @@ struct SoundIo {
/// * #SoundIoErrorSystemResources /// * #SoundIoErrorSystemResources
/// * #SoundIoErrorOpeningDevice - unexpected problem accessing device /// * #SoundIoErrorOpeningDevice - unexpected problem accessing device
/// information /// information
void (*on_backend_disconnect)(struct SoundIo *, int err); void (*on_backend_disconnect)(struct SoundIo *, enum SoundIoError err);
/// Optional callback. Called from an unknown thread that you should not use /// Optional callback. Called from an unknown thread that you should not use
/// to call any soundio functions. You may use this to signal a condition /// to call any soundio functions. You may use this to signal a condition
/// variable to wake up. Called when ::soundio_wait_events would be woken up. /// variable to wake up. Called when ::soundio_wait_events would be woken up.
@ -502,7 +502,7 @@ struct SoundIoDevice {
/// Possible errors: /// Possible errors:
/// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorOpeningDevice
/// * #SoundIoErrorNoMem /// * #SoundIoErrorNoMem
int probe_error; enum SoundIoError probe_error;
}; };
/// The size of this struct is not part of the API or ABI. /// The size of this struct is not part of the API or ABI.
@ -580,7 +580,7 @@ struct SoundIoOutStream {
/// If you do not supply error_callback, the default callback will print /// If you do not supply error_callback, the default callback will print
/// a message to stderr and then call `abort`. /// a message to stderr and then call `abort`.
/// This is called from the SoundIoOutStream::write_callback thread context. /// This is called from the SoundIoOutStream::write_callback thread context.
void (*error_callback)(struct SoundIoOutStream *, int err); void (*error_callback)(struct SoundIoOutStream *, enum SoundIoError err);
/// Optional: Name of the stream. Defaults to "SoundIoOutStream" /// Optional: Name of the stream. Defaults to "SoundIoOutStream"
/// PulseAudio uses this for the stream name. /// PulseAudio uses this for the stream name.
@ -604,7 +604,7 @@ struct SoundIoOutStream {
/// If setting the channel layout fails for some reason, this field is set /// If setting the channel layout fails for some reason, this field is set
/// to an error code. Possible error codes are: /// to an error code. Possible error codes are:
/// * #SoundIoErrorIncompatibleDevice /// * #SoundIoErrorIncompatibleDevice
int layout_error; enum SoundIoError layout_error;
}; };
/// The size of this struct is not part of the API or ABI. /// The size of this struct is not part of the API or ABI.
@ -664,7 +664,7 @@ struct SoundIoInStream {
/// If you do not supply `error_callback`, the default callback will print /// If you do not supply `error_callback`, the default callback will print
/// a message to stderr and then abort(). /// a message to stderr and then abort().
/// This is called from the SoundIoInStream::read_callback thread context. /// This is called from the SoundIoInStream::read_callback thread context.
void (*error_callback)(struct SoundIoInStream *, int err); void (*error_callback)(struct SoundIoInStream *, enum SoundIoError err);
/// Optional: Name of the stream. Defaults to "SoundIoInStream"; /// Optional: Name of the stream. Defaults to "SoundIoInStream";
/// PulseAudio uses this for the stream name. /// PulseAudio uses this for the stream name.
@ -686,7 +686,7 @@ struct SoundIoInStream {
/// If setting the channel layout fails for some reason, this field is set /// If setting the channel layout fails for some reason, this field is set
/// to an error code. Possible error codes are: #SoundIoErrorIncompatibleDevice /// to an error code. Possible error codes are: #SoundIoErrorIncompatibleDevice
int layout_error; enum SoundIoError layout_error;
}; };
/// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch /// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch
@ -713,7 +713,7 @@ SOUNDIO_EXPORT void soundio_destroy(struct SoundIo *soundio);
/// * #SoundIoErrorSystemResources /// * #SoundIoErrorSystemResources
/// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient`
/// See also ::soundio_disconnect /// See also ::soundio_disconnect
SOUNDIO_EXPORT int soundio_connect(struct SoundIo *soundio); SOUNDIO_EXPORT enum SoundIoError soundio_connect(struct SoundIo *soundio);
/// Instead of calling ::soundio_connect you may call this function to try a /// Instead of calling ::soundio_connect you may call this function to try a
/// specific backend. /// specific backend.
/// Possible errors: /// Possible errors:
@ -725,11 +725,11 @@ SOUNDIO_EXPORT int soundio_connect(struct SoundIo *soundio);
/// * #SoundIoErrorInitAudioBackend - requested `backend` is not active /// * #SoundIoErrorInitAudioBackend - requested `backend` is not active
/// * #SoundIoErrorBackendDisconnected - backend disconnected while connecting /// * #SoundIoErrorBackendDisconnected - backend disconnected while connecting
/// See also ::soundio_disconnect /// See also ::soundio_disconnect
SOUNDIO_EXPORT int soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend); SOUNDIO_EXPORT enum SoundIoError soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend);
SOUNDIO_EXPORT void soundio_disconnect(struct SoundIo *soundio); SOUNDIO_EXPORT void soundio_disconnect(struct SoundIo *soundio);
/// Get a string representation of a #SoundIoError /// Get a string representation of a #SoundIoError
SOUNDIO_EXPORT const char *soundio_strerror(int error); SOUNDIO_EXPORT const char *soundio_strerror(enum SoundIoError error);
/// Get a string representation of a #SoundIoBackend /// Get a string representation of a #SoundIoBackend
SOUNDIO_EXPORT const char *soundio_backend_name(enum SoundIoBackend backend); SOUNDIO_EXPORT const char *soundio_backend_name(enum SoundIoBackend backend);
@ -962,7 +962,7 @@ SOUNDIO_EXPORT void soundio_outstream_destroy(struct SoundIoOutStream *outstream
/// greater than the number of channels the backend can handle. /// greater than the number of channels the backend can handle.
/// * #SoundIoErrorIncompatibleDevice - stream parameters requested are not /// * #SoundIoErrorIncompatibleDevice - stream parameters requested are not
/// compatible with the chosen device. /// compatible with the chosen device.
SOUNDIO_EXPORT int soundio_outstream_open(struct SoundIoOutStream *outstream); SOUNDIO_EXPORT enum SoundIoError soundio_outstream_open(struct SoundIoOutStream *outstream);
/// After you call this function, SoundIoOutStream::write_callback will be called. /// After you call this function, SoundIoOutStream::write_callback will be called.
/// ///
@ -973,7 +973,7 @@ SOUNDIO_EXPORT int soundio_outstream_open(struct SoundIoOutStream *outstream);
/// * #SoundIoErrorNoMem /// * #SoundIoErrorNoMem
/// * #SoundIoErrorSystemResources /// * #SoundIoErrorSystemResources
/// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorBackendDisconnected
SOUNDIO_EXPORT int soundio_outstream_start(struct SoundIoOutStream *outstream); SOUNDIO_EXPORT enum SoundIoError soundio_outstream_start(struct SoundIoOutStream *outstream);
/// Call this function when you are ready to begin writing to the device buffer. /// Call this function when you are ready to begin writing to the device buffer.
/// * `outstream` - (in) The output stream you want to write to. /// * `outstream` - (in) The output stream you want to write to.
@ -1005,7 +1005,7 @@ SOUNDIO_EXPORT int soundio_outstream_start(struct SoundIoOutStream *outstream);
/// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now
/// be discovered that the device uses non-byte-aligned access, in which /// be discovered that the device uses non-byte-aligned access, in which
/// case this error code is returned. /// case this error code is returned.
SOUNDIO_EXPORT int soundio_outstream_begin_write(struct SoundIoOutStream *outstream, SOUNDIO_EXPORT enum SoundIoError soundio_outstream_begin_write(struct SoundIoOutStream *outstream,
struct SoundIoChannelArea **areas, int *frame_count); struct SoundIoChannelArea **areas, int *frame_count);
/// Commits the write that you began with ::soundio_outstream_begin_write. /// Commits the write that you began with ::soundio_outstream_begin_write.
@ -1017,7 +1017,7 @@ SOUNDIO_EXPORT int soundio_outstream_begin_write(struct SoundIoOutStream *outstr
/// also get a SoundIoOutStream::underflow_callback, and you might not get /// also get a SoundIoOutStream::underflow_callback, and you might not get
/// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming, /// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming,
/// the outstream is still in a valid state and streaming can continue. /// the outstream is still in a valid state and streaming can continue.
SOUNDIO_EXPORT int soundio_outstream_end_write(struct SoundIoOutStream *outstream); SOUNDIO_EXPORT enum SoundIoError soundio_outstream_end_write(struct SoundIoOutStream *outstream);
/// Clears the output stream buffer. /// Clears the output stream buffer.
/// This function can be called from any thread. /// This function can be called from any thread.
@ -1032,7 +1032,7 @@ SOUNDIO_EXPORT int soundio_outstream_end_write(struct SoundIoOutStream *outstrea
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
/// * #SoundIoErrorIncompatibleBackend /// * #SoundIoErrorIncompatibleBackend
/// * #SoundIoErrorIncompatibleDevice /// * #SoundIoErrorIncompatibleDevice
SOUNDIO_EXPORT int soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream); SOUNDIO_EXPORT enum SoundIoError soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream);
/// If the underlying backend and device support pausing, this pauses the /// If the underlying backend and device support pausing, this pauses the
/// stream. SoundIoOutStream::write_callback may be called a few more times if /// stream. SoundIoOutStream::write_callback may be called a few more times if
@ -1053,7 +1053,7 @@ SOUNDIO_EXPORT int soundio_outstream_clear_buffer(struct SoundIoOutStream *outst
/// * #SoundIoErrorIncompatibleBackend - backend does not support /// * #SoundIoErrorIncompatibleBackend - backend does not support
/// pausing/unpausing. /// pausing/unpausing.
/// * #SoundIoErrorInvalid - outstream not opened and started /// * #SoundIoErrorInvalid - outstream not opened and started
SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause); SOUNDIO_EXPORT enum SoundIoError soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause);
/// Obtain the total number of seconds that the next frame written after the /// Obtain the total number of seconds that the next frame written after the
/// last frame written with ::soundio_outstream_end_write will take to become /// last frame written with ::soundio_outstream_end_write will take to become
@ -1066,7 +1066,7 @@ SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, b
/// ///
/// Possible errors: /// Possible errors:
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
SOUNDIO_EXPORT int soundio_outstream_get_latency(struct SoundIoOutStream *outstream, SOUNDIO_EXPORT enum SoundIoError soundio_outstream_get_latency(struct SoundIoOutStream *outstream,
double *out_latency); double *out_latency);
@ -1098,7 +1098,7 @@ SOUNDIO_EXPORT void soundio_instream_destroy(struct SoundIoInStream *instream);
/// * #SoundIoErrorNoSuchClient /// * #SoundIoErrorNoSuchClient
/// * #SoundIoErrorIncompatibleBackend /// * #SoundIoErrorIncompatibleBackend
/// * #SoundIoErrorIncompatibleDevice /// * #SoundIoErrorIncompatibleDevice
SOUNDIO_EXPORT int soundio_instream_open(struct SoundIoInStream *instream); SOUNDIO_EXPORT enum SoundIoError soundio_instream_open(struct SoundIoInStream *instream);
/// After you call this function, SoundIoInStream::read_callback will be called. /// After you call this function, SoundIoInStream::read_callback will be called.
/// ///
@ -1107,7 +1107,7 @@ SOUNDIO_EXPORT int soundio_instream_open(struct SoundIoInStream *instream);
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
/// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorOpeningDevice
/// * #SoundIoErrorSystemResources /// * #SoundIoErrorSystemResources
SOUNDIO_EXPORT int soundio_instream_start(struct SoundIoInStream *instream); SOUNDIO_EXPORT enum SoundIoError soundio_instream_start(struct SoundIoInStream *instream);
/// Call this function when you are ready to begin reading from the device /// Call this function when you are ready to begin reading from the device
/// buffer. /// buffer.
@ -1138,7 +1138,7 @@ SOUNDIO_EXPORT int soundio_instream_start(struct SoundIoInStream *instream);
/// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now
/// be discovered that the device uses non-byte-aligned access, in which /// be discovered that the device uses non-byte-aligned access, in which
/// case this error code is returned. /// case this error code is returned.
SOUNDIO_EXPORT int soundio_instream_begin_read(struct SoundIoInStream *instream, SOUNDIO_EXPORT enum SoundIoError soundio_instream_begin_read(struct SoundIoInStream *instream,
struct SoundIoChannelArea **areas, int *frame_count); struct SoundIoChannelArea **areas, int *frame_count);
/// This will drop all of the frames from when you called /// This will drop all of the frames from when you called
/// ::soundio_instream_begin_read. /// ::soundio_instream_begin_read.
@ -1148,7 +1148,7 @@ SOUNDIO_EXPORT int soundio_instream_begin_read(struct SoundIoInStream *instream,
/// ///
/// Possible errors: /// Possible errors:
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
SOUNDIO_EXPORT int soundio_instream_end_read(struct SoundIoInStream *instream); SOUNDIO_EXPORT enum SoundIoError soundio_instream_end_read(struct SoundIoInStream *instream);
/// If the underyling device supports pausing, this pauses the stream and /// If the underyling device supports pausing, this pauses the stream and
/// prevents SoundIoInStream::read_callback from being called. Otherwise this returns /// prevents SoundIoInStream::read_callback from being called. Otherwise this returns
@ -1161,7 +1161,7 @@ SOUNDIO_EXPORT int soundio_instream_end_read(struct SoundIoInStream *instream);
/// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorBackendDisconnected
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
/// * #SoundIoErrorIncompatibleDevice - device does not support pausing/unpausing /// * #SoundIoErrorIncompatibleDevice - device does not support pausing/unpausing
SOUNDIO_EXPORT int soundio_instream_pause(struct SoundIoInStream *instream, bool pause); SOUNDIO_EXPORT enum SoundIoError soundio_instream_pause(struct SoundIoInStream *instream, bool pause);
/// Obtain the number of seconds that the next frame of sound being /// Obtain the number of seconds that the next frame of sound being
/// captured will take to arrive in the buffer, plus the amount of time that is /// captured will take to arrive in the buffer, plus the amount of time that is
@ -1171,7 +1171,7 @@ SOUNDIO_EXPORT int soundio_instream_pause(struct SoundIoInStream *instream, bool
/// ///
/// Possible errors: /// Possible errors:
/// * #SoundIoErrorStreaming /// * #SoundIoErrorStreaming
SOUNDIO_EXPORT int soundio_instream_get_latency(struct SoundIoInStream *instream, SOUNDIO_EXPORT enum SoundIoError soundio_instream_get_latency(struct SoundIoInStream *instream,
double *out_latency); double *out_latency);

View file

@ -1276,7 +1276,7 @@ static void instream_thread_run(void *arg) {
} }
} }
static int outstream_open_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_open_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoDevice *device = outstream->device; struct SoundIoDevice *device = outstream->device;
@ -1439,13 +1439,13 @@ static int outstream_open_alsa(struct SoundIoPrivate *si, struct SoundIoOutStrea
return 0; return 0;
} }
static int outstream_start_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_start_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa;
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
assert(!osa->thread); assert(!osa->thread);
int err; enum SoundIoError err;
SOUNDIO_ATOMIC_FLAG_TEST_AND_SET(osa->thread_exit_flag); SOUNDIO_ATOMIC_FLAG_TEST_AND_SET(osa->thread_exit_flag);
if ((err = soundio_os_thread_create(outstream_thread_run, os, soundio->emit_rtprio_warning, &osa->thread))) if ((err = soundio_os_thread_create(outstream_thread_run, os, soundio->emit_rtprio_warning, &osa->thread)))
return err; return err;
@ -1453,7 +1453,7 @@ static int outstream_start_alsa(struct SoundIoPrivate *si, struct SoundIoOutStre
return 0; return 0;
} }
static int outstream_begin_write_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_begin_write_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
*out_areas = NULL; *out_areas = NULL;
@ -1504,7 +1504,7 @@ static int outstream_begin_write_alsa(struct SoundIoPrivate *si, struct SoundIoO
return 0; return 0;
} }
static int outstream_end_write_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_end_write_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -1531,7 +1531,7 @@ static int outstream_end_write_alsa(struct SoundIoPrivate *si, struct SoundIoOut
return 0; return 0;
} }
static int outstream_clear_buffer_alsa(struct SoundIoPrivate *si, static enum SoundIoError outstream_clear_buffer_alsa(struct SoundIoPrivate *si,
struct SoundIoOutStreamPrivate *os) struct SoundIoOutStreamPrivate *os)
{ {
struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; struct SoundIoOutStreamAlsa *osa = &os->backend_data.alsa;
@ -1539,7 +1539,7 @@ static int outstream_clear_buffer_alsa(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int outstream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static enum SoundIoError outstream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
if (!si) if (!si)
return SoundIoErrorInvalid; return SoundIoErrorInvalid;
@ -1560,7 +1560,7 @@ static int outstream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoOutStre
return 0; return 0;
} }
static int outstream_get_latency_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_get_latency_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
double *out_latency) double *out_latency)
{ {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -1600,7 +1600,7 @@ static void instream_destroy_alsa(struct SoundIoPrivate *si, struct SoundIoInStr
isa->sample_buffer = NULL; isa->sample_buffer = NULL;
} }
static int instream_open_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_open_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa; struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoDevice *device = instream->device; struct SoundIoDevice *device = instream->device;
@ -1741,14 +1741,14 @@ static int instream_open_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamP
return 0; return 0;
} }
static int instream_start_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_start_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa; struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa;
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
assert(!isa->thread); assert(!isa->thread);
SOUNDIO_ATOMIC_FLAG_TEST_AND_SET(isa->thread_exit_flag); SOUNDIO_ATOMIC_FLAG_TEST_AND_SET(isa->thread_exit_flag);
int err; enum SoundIoError err;
if ((err = soundio_os_thread_create(instream_thread_run, is, soundio->emit_rtprio_warning, &isa->thread))) { if ((err = soundio_os_thread_create(instream_thread_run, is, soundio->emit_rtprio_warning, &isa->thread))) {
instream_destroy_alsa(si, is); instream_destroy_alsa(si, is);
return err; return err;
@ -1757,7 +1757,7 @@ static int instream_start_alsa(struct SoundIoPrivate *si, struct SoundIoInStream
return 0; return 0;
} }
static int instream_begin_read_alsa(struct SoundIoPrivate *si, static enum SoundIoError instream_begin_read_alsa(struct SoundIoPrivate *si,
struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
*out_areas = NULL; *out_areas = NULL;
@ -1822,7 +1822,7 @@ static int instream_begin_read_alsa(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int instream_end_read_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_end_read_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa; struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa;
if (isa->access == SND_PCM_ACCESS_RW_INTERLEAVED) { if (isa->access == SND_PCM_ACCESS_RW_INTERLEAVED) {
@ -1841,7 +1841,7 @@ static int instream_end_read_alsa(struct SoundIoPrivate *si, struct SoundIoInStr
return 0; return 0;
} }
static int instream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) { static enum SoundIoError instream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa; struct SoundIoInStreamAlsa *isa = &is->backend_data.alsa;
if (isa->is_paused == pause) if (isa->is_paused == pause)
@ -1855,7 +1855,7 @@ static int instream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoInStream
return 0; return 0;
} }
static int instream_get_latency_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, static enum SoundIoError instream_get_latency_alsa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
double *out_latency) double *out_latency)
{ {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
@ -1871,7 +1871,7 @@ static int instream_get_latency_alsa(struct SoundIoPrivate *si, struct SoundIoIn
return 0; return 0;
} }
int soundio_alsa_init(struct SoundIoPrivate *si) { enum SoundIoError soundio_alsa_init(struct SoundIoPrivate *si) {
struct SoundIoAlsa *sia = &si->backend_data.alsa; struct SoundIoAlsa *sia = &si->backend_data.alsa;
int err; int err;

View file

@ -16,7 +16,7 @@
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
struct SoundIoPrivate; struct SoundIoPrivate;
int soundio_alsa_init(struct SoundIoPrivate *si); enum SoundIoError soundio_alsa_init(struct SoundIoPrivate *si);
struct SoundIoDeviceAlsa { int make_the_struct_not_empty; }; struct SoundIoDeviceAlsa { int make_the_struct_not_empty; };

View file

@ -946,7 +946,7 @@ static int set_ca_desc(enum SoundIoFormat fmt, AudioStreamBasicDescription *desc
return 0; return 0;
} }
static int outstream_open_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_open_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio; struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoDevice *device = outstream->device; struct SoundIoDevice *device = outstream->device;
@ -1046,7 +1046,7 @@ static int outstream_open_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamP
return 0; return 0;
} }
static int outstream_pause_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static enum SoundIoError outstream_pause_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio; struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio;
OSStatus os_err; OSStatus os_err;
if (pause) { if (pause) {
@ -1062,11 +1062,11 @@ static int outstream_pause_ca(struct SoundIoPrivate *si, struct SoundIoOutStream
return 0; return 0;
} }
static int outstream_start_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_start_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
return outstream_pause_ca(si, os, false); return outstream_pause_ca(si, os, false);
} }
static int outstream_begin_write_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_begin_write_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -1091,7 +1091,7 @@ static int outstream_begin_write_ca(struct SoundIoPrivate *si, struct SoundIoOut
return 0; return 0;
} }
static int outstream_end_write_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_end_write_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio; struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio;
osca->buffer_index += 1; osca->buffer_index += 1;
osca->frames_left -= osca->write_frame_count; osca->frames_left -= osca->write_frame_count;
@ -1099,11 +1099,11 @@ static int outstream_end_write_ca(struct SoundIoPrivate *si, struct SoundIoOutSt
return 0; return 0;
} }
static int outstream_clear_buffer_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_clear_buffer_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
return SoundIoErrorIncompatibleBackend; return SoundIoErrorIncompatibleBackend;
} }
static int outstream_get_latency_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_get_latency_ca(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
double *out_latency) double *out_latency)
{ {
struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio; struct SoundIoOutStreamCoreAudio *osca = &os->backend_data.coreaudio;
@ -1188,7 +1188,7 @@ static OSStatus read_callback_ca(void *userdata, AudioUnitRenderActionFlags *io_
return noErr; return noErr;
} }
static int instream_open_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_open_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio; struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoDevice *device = instream->device; struct SoundIoDevice *device = instream->device;
@ -1332,7 +1332,7 @@ static int instream_open_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPri
return 0; return 0;
} }
static int instream_pause_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) { static enum SoundIoError instream_pause_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio; struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio;
OSStatus os_err; OSStatus os_err;
if (pause) { if (pause) {
@ -1348,11 +1348,11 @@ static int instream_pause_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPr
return 0; return 0;
} }
static int instream_start_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_start_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
return instream_pause_ca(si, is, false); return instream_pause_ca(si, is, false);
} }
static int instream_begin_read_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, static enum SoundIoError instream_begin_read_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio; struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio;
@ -1365,13 +1365,13 @@ static int instream_begin_read_ca(struct SoundIoPrivate *si, struct SoundIoInStr
return 0; return 0;
} }
static int instream_end_read_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_end_read_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio; struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio;
isca->frames_left = 0; isca->frames_left = 0;
return 0; return 0;
} }
static int instream_get_latency_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, static enum SoundIoError instream_get_latency_ca(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
double *out_latency) double *out_latency)
{ {
struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio; struct SoundIoInStreamCoreAudio *isca = &is->backend_data.coreaudio;
@ -1380,7 +1380,7 @@ static int instream_get_latency_ca(struct SoundIoPrivate *si, struct SoundIoInSt
} }
int soundio_coreaudio_init(struct SoundIoPrivate *si) { enum SoundIoError soundio_coreaudio_init(struct SoundIoPrivate *si) {
struct SoundIoCoreAudio *sica = &si->backend_data.coreaudio; struct SoundIoCoreAudio *sica = &si->backend_data.coreaudio;
int err; int err;

View file

@ -17,7 +17,7 @@
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
struct SoundIoPrivate; struct SoundIoPrivate;
int soundio_coreaudio_init(struct SoundIoPrivate *si); enum SoundIoError soundio_coreaudio_init(struct SoundIoPrivate *si);
struct SoundIoDeviceCoreAudio { struct SoundIoDeviceCoreAudio {
AudioDeviceID device_id; AudioDeviceID device_id;

View file

@ -172,7 +172,7 @@ static void outstream_destroy_dummy(struct SoundIoPrivate *si, struct SoundIoOut
soundio_ring_buffer_deinit(&osd->ring_buffer); soundio_ring_buffer_deinit(&osd->ring_buffer);
} }
static int outstream_open_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_open_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoDevice *device = outstream->device; struct SoundIoDevice *device = outstream->device;
@ -187,7 +187,7 @@ static int outstream_open_dummy(struct SoundIoPrivate *si, struct SoundIoOutStre
osd->period_duration = outstream->software_latency / 2.0; osd->period_duration = outstream->software_latency / 2.0;
int err; enum SoundIoError err;
int buffer_size = outstream->bytes_per_frame * outstream->sample_rate * outstream->software_latency; int buffer_size = outstream->bytes_per_frame * outstream->sample_rate * outstream->software_latency;
if ((err = soundio_ring_buffer_init(&osd->ring_buffer, buffer_size))) { if ((err = soundio_ring_buffer_init(&osd->ring_buffer, buffer_size))) {
outstream_destroy_dummy(si, os); outstream_destroy_dummy(si, os);
@ -206,13 +206,15 @@ static int outstream_open_dummy(struct SoundIoPrivate *si, struct SoundIoOutStre
return 0; return 0;
} }
static int outstream_pause_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static enum SoundIoError outstream_pause_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
bool pause)
{
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
SOUNDIO_ATOMIC_STORE(osd->pause_requested, pause); SOUNDIO_ATOMIC_STORE(osd->pause_requested, pause);
return 0; return SoundIoErrorNone;
} }
static int outstream_start_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_start_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
assert(!osd->thread); assert(!osd->thread);
@ -223,10 +225,10 @@ static int outstream_start_dummy(struct SoundIoPrivate *si, struct SoundIoOutStr
{ {
return err; return err;
} }
return 0; return SoundIoErrorNone;
} }
static int outstream_begin_write_dummy(struct SoundIoPrivate *si, static enum SoundIoError outstream_begin_write_dummy(struct SoundIoPrivate *si,
struct SoundIoOutStreamPrivate *os, struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoOutStreamPrivate *os, struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -243,32 +245,32 @@ static int outstream_begin_write_dummy(struct SoundIoPrivate *si,
osd->write_frame_count = *frame_count; osd->write_frame_count = *frame_count;
*out_areas = osd->areas; *out_areas = osd->areas;
return 0; return SoundIoErrorNone;
} }
static int outstream_end_write_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_end_write_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
int byte_count = osd->write_frame_count * outstream->bytes_per_frame; int byte_count = osd->write_frame_count * outstream->bytes_per_frame;
soundio_ring_buffer_advance_write_ptr(&osd->ring_buffer, byte_count); soundio_ring_buffer_advance_write_ptr(&osd->ring_buffer, byte_count);
osd->frames_left -= osd->write_frame_count; osd->frames_left -= osd->write_frame_count;
return 0; return SoundIoErrorNone;
} }
static int outstream_clear_buffer_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_clear_buffer_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
SOUNDIO_ATOMIC_FLAG_CLEAR(osd->clear_buffer_flag); SOUNDIO_ATOMIC_FLAG_CLEAR(osd->clear_buffer_flag);
soundio_os_cond_signal(osd->cond, NULL); soundio_os_cond_signal(osd->cond, NULL);
return 0; return SoundIoErrorNone;
} }
static int outstream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, double *out_latency) { static enum SoundIoError outstream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, double *out_latency) {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy; struct SoundIoOutStreamDummy *osd = &os->backend_data.dummy;
int fill_bytes = soundio_ring_buffer_fill_count(&osd->ring_buffer); int fill_bytes = soundio_ring_buffer_fill_count(&osd->ring_buffer);
*out_latency = (fill_bytes / outstream->bytes_per_frame) / (double)outstream->sample_rate; *out_latency = (fill_bytes / outstream->bytes_per_frame) / (double)outstream->sample_rate;
return 0; return SoundIoErrorNone;
} }
static void instream_destroy_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static void instream_destroy_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
@ -286,7 +288,7 @@ static void instream_destroy_dummy(struct SoundIoPrivate *si, struct SoundIoInSt
soundio_ring_buffer_deinit(&isd->ring_buffer); soundio_ring_buffer_deinit(&isd->ring_buffer);
} }
static int instream_open_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_open_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamDummy *isd = &is->backend_data.dummy; struct SoundIoInStreamDummy *isd = &is->backend_data.dummy;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoDevice *device = instream->device; struct SoundIoDevice *device = instream->device;
@ -321,13 +323,13 @@ static int instream_open_dummy(struct SoundIoPrivate *si, struct SoundIoInStream
return 0; return 0;
} }
static int instream_pause_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) { static enum SoundIoError instream_pause_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
struct SoundIoInStreamDummy *isd = &is->backend_data.dummy; struct SoundIoInStreamDummy *isd = &is->backend_data.dummy;
SOUNDIO_ATOMIC_STORE(isd->pause_requested, pause); SOUNDIO_ATOMIC_STORE(isd->pause_requested, pause);
return 0; return 0;
} }
static int instream_start_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_start_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamDummy *isd = &is->backend_data.dummy; struct SoundIoInStreamDummy *isd = &is->backend_data.dummy;
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
assert(!isd->thread); assert(!isd->thread);
@ -341,7 +343,7 @@ static int instream_start_dummy(struct SoundIoPrivate *si, struct SoundIoInStrea
return 0; return 0;
} }
static int instream_begin_read_dummy(struct SoundIoPrivate *si, static enum SoundIoError instream_begin_read_dummy(struct SoundIoPrivate *si,
struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
@ -361,7 +363,7 @@ static int instream_begin_read_dummy(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int instream_end_read_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_end_read_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamDummy *isd = &is->backend_data.dummy; struct SoundIoInStreamDummy *isd = &is->backend_data.dummy;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
int byte_count = isd->read_frame_count * instream->bytes_per_frame; int byte_count = isd->read_frame_count * instream->bytes_per_frame;
@ -370,7 +372,7 @@ static int instream_end_read_dummy(struct SoundIoPrivate *si, struct SoundIoInSt
return 0; return 0;
} }
static int instream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, double *out_latency) { static enum SoundIoError instream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, double *out_latency) {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoInStreamDummy *osd = &is->backend_data.dummy; struct SoundIoInStreamDummy *osd = &is->backend_data.dummy;
int fill_bytes = soundio_ring_buffer_fill_count(&osd->ring_buffer); int fill_bytes = soundio_ring_buffer_fill_count(&osd->ring_buffer);
@ -379,7 +381,7 @@ static int instream_get_latency_dummy(struct SoundIoPrivate *si, struct SoundIoI
return 0; return 0;
} }
static int set_all_device_formats(struct SoundIoDevice *device) { static enum SoundIoError set_all_device_formats(struct SoundIoDevice *device) {
device->format_count = 22; device->format_count = 22;
device->formats = ALLOCATE(enum SoundIoFormat, device->format_count); device->formats = ALLOCATE(enum SoundIoFormat, device->format_count);
if (!device->formats) if (!device->formats)
@ -419,7 +421,7 @@ static void set_all_device_sample_rates(struct SoundIoDevice *device) {
device->sample_rates[0].max = SOUNDIO_MAX_SAMPLE_RATE; device->sample_rates[0].max = SOUNDIO_MAX_SAMPLE_RATE;
} }
static int set_all_device_channel_layouts(struct SoundIoDevice *device) { static enum SoundIoError set_all_device_channel_layouts(struct SoundIoDevice *device) {
device->layout_count = soundio_channel_layout_builtin_count(); device->layout_count = soundio_channel_layout_builtin_count();
device->layouts = ALLOCATE(struct SoundIoChannelLayout, device->layout_count); device->layouts = ALLOCATE(struct SoundIoChannelLayout, device->layout_count);
if (!device->layouts) if (!device->layouts)
@ -429,7 +431,7 @@ static int set_all_device_channel_layouts(struct SoundIoDevice *device) {
return 0; return 0;
} }
int soundio_dummy_init(struct SoundIoPrivate *si) { enum SoundIoError soundio_dummy_init(struct SoundIoPrivate *si) {
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
struct SoundIoDummy *sid = &si->backend_data.dummy; struct SoundIoDummy *sid = &si->backend_data.dummy;

View file

@ -14,7 +14,7 @@
#include "atomics.h" #include "atomics.h"
struct SoundIoPrivate; struct SoundIoPrivate;
int soundio_dummy_init(struct SoundIoPrivate *si); enum SoundIoError soundio_dummy_init(struct SoundIoPrivate *si);
struct SoundIoDummy { struct SoundIoDummy {
struct SoundIoOsMutex *mutex; struct SoundIoOsMutex *mutex;

View file

@ -425,7 +425,7 @@ static inline jack_nframes_t nframes_max(jack_nframes_t a, jack_nframes_t b) {
return (a >= b) ? a : b; return (a >= b) ? a : b;
} }
static int outstream_open_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_open_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
struct SoundIoOutStreamJack *osj = &os->backend_data.jack; struct SoundIoOutStreamJack *osj = &os->backend_data.jack;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -454,7 +454,7 @@ static int outstream_open_jack(struct SoundIoPrivate *si, struct SoundIoOutStrea
return SoundIoErrorOpeningDevice; return SoundIoErrorOpeningDevice;
} }
int err; enum SoundIoError err;
if ((err = jack_set_process_callback(osj->client, outstream_process_callback, os))) { if ((err = jack_set_process_callback(osj->client, outstream_process_callback, os))) {
outstream_destroy_jack(si, os); outstream_destroy_jack(si, os);
return SoundIoErrorOpeningDevice; return SoundIoErrorOpeningDevice;
@ -521,7 +521,7 @@ static int outstream_open_jack(struct SoundIoPrivate *si, struct SoundIoOutStrea
return 0; return 0;
} }
static int outstream_pause_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static enum SoundIoError outstream_pause_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
if (sij->is_shutdown) if (sij->is_shutdown)
@ -530,11 +530,11 @@ static int outstream_pause_jack(struct SoundIoPrivate *si, struct SoundIoOutStre
return SoundIoErrorIncompatibleBackend; return SoundIoErrorIncompatibleBackend;
} }
static int outstream_start_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_start_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamJack *osj = &os->backend_data.jack; struct SoundIoOutStreamJack *osj = &os->backend_data.jack;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
int err; enum SoundIoError err;
if (sij->is_shutdown) if (sij->is_shutdown)
return SoundIoErrorBackendDisconnected; return SoundIoErrorBackendDisconnected;
@ -556,7 +556,7 @@ static int outstream_start_jack(struct SoundIoPrivate *si, struct SoundIoOutStre
return 0; return 0;
} }
static int outstream_begin_write_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_begin_write_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoOutStreamJack *osj = &os->backend_data.jack; struct SoundIoOutStreamJack *osj = &os->backend_data.jack;
@ -569,17 +569,17 @@ static int outstream_begin_write_jack(struct SoundIoPrivate *si, struct SoundIoO
return 0; return 0;
} }
static int outstream_end_write_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_end_write_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamJack *osj = &os->backend_data.jack; struct SoundIoOutStreamJack *osj = &os->backend_data.jack;
osj->frames_left = 0; osj->frames_left = 0;
return 0; return 0;
} }
static int outstream_clear_buffer_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_clear_buffer_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
return SoundIoErrorIncompatibleBackend; return SoundIoErrorIncompatibleBackend;
} }
static int outstream_get_latency_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, static enum SoundIoError outstream_get_latency_jack(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os,
double *out_latency) double *out_latency)
{ {
struct SoundIoOutStreamJack *osj = &os->backend_data.jack; struct SoundIoOutStreamJack *osj = &os->backend_data.jack;
@ -646,7 +646,7 @@ static int instream_process_callback(jack_nframes_t nframes, void *arg) {
return 0; return 0;
} }
static int instream_open_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_open_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoInStreamJack *isj = &is->backend_data.jack; struct SoundIoInStreamJack *isj = &is->backend_data.jack;
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
@ -675,7 +675,7 @@ static int instream_open_jack(struct SoundIoPrivate *si, struct SoundIoInStreamP
return SoundIoErrorOpeningDevice; return SoundIoErrorOpeningDevice;
} }
int err; enum SoundIoError err;
if ((err = jack_set_process_callback(isj->client, instream_process_callback, is))) { if ((err = jack_set_process_callback(isj->client, instream_process_callback, is))) {
instream_destroy_jack(si, is); instream_destroy_jack(si, is);
return SoundIoErrorOpeningDevice; return SoundIoErrorOpeningDevice;
@ -741,7 +741,7 @@ static int instream_open_jack(struct SoundIoPrivate *si, struct SoundIoInStreamP
return 0; return 0;
} }
static int instream_pause_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) { static enum SoundIoError instream_pause_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
if (sij->is_shutdown) if (sij->is_shutdown)
@ -750,11 +750,11 @@ static int instream_pause_jack(struct SoundIoPrivate *si, struct SoundIoInStream
return SoundIoErrorIncompatibleBackend; return SoundIoErrorIncompatibleBackend;
} }
static int instream_start_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_start_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamJack *isj = &is->backend_data.jack; struct SoundIoInStreamJack *isj = &is->backend_data.jack;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
int err; enum SoundIoError err;
if (sij->is_shutdown) if (sij->is_shutdown)
return SoundIoErrorBackendDisconnected; return SoundIoErrorBackendDisconnected;
@ -776,7 +776,7 @@ static int instream_start_jack(struct SoundIoPrivate *si, struct SoundIoInStream
return 0; return 0;
} }
static int instream_begin_read_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, static enum SoundIoError instream_begin_read_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoInStreamJack *isj = &is->backend_data.jack; struct SoundIoInStreamJack *isj = &is->backend_data.jack;
@ -789,13 +789,13 @@ static int instream_begin_read_jack(struct SoundIoPrivate *si, struct SoundIoInS
return 0; return 0;
} }
static int instream_end_read_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_end_read_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamJack *isj = &is->backend_data.jack; struct SoundIoInStreamJack *isj = &is->backend_data.jack;
isj->frames_left = 0; isj->frames_left = 0;
return 0; return 0;
} }
static int instream_get_latency_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, static enum SoundIoError instream_get_latency_jack(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is,
double *out_latency) double *out_latency)
{ {
struct SoundIoInStreamJack *isj = &is->backend_data.jack; struct SoundIoInStreamJack *isj = &is->backend_data.jack;
@ -865,7 +865,7 @@ static void destroy_jack(struct SoundIoPrivate *si) {
soundio_os_mutex_destroy(sij->mutex); soundio_os_mutex_destroy(sij->mutex);
} }
int soundio_jack_init(struct SoundIoPrivate *si) { enum SoundIoError soundio_jack_init(struct SoundIoPrivate *si) {
struct SoundIoJack *sij = &si->backend_data.jack; struct SoundIoJack *sij = &si->backend_data.jack;
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;

View file

@ -20,7 +20,7 @@
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
struct SoundIoPrivate; struct SoundIoPrivate;
int soundio_jack_init(struct SoundIoPrivate *si); enum SoundIoError soundio_jack_init(struct SoundIoPrivate *si);
struct SoundIoDeviceJackPort { struct SoundIoDeviceJackPort {
char *full_name; char *full_name;

View file

@ -661,7 +661,7 @@ static void timing_update_callback(pa_stream *stream, int success, void *userdat
pa_threaded_mainloop_signal(sipa->main_loop, 0); pa_threaded_mainloop_signal(sipa->main_loop, 0);
} }
static int outstream_open_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_open_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -737,7 +737,7 @@ static int outstream_open_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamP
return 0; return 0;
} }
static int outstream_start_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_start_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
@ -763,7 +763,7 @@ static int outstream_start_pa(struct SoundIoPrivate *si, struct SoundIoOutStream
return 0; return 0;
} }
static int outstream_begin_write_pa(struct SoundIoPrivate *si, static enum SoundIoError outstream_begin_write_pa(struct SoundIoPrivate *si,
struct SoundIoOutStreamPrivate *os, struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoOutStreamPrivate *os, struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoOutStream *outstream = &os->pub; struct SoundIoOutStream *outstream = &os->pub;
@ -785,7 +785,7 @@ static int outstream_begin_write_pa(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int outstream_end_write_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) { static enum SoundIoError outstream_end_write_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os) {
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
pa_stream *stream = ospa->stream; pa_stream *stream = ospa->stream;
@ -796,7 +796,7 @@ static int outstream_end_write_pa(struct SoundIoPrivate *si, struct SoundIoOutSt
return 0; return 0;
} }
static int outstream_clear_buffer_pa(struct SoundIoPrivate *si, static enum SoundIoError outstream_clear_buffer_pa(struct SoundIoPrivate *si,
struct SoundIoOutStreamPrivate *os) struct SoundIoOutStreamPrivate *os)
{ {
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
@ -804,7 +804,7 @@ static int outstream_clear_buffer_pa(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int outstream_pause_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static enum SoundIoError outstream_pause_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
@ -828,7 +828,7 @@ static int outstream_pause_pa(struct SoundIoPrivate *si, struct SoundIoOutStream
return 0; return 0;
} }
static int outstream_get_latency_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, double *out_latency) { static enum SoundIoError outstream_get_latency_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, double *out_latency) {
struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio; struct SoundIoOutStreamPulseAudio *ospa = &os->backend_data.pulseaudio;
int err; int err;
@ -890,7 +890,7 @@ static void instream_destroy_pa(struct SoundIoPrivate *si, struct SoundIoInStrea
} }
} }
static int instream_open_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_open_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio; struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
@ -941,7 +941,7 @@ static int instream_open_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPri
return 0; return 0;
} }
static int instream_start_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_start_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio; struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
@ -971,7 +971,7 @@ static int instream_start_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPr
return 0; return 0;
} }
static int instream_begin_read_pa(struct SoundIoPrivate *si, static enum SoundIoError instream_begin_read_pa(struct SoundIoPrivate *si,
struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count) struct SoundIoInStreamPrivate *is, struct SoundIoChannelArea **out_areas, int *frame_count)
{ {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
@ -1007,7 +1007,7 @@ static int instream_begin_read_pa(struct SoundIoPrivate *si,
return 0; return 0;
} }
static int instream_end_read_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) { static enum SoundIoError instream_end_read_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is) {
struct SoundIoInStream *instream = &is->pub; struct SoundIoInStream *instream = &is->pub;
struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio; struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
pa_stream *stream = ispa->stream; pa_stream *stream = ispa->stream;
@ -1032,7 +1032,7 @@ static int instream_end_read_pa(struct SoundIoPrivate *si, struct SoundIoInStrea
return 0; return 0;
} }
static int instream_pause_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) { static enum SoundIoError instream_pause_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, bool pause) {
struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio; struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
@ -1054,7 +1054,7 @@ static int instream_pause_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPr
return 0; return 0;
} }
static int instream_get_latency_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, double *out_latency) { static enum SoundIoError instream_get_latency_pa(struct SoundIoPrivate *si, struct SoundIoInStreamPrivate *is, double *out_latency) {
struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio; struct SoundIoInStreamPulseAudio *ispa = &is->backend_data.pulseaudio;
int err; int err;
@ -1067,7 +1067,7 @@ static int instream_get_latency_pa(struct SoundIoPrivate *si, struct SoundIoInSt
return 0; return 0;
} }
int soundio_pulseaudio_init(struct SoundIoPrivate *si) { enum SoundIoError soundio_pulseaudio_init(struct SoundIoPrivate *si) {
struct SoundIo *soundio = &si->pub; struct SoundIo *soundio = &si->pub;
struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio; struct SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;

View file

@ -14,7 +14,7 @@
#include <pulse/pulseaudio.h> #include <pulse/pulseaudio.h>
struct SoundIoPrivate; struct SoundIoPrivate;
int soundio_pulseaudio_init(struct SoundIoPrivate *si); enum SoundIoError soundio_pulseaudio_init(struct SoundIoPrivate *si);
struct SoundIoDevicePulseAudio { int make_the_struct_not_empty; }; struct SoundIoDevicePulseAudio { int make_the_struct_not_empty; };

View file

@ -33,7 +33,7 @@ static const enum SoundIoBackend available_backends[] = {
SoundIoBackendDummy, SoundIoBackendDummy,
}; };
typedef int (*backend_init_t)(struct SoundIoPrivate *); typedef enum SoundIoError (*backend_init_t)(struct SoundIoPrivate *);
static backend_init_t backend_init_fns[] = { static backend_init_t backend_init_fns[] = {
NULL, // None backend NULL, // None backend
@ -73,8 +73,8 @@ static backend_init_t backend_init_fns[] = {
SOUNDIO_MAKE_LIST_DEF(struct SoundIoDevice*, SoundIoListDevicePtr, SOUNDIO_LIST_NOT_STATIC) SOUNDIO_MAKE_LIST_DEF(struct SoundIoDevice*, SoundIoListDevicePtr, SOUNDIO_LIST_NOT_STATIC)
SOUNDIO_MAKE_LIST_DEF(struct SoundIoSampleRateRange, SoundIoListSampleRateRange, SOUNDIO_LIST_NOT_STATIC) SOUNDIO_MAKE_LIST_DEF(struct SoundIoSampleRateRange, SoundIoListSampleRateRange, SOUNDIO_LIST_NOT_STATIC)
const char *soundio_strerror(int error) { const char *soundio_strerror(enum SoundIoError error) {
switch ((enum SoundIoError)error) { switch (error) {
case SoundIoErrorNone: return "(no error)"; case SoundIoErrorNone: return "(no error)";
case SoundIoErrorNoMem: return "out of memory"; case SoundIoErrorNoMem: return "out of memory";
case SoundIoErrorInitAudioBackend: return "unable to initialize audio backend"; case SoundIoErrorInitAudioBackend: return "unable to initialize audio backend";
@ -181,7 +181,7 @@ void soundio_destroy(struct SoundIo *soundio) {
static void do_nothing_cb(struct SoundIo *soundio) { } static void do_nothing_cb(struct SoundIo *soundio) { }
static void default_msg_callback(const char *msg) { } static void default_msg_callback(const char *msg) { }
static void default_backend_disconnect_cb(struct SoundIo *soundio, int err) { static void default_backend_disconnect_cb(struct SoundIo *soundio, enum SoundIoError err) {
soundio_panic("libsoundio: backend disconnected: %s", soundio_strerror(err)); soundio_panic("libsoundio: backend disconnected: %s", soundio_strerror(err));
} }
@ -195,7 +195,7 @@ static void default_emit_rtprio_warning(void) {
} }
struct SoundIo *soundio_create(void) { struct SoundIo *soundio_create(void) {
int err; enum SoundIoError err;
if ((err = soundio_os_init())) if ((err = soundio_os_init()))
return NULL; return NULL;
struct SoundIoPrivate *si = ALLOCATE(struct SoundIoPrivate, 1); struct SoundIoPrivate *si = ALLOCATE(struct SoundIoPrivate, 1);
@ -212,7 +212,7 @@ struct SoundIo *soundio_create(void) {
return soundio; return soundio;
} }
int soundio_connect(struct SoundIo *soundio) { enum SoundIoError soundio_connect(struct SoundIo *soundio) {
int err = 0; int err = 0;
for (int i = 0; i < ARRAY_LENGTH(available_backends); i += 1) { for (int i = 0; i < ARRAY_LENGTH(available_backends); i += 1) {
@ -227,7 +227,7 @@ int soundio_connect(struct SoundIo *soundio) {
return err; return err;
} }
int soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend) { enum SoundIoError soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend) {
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
if (soundio->current_backend) if (soundio->current_backend)
@ -236,7 +236,7 @@ int soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend
if (backend <= 0 || backend > SoundIoBackendDummy) if (backend <= 0 || backend > SoundIoBackendDummy)
return SoundIoErrorInvalid; return SoundIoErrorInvalid;
int (*fn)(struct SoundIoPrivate *) = backend_init_fns[backend]; enum SoundIoError (*fn)(struct SoundIoPrivate *) = backend_init_fns[backend];
if (!fn) if (!fn)
return SoundIoErrorBackendUnavailable; return SoundIoErrorBackendUnavailable;
@ -446,7 +446,7 @@ void soundio_force_device_scan(struct SoundIo *soundio) {
si->force_device_scan(si); si->force_device_scan(si);
} }
int soundio_outstream_begin_write(struct SoundIoOutStream *outstream, enum SoundIoError soundio_outstream_begin_write(struct SoundIoOutStream *outstream,
struct SoundIoChannelArea **areas, int *frame_count) struct SoundIoChannelArea **areas, int *frame_count)
{ {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
@ -457,14 +457,14 @@ int soundio_outstream_begin_write(struct SoundIoOutStream *outstream,
return si->outstream_begin_write(si, os, areas, frame_count); return si->outstream_begin_write(si, os, areas, frame_count);
} }
int soundio_outstream_end_write(struct SoundIoOutStream *outstream) { enum SoundIoError soundio_outstream_end_write(struct SoundIoOutStream *outstream) {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream; struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream;
return si->outstream_end_write(si, os); return si->outstream_end_write(si, os);
} }
static void default_outstream_error_callback(struct SoundIoOutStream *os, int err) { static void default_outstream_error_callback(struct SoundIoOutStream *os, enum SoundIoError err) {
soundio_panic("libsoundio: %s", soundio_strerror(err)); soundio_panic("libsoundio: %s", soundio_strerror(err));
} }
@ -488,7 +488,7 @@ struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device)
return outstream; return outstream;
} }
int soundio_outstream_open(struct SoundIoOutStream *outstream) { enum SoundIoError soundio_outstream_open(struct SoundIoOutStream *outstream) {
struct SoundIoDevice *device = outstream->device; struct SoundIoDevice *device = outstream->device;
if (device->aim != SoundIoDeviceAimOutput) if (device->aim != SoundIoDeviceAimOutput)
@ -540,35 +540,35 @@ void soundio_outstream_destroy(struct SoundIoOutStream *outstream) {
free(os); free(os);
} }
int soundio_outstream_start(struct SoundIoOutStream *outstream) { enum SoundIoError soundio_outstream_start(struct SoundIoOutStream *outstream) {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream; struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream;
return si->outstream_start(si, os); return si->outstream_start(si, os);
} }
int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause) { enum SoundIoError soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause) {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream; struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream;
return si->outstream_pause(si, os, pause); return si->outstream_pause(si, os, pause);
} }
int soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream) { enum SoundIoError soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream) {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream; struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream;
return si->outstream_clear_buffer(si, os); return si->outstream_clear_buffer(si, os);
} }
int soundio_outstream_get_latency(struct SoundIoOutStream *outstream, double *out_latency) { enum SoundIoError soundio_outstream_get_latency(struct SoundIoOutStream *outstream, double *out_latency) {
struct SoundIo *soundio = outstream->device->soundio; struct SoundIo *soundio = outstream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream; struct SoundIoOutStreamPrivate *os = (struct SoundIoOutStreamPrivate *)outstream;
return si->outstream_get_latency(si, os, out_latency); return si->outstream_get_latency(si, os, out_latency);
} }
static void default_instream_error_callback(struct SoundIoInStream *is, int err) { static void default_instream_error_callback(struct SoundIoInStream *is, enum SoundIoError err) {
soundio_panic("libsoundio: %s", soundio_strerror(err)); soundio_panic("libsoundio: %s", soundio_strerror(err));
} }
@ -592,7 +592,7 @@ struct SoundIoInStream *soundio_instream_create(struct SoundIoDevice *device) {
return instream; return instream;
} }
int soundio_instream_open(struct SoundIoInStream *instream) { enum SoundIoError soundio_instream_open(struct SoundIoInStream *instream) {
struct SoundIoDevice *device = instream->device; struct SoundIoDevice *device = instream->device;
if (device->aim != SoundIoDeviceAimInput) if (device->aim != SoundIoDeviceAimInput)
return SoundIoErrorInvalid; return SoundIoErrorInvalid;
@ -628,7 +628,7 @@ int soundio_instream_open(struct SoundIoInStream *instream) {
return si->instream_open(si, is); return si->instream_open(si, is);
} }
int soundio_instream_start(struct SoundIoInStream *instream) { enum SoundIoError soundio_instream_start(struct SoundIoInStream *instream) {
struct SoundIo *soundio = instream->device->soundio; struct SoundIo *soundio = instream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream; struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream;
@ -650,14 +650,14 @@ void soundio_instream_destroy(struct SoundIoInStream *instream) {
free(is); free(is);
} }
int soundio_instream_pause(struct SoundIoInStream *instream, bool pause) { enum SoundIoError soundio_instream_pause(struct SoundIoInStream *instream, bool pause) {
struct SoundIo *soundio = instream->device->soundio; struct SoundIo *soundio = instream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream; struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream;
return si->instream_pause(si, is, pause); return si->instream_pause(si, is, pause);
} }
int soundio_instream_begin_read(struct SoundIoInStream *instream, enum SoundIoError soundio_instream_begin_read(struct SoundIoInStream *instream,
struct SoundIoChannelArea **areas, int *frame_count) struct SoundIoChannelArea **areas, int *frame_count)
{ {
struct SoundIo *soundio = instream->device->soundio; struct SoundIo *soundio = instream->device->soundio;
@ -666,14 +666,14 @@ int soundio_instream_begin_read(struct SoundIoInStream *instream,
return si->instream_begin_read(si, is, areas, frame_count); return si->instream_begin_read(si, is, areas, frame_count);
} }
int soundio_instream_end_read(struct SoundIoInStream *instream) { enum SoundIoError soundio_instream_end_read(struct SoundIoInStream *instream) {
struct SoundIo *soundio = instream->device->soundio; struct SoundIo *soundio = instream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream; struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream;
return si->instream_end_read(si, is); return si->instream_end_read(si, is);
} }
int soundio_instream_get_latency(struct SoundIoInStream *instream, double *out_latency) { enum SoundIoError soundio_instream_get_latency(struct SoundIoInStream *instream, double *out_latency) {
struct SoundIo *soundio = instream->device->soundio; struct SoundIo *soundio = instream->device->soundio;
struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio; struct SoundIoPrivate *si = (struct SoundIoPrivate *)soundio;
struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream; struct SoundIoInStreamPrivate *is = (struct SoundIoInStreamPrivate *)instream;

View file

@ -143,25 +143,25 @@ struct SoundIoPrivate {
void (*wakeup)(struct SoundIoPrivate *); void (*wakeup)(struct SoundIoPrivate *);
void (*force_device_scan)(struct SoundIoPrivate *); void (*force_device_scan)(struct SoundIoPrivate *);
int (*outstream_open)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *); enum SoundIoError (*outstream_open)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *);
void (*outstream_destroy)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *); void (*outstream_destroy)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *);
int (*outstream_start)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *); enum SoundIoError (*outstream_start)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *);
int (*outstream_begin_write)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *, enum SoundIoError (*outstream_begin_write)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *,
struct SoundIoChannelArea **out_areas, int *out_frame_count); struct SoundIoChannelArea **out_areas, int *out_frame_count);
int (*outstream_end_write)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *); enum SoundIoError (*outstream_end_write)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *);
int (*outstream_clear_buffer)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *); enum SoundIoError (*outstream_clear_buffer)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *);
int (*outstream_pause)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *, bool pause); enum SoundIoError (*outstream_pause)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *, bool pause);
int (*outstream_get_latency)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *, double *out_latency); enum SoundIoError (*outstream_get_latency)(struct SoundIoPrivate *, struct SoundIoOutStreamPrivate *, double *out_latency);
int (*instream_open)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *); enum SoundIoError (*instream_open)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *);
void (*instream_destroy)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *); void (*instream_destroy)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *);
int (*instream_start)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *); enum SoundIoError (*instream_start)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *);
int (*instream_begin_read)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *, enum SoundIoError (*instream_begin_read)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *,
struct SoundIoChannelArea **out_areas, int *out_frame_count); struct SoundIoChannelArea **out_areas, int *out_frame_count);
int (*instream_end_read)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *); enum SoundIoError (*instream_end_read)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *);
int (*instream_pause)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *, bool pause); enum SoundIoError (*instream_pause)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *, bool pause);
int (*instream_get_latency)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *, double *out_latency); enum SoundIoError (*instream_get_latency)(struct SoundIoPrivate *, struct SoundIoInStreamPrivate *, double *out_latency);
union SoundIoBackendData backend_data; union SoundIoBackendData backend_data;
}; };

View file

@ -38,7 +38,7 @@ static enum SoundIoBackend backend = SoundIoBackendNone;
static bool severed = false; static bool severed = false;
static void on_backend_disconnect(struct SoundIo *soundio, int err) { static void on_backend_disconnect(struct SoundIo *soundio, enum SoundIoError err) {
fprintf(stderr, "OK backend disconnected with '%s'.\n", soundio_strerror(err)); fprintf(stderr, "OK backend disconnected with '%s'.\n", soundio_strerror(err));
severed = true; severed = true;
} }

View file

@ -26,7 +26,7 @@ static void test_os_get_time(void) {
} }
static void write_callback(struct SoundIoOutStream *device, int frame_count_min, int frame_count_max) { } static void write_callback(struct SoundIoOutStream *device, int frame_count_min, int frame_count_max) { }
static void error_callback(struct SoundIoOutStream *device, int err) { } static void error_callback(struct SoundIoOutStream *device, enum SoundIoError err) { }
static void test_create_outstream(void) { static void test_create_outstream(void) {
struct SoundIo *soundio = soundio_create(); struct SoundIo *soundio = soundio_create();