|
|
|
@ -12,8 +12,19 @@
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#define SOUNDIO_EXTERN_C extern "C"
|
|
|
|
|
#else
|
|
|
|
|
#define SOUNDIO_EXTERN_C
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
#if defined(SOUNDIO_BUILDING_LIBRARY)
|
|
|
|
|
#define SOUNDIO_EXPORT SOUNDIO_EXTERN_C __declspec(dllexport)
|
|
|
|
|
#else
|
|
|
|
|
#define SOUNDIO_EXPORT SOUNDIO_EXTERN_C __declspec(dllimport)
|
|
|
|
|
#endif
|
|
|
|
|
#else
|
|
|
|
|
#define SOUNDIO_EXPORT SOUNDIO_EXTERN_C __attribute__((visibility ("default")))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
enum SoundIoError {
|
|
|
|
@ -532,29 +543,29 @@ struct SoundIoInStream {
|
|
|
|
|
|
|
|
|
|
// Create a SoundIo context. You may create multiple instances of this to
|
|
|
|
|
// connect to multiple backends.
|
|
|
|
|
struct SoundIo * soundio_create(void);
|
|
|
|
|
void soundio_destroy(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIo * soundio_create(void);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_destroy(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This is a convenience function you could implement yourself if you wanted
|
|
|
|
|
// to. It tries `soundio_connect_backend` on all available backends in order.
|
|
|
|
|
int soundio_connect(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_connect(struct SoundIo *soundio);
|
|
|
|
|
// Instead of calling `soundio_connect` you may call this function to try a
|
|
|
|
|
// specific backend.
|
|
|
|
|
int soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend);
|
|
|
|
|
void soundio_disconnect(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_connect_backend(struct SoundIo *soundio, enum SoundIoBackend backend);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_disconnect(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
const char *soundio_strerror(int error);
|
|
|
|
|
const char *soundio_backend_name(enum SoundIoBackend backend);
|
|
|
|
|
SOUNDIO_EXPORT const char *soundio_strerror(int error);
|
|
|
|
|
SOUNDIO_EXPORT const char *soundio_backend_name(enum SoundIoBackend backend);
|
|
|
|
|
|
|
|
|
|
// Returns the number of available backends.
|
|
|
|
|
int soundio_backend_count(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_backend_count(struct SoundIo *soundio);
|
|
|
|
|
// get the available backend at the specified index
|
|
|
|
|
// (0 <= index < `soundio_backend_count`)
|
|
|
|
|
enum SoundIoBackend soundio_get_backend(struct SoundIo *soundio, int index);
|
|
|
|
|
SOUNDIO_EXPORT enum SoundIoBackend soundio_get_backend(struct SoundIo *soundio, int index);
|
|
|
|
|
|
|
|
|
|
// Returns whether libsoundio was compiled with `backend`.
|
|
|
|
|
bool soundio_have_backend(enum SoundIoBackend backend);
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_have_backend(enum SoundIoBackend backend);
|
|
|
|
|
|
|
|
|
|
// When you call this, the `on_devices_change` and `on_events_signal` callbacks
|
|
|
|
|
// might be called. This is the only time those callbacks will be called.
|
|
|
|
@ -566,14 +577,14 @@ bool soundio_have_backend(enum SoundIoBackend backend);
|
|
|
|
|
// * `soundio_get_output_device`
|
|
|
|
|
// * `soundio_default_input_device_index`
|
|
|
|
|
// * `soundio_default_output_device_index`
|
|
|
|
|
void soundio_flush_events(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_flush_events(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
// This function calls `soundio_flush_events` then blocks until another event
|
|
|
|
|
// is ready or you call `soundio_wakeup`. Be ready for spurious wakeups.
|
|
|
|
|
void soundio_wait_events(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_wait_events(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
// Makes `soundio_wait_events` stop blocking.
|
|
|
|
|
void soundio_wakeup(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_wakeup(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -581,44 +592,44 @@ void soundio_wakeup(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
// Returns whether the channel count field and each channel id matches in
|
|
|
|
|
// the supplied channel layouts.
|
|
|
|
|
bool soundio_channel_layout_equal(
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_channel_layout_equal(
|
|
|
|
|
const struct SoundIoChannelLayout *a,
|
|
|
|
|
const struct SoundIoChannelLayout *b);
|
|
|
|
|
|
|
|
|
|
const char *soundio_get_channel_name(enum SoundIoChannelId id);
|
|
|
|
|
SOUNDIO_EXPORT const char *soundio_get_channel_name(enum SoundIoChannelId id);
|
|
|
|
|
// Given UTF-8 encoded text which is the name of a channel such as
|
|
|
|
|
// "Front Left", "FL", or "front-left", return the corresponding
|
|
|
|
|
// SoundIoChannelId. Returns SoundIoChannelIdInvalid for no match.
|
|
|
|
|
enum SoundIoChannelId soundio_parse_channel_id(const char *str, int str_len);
|
|
|
|
|
SOUNDIO_EXPORT enum SoundIoChannelId soundio_parse_channel_id(const char *str, int str_len);
|
|
|
|
|
|
|
|
|
|
int soundio_channel_layout_builtin_count(void);
|
|
|
|
|
const struct SoundIoChannelLayout *soundio_channel_layout_get_builtin(int index);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_channel_layout_builtin_count(void);
|
|
|
|
|
SOUNDIO_EXPORT const struct SoundIoChannelLayout *soundio_channel_layout_get_builtin(int index);
|
|
|
|
|
|
|
|
|
|
// Get the default builtin channel layout for the given number of channels.
|
|
|
|
|
const struct SoundIoChannelLayout *soundio_channel_layout_get_default(int channel_count);
|
|
|
|
|
SOUNDIO_EXPORT const struct SoundIoChannelLayout *soundio_channel_layout_get_default(int channel_count);
|
|
|
|
|
|
|
|
|
|
int soundio_channel_layout_find_channel(
|
|
|
|
|
SOUNDIO_EXPORT int soundio_channel_layout_find_channel(
|
|
|
|
|
const struct SoundIoChannelLayout *layout, enum SoundIoChannelId channel);
|
|
|
|
|
|
|
|
|
|
// Populates the name field of layout if it matches a builtin one.
|
|
|
|
|
// returns whether it found a match
|
|
|
|
|
bool soundio_channel_layout_detect_builtin(struct SoundIoChannelLayout *layout);
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_channel_layout_detect_builtin(struct SoundIoChannelLayout *layout);
|
|
|
|
|
|
|
|
|
|
// Iterates over preferred_layouts. Returns the first channel layout in
|
|
|
|
|
// preferred_layouts which matches one of the channel layouts in
|
|
|
|
|
// available_layouts. Returns NULL if none matches.
|
|
|
|
|
const struct SoundIoChannelLayout *soundio_best_matching_channel_layout(
|
|
|
|
|
SOUNDIO_EXPORT const struct SoundIoChannelLayout *soundio_best_matching_channel_layout(
|
|
|
|
|
const struct SoundIoChannelLayout *preferred_layouts, int preferred_layout_count,
|
|
|
|
|
const struct SoundIoChannelLayout *available_layouts, int available_layout_count);
|
|
|
|
|
|
|
|
|
|
// Sorts by channel count, descending.
|
|
|
|
|
void soundio_sort_channel_layouts(struct SoundIoChannelLayout *layouts, int layout_count);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_sort_channel_layouts(struct SoundIoChannelLayout *layouts, int layout_count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sample Formats
|
|
|
|
|
|
|
|
|
|
// Returns -1 on invalid format.
|
|
|
|
|
int soundio_get_bytes_per_sample(enum SoundIoFormat format);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_get_bytes_per_sample(enum SoundIoFormat format);
|
|
|
|
|
|
|
|
|
|
static inline int soundio_get_bytes_per_frame(enum SoundIoFormat format, int channel_count) {
|
|
|
|
|
return soundio_get_bytes_per_sample(format) * channel_count;
|
|
|
|
@ -631,7 +642,7 @@ static inline int soundio_get_bytes_per_second(enum SoundIoFormat format,
|
|
|
|
|
return soundio_get_bytes_per_frame(format, channel_count) * sample_rate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char * soundio_format_string(enum SoundIoFormat format);
|
|
|
|
|
SOUNDIO_EXPORT const char * soundio_format_string(enum SoundIoFormat format);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -647,60 +658,60 @@ const char * soundio_format_string(enum SoundIoFormat format);
|
|
|
|
|
|
|
|
|
|
// Get the number of input devices.
|
|
|
|
|
// Returns -1 if you never called `soundio_flush_events`.
|
|
|
|
|
int soundio_input_device_count(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_input_device_count(struct SoundIo *soundio);
|
|
|
|
|
// Get the number of output devices.
|
|
|
|
|
// Returns -1 if you never called `soundio_flush_events`.
|
|
|
|
|
int soundio_output_device_count(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_output_device_count(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
// Always returns a device. Call soundio_device_unref when done.
|
|
|
|
|
// `index` must be 0 <= index < soundio_input_device_count
|
|
|
|
|
// Returns NULL if you never called `soundio_flush_events` or if you provide
|
|
|
|
|
// invalid parameter values.
|
|
|
|
|
struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index);
|
|
|
|
|
// Always returns a device. Call soundio_device_unref when done.
|
|
|
|
|
// `index` must be 0 <= index < soundio_output_device_count
|
|
|
|
|
// Returns NULL if you never called `soundio_flush_events` or if you provide
|
|
|
|
|
// invalid parameter values.
|
|
|
|
|
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
|
|
|
|
|
|
|
|
|
// returns the index of the default input device
|
|
|
|
|
// returns -1 if there are no devices or if you never called
|
|
|
|
|
// `soundio_flush_events`.
|
|
|
|
|
int soundio_default_input_device_index(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_default_input_device_index(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
// returns the index of the default output device
|
|
|
|
|
// returns -1 if there are no devices or if you never called
|
|
|
|
|
// `soundio_flush_events`.
|
|
|
|
|
int soundio_default_output_device_index(struct SoundIo *soundio);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_default_output_device_index(struct SoundIo *soundio);
|
|
|
|
|
|
|
|
|
|
void soundio_device_ref(struct SoundIoDevice *device);
|
|
|
|
|
void soundio_device_unref(struct SoundIoDevice *device);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_device_ref(struct SoundIoDevice *device);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_device_unref(struct SoundIoDevice *device);
|
|
|
|
|
|
|
|
|
|
bool soundio_device_equal(
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_device_equal(
|
|
|
|
|
const struct SoundIoDevice *a,
|
|
|
|
|
const struct SoundIoDevice *b);
|
|
|
|
|
|
|
|
|
|
// Sorts channel layouts by channel count, descending.
|
|
|
|
|
void soundio_device_sort_channel_layouts(struct SoundIoDevice *device);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_device_sort_channel_layouts(struct SoundIoDevice *device);
|
|
|
|
|
|
|
|
|
|
// Convenience function. Returns whether `format` is included in the device's
|
|
|
|
|
// supported formats.
|
|
|
|
|
bool soundio_device_supports_format(struct SoundIoDevice *device,
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_device_supports_format(struct SoundIoDevice *device,
|
|
|
|
|
enum SoundIoFormat format);
|
|
|
|
|
|
|
|
|
|
// Convenience function. Returns whether `layout` is included in the device's
|
|
|
|
|
// supported channel layouts.
|
|
|
|
|
bool soundio_device_supports_layout(struct SoundIoDevice *device,
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_device_supports_layout(struct SoundIoDevice *device,
|
|
|
|
|
const struct SoundIoChannelLayout *layout);
|
|
|
|
|
|
|
|
|
|
// Convenience function. Returns whether `sample_rate` is included in the
|
|
|
|
|
// device's supported sample rates.
|
|
|
|
|
bool soundio_device_supports_sample_rate(struct SoundIoDevice *device,
|
|
|
|
|
SOUNDIO_EXPORT bool soundio_device_supports_sample_rate(struct SoundIoDevice *device,
|
|
|
|
|
int sample_rate);
|
|
|
|
|
|
|
|
|
|
// Convenience function. Returns the available sample rate nearest to
|
|
|
|
|
// `sample_rate`, rounding up.
|
|
|
|
|
int soundio_device_nearest_sample_rate(struct SoundIoDevice *device,
|
|
|
|
|
SOUNDIO_EXPORT int soundio_device_nearest_sample_rate(struct SoundIoDevice *device,
|
|
|
|
|
int sample_rate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -708,17 +719,17 @@ int soundio_device_nearest_sample_rate(struct SoundIoDevice *device,
|
|
|
|
|
// Output Streams
|
|
|
|
|
// Allocates memory and sets defaults. Next you should fill out the struct fields
|
|
|
|
|
// and then call `soundio_outstream_open`.
|
|
|
|
|
struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device);
|
|
|
|
|
// You may not call this function from the `write_callback` thread context.
|
|
|
|
|
void soundio_outstream_destroy(struct SoundIoOutStream *outstream);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_outstream_destroy(struct SoundIoOutStream *outstream);
|
|
|
|
|
|
|
|
|
|
// After you call this function, `software_latency` is set to the correct
|
|
|
|
|
// value.
|
|
|
|
|
// The next thing to do is call `soundio_instream_start`.
|
|
|
|
|
int soundio_outstream_open(struct SoundIoOutStream *outstream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_open(struct SoundIoOutStream *outstream);
|
|
|
|
|
|
|
|
|
|
// After you call this function, `write_callback` will be called.
|
|
|
|
|
int soundio_outstream_start(struct SoundIoOutStream *outstream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_start(struct SoundIoOutStream *outstream);
|
|
|
|
|
|
|
|
|
|
// Call this function when you are ready to begin writing to the device buffer.
|
|
|
|
|
// * `outstream` - (in) The output stream you want to write to.
|
|
|
|
@ -738,23 +749,23 @@ int soundio_outstream_start(struct SoundIoOutStream *outstream);
|
|
|
|
|
// If you call this function with `frame_count` less than the `frame_count_min`
|
|
|
|
|
// parameter from `write_callback` it returns SoundIoErrorInvalid.
|
|
|
|
|
// If this function returns an error, do not call `soundio_outstream_end_write`.
|
|
|
|
|
int soundio_outstream_begin_write(struct SoundIoOutStream *outstream,
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_begin_write(struct SoundIoOutStream *outstream,
|
|
|
|
|
struct SoundIoChannelArea **areas, int *frame_count);
|
|
|
|
|
|
|
|
|
|
// Commits the write that you began with `soundio_outstream_begin_write`.
|
|
|
|
|
// You must call this function only from the `write_callback` thread context.
|
|
|
|
|
// This function might return `SoundIoErrorUnderflow` but don't count on it.
|
|
|
|
|
int soundio_outstream_end_write(struct SoundIoOutStream *outstream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_end_write(struct SoundIoOutStream *outstream);
|
|
|
|
|
|
|
|
|
|
// Clears the output stream buffer.
|
|
|
|
|
// You must call this function only from the `write_callback` thread context.
|
|
|
|
|
int soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_clear_buffer(struct SoundIoOutStream *outstream);
|
|
|
|
|
|
|
|
|
|
// If the underyling device supports pausing, this pauses the stream and
|
|
|
|
|
// prevents `write_callback` from being called. Otherwise this returns
|
|
|
|
|
// `SoundIoErrorIncompatibleDevice`.
|
|
|
|
|
// You must call this function only from the `write_callback` thread context.
|
|
|
|
|
int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -762,17 +773,17 @@ int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause);
|
|
|
|
|
// Input Streams
|
|
|
|
|
// Allocates memory and sets defaults. Next you should fill out the struct fields
|
|
|
|
|
// and then call `soundio_instream_open`.
|
|
|
|
|
struct SoundIoInStream *soundio_instream_create(struct SoundIoDevice *device);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIoInStream *soundio_instream_create(struct SoundIoDevice *device);
|
|
|
|
|
// You may not call this function from `read_callback`.
|
|
|
|
|
void soundio_instream_destroy(struct SoundIoInStream *instream);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_instream_destroy(struct SoundIoInStream *instream);
|
|
|
|
|
|
|
|
|
|
// After you call this function, `software_latency` is set to the correct
|
|
|
|
|
// value.
|
|
|
|
|
// The next thing to do is call `soundio_instream_start`.
|
|
|
|
|
int soundio_instream_open(struct SoundIoInStream *instream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_instream_open(struct SoundIoInStream *instream);
|
|
|
|
|
|
|
|
|
|
// After you call this function, `read_callback` will be called.
|
|
|
|
|
int soundio_instream_start(struct SoundIoInStream *instream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_instream_start(struct SoundIoInStream *instream);
|
|
|
|
|
|
|
|
|
|
// Call this function when you are ready to begin reading from the device
|
|
|
|
|
// buffer.
|
|
|
|
@ -796,51 +807,46 @@ int soundio_instream_start(struct SoundIoInStream *instream);
|
|
|
|
|
// and move the read index forward. `soundio_instream_end_read` should not be
|
|
|
|
|
// called if the buffer is empty (`frame_count` == 0), but it should be called
|
|
|
|
|
// if there is a hole.
|
|
|
|
|
int soundio_instream_begin_read(struct SoundIoInStream *instream,
|
|
|
|
|
SOUNDIO_EXPORT int soundio_instream_begin_read(struct SoundIoInStream *instream,
|
|
|
|
|
struct SoundIoChannelArea **areas, int *frame_count);
|
|
|
|
|
// This will drop all of the frames from when you called
|
|
|
|
|
// `soundio_instream_begin_read`.
|
|
|
|
|
// You must call this function only from the `read_callback` thread context.
|
|
|
|
|
// You must call this function only after a successful call to
|
|
|
|
|
// `soundio_instream_begin_read`.
|
|
|
|
|
int soundio_instream_end_read(struct SoundIoInStream *instream);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_instream_end_read(struct SoundIoInStream *instream);
|
|
|
|
|
|
|
|
|
|
// If the underyling device supports pausing, this pauses the stream and
|
|
|
|
|
// prevents `read_callback` from being called. Otherwise this returns
|
|
|
|
|
// `SoundIoErrorIncompatibleDevice`.
|
|
|
|
|
// You must call this function only from the `read_callback` thread context.
|
|
|
|
|
int soundio_instream_pause(struct SoundIoInStream *instream, bool pause);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_instream_pause(struct SoundIoInStream *instream, bool pause);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ring Buffer
|
|
|
|
|
struct SoundIoRingBuffer;
|
|
|
|
|
// `requested_capacity` in bytes.
|
|
|
|
|
struct SoundIoRingBuffer *soundio_ring_buffer_create(struct SoundIo *soundio, int requested_capacity);
|
|
|
|
|
void soundio_ring_buffer_destroy(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
int soundio_ring_buffer_capacity(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT struct SoundIoRingBuffer *soundio_ring_buffer_create(struct SoundIo *soundio, int requested_capacity);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_ring_buffer_destroy(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_ring_buffer_capacity(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
|
|
|
|
|
// don't write more than capacity
|
|
|
|
|
char *soundio_ring_buffer_write_ptr(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT char *soundio_ring_buffer_write_ptr(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
// `count` in bytes.
|
|
|
|
|
void soundio_ring_buffer_advance_write_ptr(struct SoundIoRingBuffer *ring_buffer, int count);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_ring_buffer_advance_write_ptr(struct SoundIoRingBuffer *ring_buffer, int count);
|
|
|
|
|
|
|
|
|
|
// don't read more than capacity
|
|
|
|
|
char *soundio_ring_buffer_read_ptr(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT char *soundio_ring_buffer_read_ptr(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
// `count` in bytes.
|
|
|
|
|
void soundio_ring_buffer_advance_read_ptr(struct SoundIoRingBuffer *ring_buffer, int count);
|
|
|
|
|
SOUNDIO_EXPORT void soundio_ring_buffer_advance_read_ptr(struct SoundIoRingBuffer *ring_buffer, int count);
|
|
|
|
|
|
|
|
|
|
// Returns how many bytes of the buffer is used, ready for reading.
|
|
|
|
|
int soundio_ring_buffer_fill_count(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_ring_buffer_fill_count(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
|
|
|
|
|
// Returns how many bytes of the buffer is free, ready for writing.
|
|
|
|
|
int soundio_ring_buffer_free_count(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
SOUNDIO_EXPORT int soundio_ring_buffer_free_count(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
|
|
|
|
|
// Must be called by the writer.
|
|
|
|
|
void soundio_ring_buffer_clear(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
SOUNDIO_EXPORT void soundio_ring_buffer_clear(struct SoundIoRingBuffer *ring_buffer);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|