libsoundio
1.0.3
|
Go to the source code of this file.
Data Structures | |
struct | SoundIoChannelLayout |
The size of this struct is OK to use. More... | |
struct | SoundIoSampleRateRange |
The size of this struct is OK to use. More... | |
struct | SoundIoChannelArea |
The size of this struct is OK to use. More... | |
struct | SoundIo |
The size of this struct is not part of the API or ABI. More... | |
struct | SoundIoDevice |
The size of this struct is not part of the API or ABI. More... | |
struct | SoundIoOutStream |
The size of this struct is not part of the API or ABI. More... | |
struct | SoundIoInStream |
The size of this struct is not part of the API or ABI. More... | |
Macros | |
#define | SOUNDIO_MAX_CHANNELS 24 |
Functions | |
struct SoundIo * | soundio_create (void) |
Create a SoundIo context. More... | |
void | soundio_destroy (struct SoundIo *soundio) |
int | soundio_connect (struct SoundIo *soundio) |
Tries soundio_connect_backend on all available backends in order. More... | |
int | soundio_connect_backend (struct SoundIo *soundio, enum SoundIoBackend backend) |
Instead of calling soundio_connect you may call this function to try a specific backend. More... | |
void | soundio_disconnect (struct SoundIo *soundio) |
const char * | soundio_strerror (int error) |
Get a string representation of a SoundIoError. More... | |
const char * | soundio_backend_name (enum SoundIoBackend backend) |
Get a string representation of a SoundIoBackend. More... | |
int | soundio_backend_count (struct SoundIo *soundio) |
Returns the number of available backends. More... | |
enum SoundIoBackend | soundio_get_backend (struct SoundIo *soundio, int index) |
get the available backend at the specified index (0 <= index < soundio_backend_count) More... | |
bool | soundio_have_backend (enum SoundIoBackend backend) |
Returns whether libsoundio was compiled with backend. More... | |
void | soundio_flush_events (struct SoundIo *soundio) |
Atomically update information for all connected devices. More... | |
void | soundio_wait_events (struct SoundIo *soundio) |
This function calls soundio_flush_events then blocks until another event is ready or you call soundio_wakeup. More... | |
void | soundio_wakeup (struct SoundIo *soundio) |
Makes soundio_wait_events stop blocking. More... | |
void | soundio_force_device_scan (struct SoundIo *soundio) |
If necessary you can manually trigger a device rescan. More... | |
bool | soundio_channel_layout_equal (const struct SoundIoChannelLayout *a, const struct SoundIoChannelLayout *b) |
Returns whether the channel count field and each channel id matches in the supplied channel layouts. More... | |
const char * | soundio_get_channel_name (enum SoundIoChannelId id) |
enum SoundIoChannelId | soundio_parse_channel_id (const char *str, int str_len) |
Given UTF-8 encoded text which is the name of a channel such as "Front Left", "FL", or "front-left", return the corresponding SoundIoChannelId. More... | |
int | soundio_channel_layout_builtin_count (void) |
Returns the number of builtin channel layouts. More... | |
const struct SoundIoChannelLayout * | soundio_channel_layout_get_builtin (int index) |
Returns a builtin channel layout. More... | |
const struct SoundIoChannelLayout * | soundio_channel_layout_get_default (int channel_count) |
Get the default builtin channel layout for the given number of channels. More... | |
int | soundio_channel_layout_find_channel (const struct SoundIoChannelLayout *layout, enum SoundIoChannelId channel) |
Return the index of channel in layout , or -1 if not found. More... | |
bool | soundio_channel_layout_detect_builtin (struct SoundIoChannelLayout *layout) |
Populates the name field of layout if it matches a builtin one. More... | |
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) |
Iterates over preferred_layouts. More... | |
void | soundio_sort_channel_layouts (struct SoundIoChannelLayout *layouts, int layout_count) |
Sorts by channel count, descending. More... | |
int | soundio_get_bytes_per_sample (enum SoundIoFormat format) |
Returns -1 on invalid format. More... | |
static int | soundio_get_bytes_per_frame (enum SoundIoFormat format, int channel_count) |
A frame is one sample per channel. More... | |
static int | soundio_get_bytes_per_second (enum SoundIoFormat format, int channel_count, int sample_rate) |
Sample rate is the number of frames per second. More... | |
const char * | soundio_format_string (enum SoundIoFormat format) |
Returns string representation of format . More... | |
int | soundio_input_device_count (struct SoundIo *soundio) |
When you call soundio_flush_events, a snapshot of all device state is saved and these functions merely access the snapshot data. More... | |
int | soundio_output_device_count (struct SoundIo *soundio) |
Get the number of output devices. More... | |
struct SoundIoDevice * | soundio_get_input_device (struct SoundIo *soundio, int index) |
Always returns a device. More... | |
struct SoundIoDevice * | soundio_get_output_device (struct SoundIo *soundio, int index) |
Always returns a device. More... | |
int | soundio_default_input_device_index (struct SoundIo *soundio) |
returns the index of the default input device returns -1 if there are no devices or if you never called soundio_flush_events. More... | |
int | soundio_default_output_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. More... | |
void | soundio_device_ref (struct SoundIoDevice *device) |
Add 1 to the reference count of device . More... | |
void | soundio_device_unref (struct SoundIoDevice *device) |
Remove 1 to the reference count of device . More... | |
bool | soundio_device_equal (const struct SoundIoDevice *a, const struct SoundIoDevice *b) |
Return true if and only if the devices have the same SoundIoDevice::id, SoundIoDevice::is_raw, and SoundIoDevice::aim are the same. More... | |
void | soundio_device_sort_channel_layouts (struct SoundIoDevice *device) |
Sorts channel layouts by channel count, descending. More... | |
bool | soundio_device_supports_format (struct SoundIoDevice *device, enum SoundIoFormat format) |
Convenience function. More... | |
bool | soundio_device_supports_layout (struct SoundIoDevice *device, const struct SoundIoChannelLayout *layout) |
Convenience function. More... | |
bool | soundio_device_supports_sample_rate (struct SoundIoDevice *device, int sample_rate) |
Convenience function. More... | |
int | soundio_device_nearest_sample_rate (struct SoundIoDevice *device, int sample_rate) |
Convenience function. More... | |
struct SoundIoOutStream * | soundio_outstream_create (struct SoundIoDevice *device) |
Allocates memory and sets defaults. More... | |
void | soundio_outstream_destroy (struct SoundIoOutStream *outstream) |
You may not call this function from the SoundIoOutStream::write_callback thread context. More... | |
int | soundio_outstream_open (struct SoundIoOutStream *outstream) |
After you call this function, SoundIoOutStream:software_latency is set to the correct value. More... | |
int | soundio_outstream_start (struct SoundIoOutStream *outstream) |
After you call this function, SoundIoOutStream::write_callback will be called. More... | |
int | soundio_outstream_begin_write (struct SoundIoOutStream *outstream, struct SoundIoChannelArea **areas, int *frame_count) |
Call this function when you are ready to begin writing to the device buffer. More... | |
int | soundio_outstream_end_write (struct SoundIoOutStream *outstream) |
Commits the write that you began with soundio_outstream_begin_write. More... | |
int | soundio_outstream_clear_buffer (struct SoundIoOutStream *outstream) |
Clears the output stream buffer. More... | |
int | soundio_outstream_pause (struct SoundIoOutStream *outstream, bool pause) |
If the underlying device supports pausing, this pauses the stream. More... | |
int | soundio_outstream_get_latency (struct SoundIoOutStream *outstream, double *out_latency) |
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 audible. More... | |
struct SoundIoInStream * | soundio_instream_create (struct SoundIoDevice *device) |
Allocates memory and sets defaults. More... | |
void | soundio_instream_destroy (struct SoundIoInStream *instream) |
You may not call this function from SoundIoInStream::read_callback. More... | |
int | soundio_instream_open (struct SoundIoInStream *instream) |
After you call this function, SoundIoInStream::software_latency is set to the correct value. More... | |
int | soundio_instream_start (struct SoundIoInStream *instream) |
After you call this function, SoundIoInStream::read_callback will be called. More... | |
int | soundio_instream_begin_read (struct SoundIoInStream *instream, struct SoundIoChannelArea **areas, int *frame_count) |
Call this function when you are ready to begin reading from the device buffer. More... | |
int | soundio_instream_end_read (struct SoundIoInStream *instream) |
This will drop all of the frames from when you called soundio_instream_begin_read. More... | |
int | soundio_instream_pause (struct SoundIoInStream *instream, bool pause) |
If the underyling device supports pausing, this pauses the stream and prevents SoundIoInStream::read_callback from being called. More... | |
int | soundio_instream_get_latency (struct SoundIoInStream *instream, double *out_latency) |
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 represented in the buffer. More... | |
struct SoundIoRingBuffer * | soundio_ring_buffer_create (struct SoundIo *soundio, int requested_capacity) |
requested_capacity in bytes. More... | |
void | soundio_ring_buffer_destroy (struct SoundIoRingBuffer *ring_buffer) |
int | soundio_ring_buffer_capacity (struct SoundIoRingBuffer *ring_buffer) |
When you create a ring buffer, capacity might be more than the requested capacity for alignment purposes. More... | |
char * | soundio_ring_buffer_write_ptr (struct SoundIoRingBuffer *ring_buffer) |
Do not write more than capacity. More... | |
void | soundio_ring_buffer_advance_write_ptr (struct SoundIoRingBuffer *ring_buffer, int count) |
count in bytes. More... | |
char * | soundio_ring_buffer_read_ptr (struct SoundIoRingBuffer *ring_buffer) |
Do not read more than capacity. More... | |
void | soundio_ring_buffer_advance_read_ptr (struct SoundIoRingBuffer *ring_buffer, int count) |
count in bytes. More... | |
int | soundio_ring_buffer_fill_count (struct SoundIoRingBuffer *ring_buffer) |
Returns how many bytes of the buffer is used, ready for reading. More... | |
int | soundio_ring_buffer_free_count (struct SoundIoRingBuffer *ring_buffer) |
Returns how many bytes of the buffer is free, ready for writing. More... | |
void | soundio_ring_buffer_clear (struct SoundIoRingBuffer *ring_buffer) |
Must be called by the writer. More... | |
#define SOUNDIO_MAX_CHANNELS 24 |
enum SoundIoBackend |
enum SoundIoChannelId |
Specifies where a channel is physically located.
Built-in channel layouts for convenience.
enum SoundIoDeviceAim |
enum SoundIoError |
See also soundio_strerror.
enum SoundIoFormat |
For your convenience, Native Endian and Foreign Endian constants are defined which point to the respective SoundIoFormat values.
int soundio_backend_count | ( | struct SoundIo * | soundio | ) |
Returns the number of available backends.
const char* soundio_backend_name | ( | enum SoundIoBackend | backend | ) |
Get a string representation of a SoundIoBackend.
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 | ||
) |
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.
int soundio_channel_layout_builtin_count | ( | void | ) |
Returns the number of builtin channel layouts.
bool soundio_channel_layout_detect_builtin | ( | struct SoundIoChannelLayout * | layout | ) |
Populates the name field of layout if it matches a builtin one.
returns whether it found a match
bool soundio_channel_layout_equal | ( | const struct SoundIoChannelLayout * | a, |
const struct SoundIoChannelLayout * | b | ||
) |
Returns whether the channel count field and each channel id matches in the supplied channel layouts.
int soundio_channel_layout_find_channel | ( | const struct SoundIoChannelLayout * | layout, |
enum SoundIoChannelId | channel | ||
) |
Return the index of channel
in layout
, or -1
if not found.
const struct SoundIoChannelLayout* soundio_channel_layout_get_builtin | ( | int | index | ) |
Returns a builtin channel layout.
0 <= index
< soundio_channel_layout_builtin_count
Although index
is of type int
, it should be a valid SoundIoChannelLayoutId enum value.
const struct SoundIoChannelLayout* soundio_channel_layout_get_default | ( | int | channel_count | ) |
Get the default builtin channel layout for the given number of channels.
int soundio_connect | ( | struct SoundIo * | soundio | ) |
Tries soundio_connect_backend on all available backends in order.
Possible errors:
JackNoSuchClient
See also soundio_disconnect int soundio_connect_backend | ( | struct SoundIo * | soundio, |
enum SoundIoBackend | backend | ||
) |
Instead of calling soundio_connect you may call this function to try a specific backend.
Possible errors:
JackNoSuchClient
backend
is not activestruct SoundIo* soundio_create | ( | void | ) |
Create a SoundIo context.
You may create multiple instances of this to connect to multiple backends. Sets all fields to defaults. Returns NULL
if and only if memory could not be allocated. See also soundio_destroy
int soundio_default_input_device_index | ( | struct SoundIo * | soundio | ) |
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_output_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.
void soundio_destroy | ( | struct SoundIo * | soundio | ) |
bool soundio_device_equal | ( | const struct SoundIoDevice * | a, |
const struct SoundIoDevice * | b | ||
) |
Return true
if and only if the devices have the same SoundIoDevice::id, SoundIoDevice::is_raw, and SoundIoDevice::aim are the same.
int soundio_device_nearest_sample_rate | ( | struct SoundIoDevice * | device, |
int | sample_rate | ||
) |
Convenience function.
Returns the available sample rate nearest to sample_rate
, rounding up.
void soundio_device_ref | ( | struct SoundIoDevice * | device | ) |
Add 1 to the reference count of device
.
void soundio_device_sort_channel_layouts | ( | struct SoundIoDevice * | device | ) |
Sorts channel layouts by channel count, descending.
bool soundio_device_supports_format | ( | struct SoundIoDevice * | device, |
enum SoundIoFormat | format | ||
) |
Convenience function.
Returns whether format
is included in the device's supported formats.
bool soundio_device_supports_layout | ( | struct SoundIoDevice * | device, |
const struct SoundIoChannelLayout * | layout | ||
) |
Convenience function.
Returns whether layout
is included in the device's supported channel layouts.
bool soundio_device_supports_sample_rate | ( | struct SoundIoDevice * | device, |
int | sample_rate | ||
) |
Convenience function.
Returns whether sample_rate
is included in the device's supported sample rates.
void soundio_device_unref | ( | struct SoundIoDevice * | device | ) |
Remove 1 to the reference count of device
.
Clean up if it was the last reference.
void soundio_disconnect | ( | struct SoundIo * | soundio | ) |
void soundio_flush_events | ( | struct SoundIo * | soundio | ) |
Atomically update information for all connected devices.
Note that calling this function merely flips a pointer; the actual work of collecting device information is done elsewhere. It is performant to call this function many times per second.
When you call this, the following callbacks might be called:
This must be called from the same thread as the thread in which you call these functions:
Note that if you do not care about learning about updated devices, you might call this function only once ever and never call soundio_wait_events.
void soundio_force_device_scan | ( | struct SoundIo * | soundio | ) |
If necessary you can manually trigger a device rescan.
Normally you will not ever have to call this function, as libsoundio listens to system events for device changes and responds to them by rescanning devices and preparing the new device information for you to be atomically replaced when you call soundio_flush_events. However you might run into cases where you want to force trigger a device rescan, for example if an ALSA device has a SoundIoDevice::probe_error.
After you call this you still have to use soundio_flush_events or soundio_wait_events and then wait for the SoundIo::on_devices_change callback.
This can be called from any thread context except for SoundIoOutStream::write_callback and SoundIoInStream::read_callback
const char* soundio_format_string | ( | enum SoundIoFormat | format | ) |
Returns string representation of format
.
enum SoundIoBackend soundio_get_backend | ( | struct SoundIo * | soundio, |
int | index | ||
) |
get the available backend at the specified index (0 <= index < soundio_backend_count)
|
inlinestatic |
A frame is one sample per channel.
References SoundIoChannelLayout::channel_count, and soundio_get_bytes_per_sample().
Referenced by soundio_get_bytes_per_second().
int soundio_get_bytes_per_sample | ( | enum SoundIoFormat | format | ) |
Returns -1 on invalid format.
Referenced by soundio_get_bytes_per_frame().
|
inlinestatic |
Sample rate is the number of frames per second.
References soundio_get_bytes_per_frame().
const char* soundio_get_channel_name | ( | enum SoundIoChannelId | id | ) |
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_input_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 | ||
) |
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.
bool soundio_have_backend | ( | enum SoundIoBackend | backend | ) |
Returns whether libsoundio was compiled with backend.
int soundio_input_device_count | ( | struct SoundIo * | soundio | ) |
When you call soundio_flush_events, a snapshot of all device state is saved and these functions merely access the snapshot data.
When you want to check for new devices, call soundio_flush_events. Or you can call soundio_wait_events to block until devices change. If an error occurs scanning devices in a background thread, SoundIo::on_backend_disconnect is called with the error code. Get the number of input devices. Returns -1 if you never called soundio_flush_events.
int soundio_instream_begin_read | ( | struct SoundIoInStream * | instream, |
struct SoundIoChannelArea ** | areas, | ||
int * | frame_count | ||
) |
Call this function when you are ready to begin reading from the device buffer.
instream
- (in) The input stream you want to read from.areas
- (out) The memory addresses you can read data from. It is OK to modify the pointers if that helps you iterate. There might be a "hole" in the buffer. To indicate this, areas
will be NULL
and frame_count
tells how big the hole is in frames.frame_count
- (in/out) - Provide the number of frames you want to read; returns the number of frames you can actually read. The returned value will always be less than or equal to the provided value. If the provided value is less than frame_count_min
from SoundIoInStream::read_callback this function returns with SoundIoErrorInvalid. It is your responsibility to call this function no more and no fewer than the correct number of times according to the frame_count_min
and frame_count_max
criteria from SoundIoInStream::read_callback. You must call this function only from the SoundIoInStream::read_callback thread context. After calling this function, read data from areas
and then use soundio_instream_end_read` to actually remove the data from the buffer 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.Possible errors:
*frame_count
< frame_count_min
or *frame_count
> frame_count_max
struct SoundIoInStream* soundio_instream_create | ( | struct SoundIoDevice * | device | ) |
Allocates memory and sets defaults.
Next you should fill out the struct fields and then call soundio_instream_open. Sets all fields to defaults. Returns NULL
if and only if memory could not be allocated. See also soundio_instream_destroy
void soundio_instream_destroy | ( | struct SoundIoInStream * | instream | ) |
You may not call this function from SoundIoInStream::read_callback.
int soundio_instream_end_read | ( | struct SoundIoInStream * | instream | ) |
This will drop all of the frames from when you called soundio_instream_begin_read.
You must call this function only from the SoundIoInStream::read_callback thread context. You must call this function only after a successful call to soundio_instream_begin_read.
Possible errors:
int soundio_instream_get_latency | ( | struct SoundIoInStream * | instream, |
double * | out_latency | ||
) |
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 represented in the buffer.
This includes both software and hardware latency.
This function must be called only from within SoundIoInStream::read_callback.
Possible errors:
int soundio_instream_open | ( | struct SoundIoInStream * | instream | ) |
After you call this function, SoundIoInStream::software_latency is set to the correct value.
The next thing to do is call soundio_instream_start. If this function returns an error, the instream is in an invalid state and you must call soundio_instream_destroy on it.
Possible errors:
int soundio_instream_pause | ( | struct SoundIoInStream * | instream, |
bool | pause | ||
) |
If the underyling device supports pausing, this pauses the stream and prevents SoundIoInStream::read_callback from being called.
Otherwise this returns SoundIoErrorIncompatibleDevice. This function may be called from any thread. Pausing when already paused or unpausing when already unpaused has no effect and always returns SoundIoErrorNone.
Possible errors:
int soundio_instream_start | ( | struct SoundIoInStream * | instream | ) |
After you call this function, SoundIoInStream::read_callback will be called.
Possible errors:
int soundio_output_device_count | ( | struct SoundIo * | soundio | ) |
Get the number of output devices.
Returns -1 if you never called soundio_flush_events.
int soundio_outstream_begin_write | ( | struct SoundIoOutStream * | outstream, |
struct SoundIoChannelArea ** | areas, | ||
int * | frame_count | ||
) |
Call this function when you are ready to begin writing to the device buffer.
outstream
- (in) The output stream you want to write to.areas
- (out) The memory addresses you can write data to, one per channel. It is OK to modify the pointers if that helps you iterate.frame_count
- (in/out) Provide the number of frames you want to write. Returned will be the number of frames you can actually write, which is also the number of frames that will be written when you call soundio_outstream_end_write. The value returned will always be less than or equal to the value provided. It is your responsibility to call this function exactly as many times as necessary to meet the frame_count_min
and frame_count_max
criteria from SoundIoOutStream::write_callback. You must call this function only from the SoundIoOutStream::write_callback thread context. After calling this function, write data to areas
and then call soundio_outstream_end_write. If this function returns an error, do not call soundio_outstream_end_write.Possible errors:
*frame_count
<= 0*frame_count
< frame_count_min
or *frame_count
> frame_count_max
frame_count_max
int soundio_outstream_clear_buffer | ( | struct SoundIoOutStream * | outstream | ) |
Clears the output stream buffer.
This function can be called from any thread. This function can be called regardless of whether the outstream is paused or not. Some backends do not support clearing the buffer. On these backends this function will return SoundIoErrorIncompatibleBackend. Some devices do not support clearing the buffer. On these devices this function might return SoundIoErrorIncompatibleDevice. Possible errors:
struct SoundIoOutStream* soundio_outstream_create | ( | struct SoundIoDevice * | device | ) |
Allocates memory and sets defaults.
Next you should fill out the struct fields and then call soundio_outstream_open. Sets all fields to defaults. Returns NULL
if and only if memory could not be allocated. See also soundio_outstream_destroy
void soundio_outstream_destroy | ( | struct SoundIoOutStream * | outstream | ) |
You may not call this function from the SoundIoOutStream::write_callback thread context.
int soundio_outstream_end_write | ( | struct SoundIoOutStream * | outstream | ) |
Commits the write that you began with soundio_outstream_begin_write.
You must call this function only from the SoundIoOutStream::write_callback thread context.
Possible errors:
int soundio_outstream_get_latency | ( | struct SoundIoOutStream * | outstream, |
double * | out_latency | ||
) |
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 audible.
This includes both software and hardware latency. In other words, if you call this function directly after calling soundio_outstream_end_write, this gives you the number of seconds that the next frame written will take to become audible.
This function must be called only from within SoundIoOutStream::write_callback.
Possible errors:
int soundio_outstream_open | ( | struct SoundIoOutStream * | outstream | ) |
After you call this function, SoundIoOutStream:software_latency is set to the correct value.
The next thing to do is call soundio_instream_start. If this function returns an error, the outstream is in an invalid state and you must call soundio_outstream_destroy on it.
Possible errors:
JackNoSuchClient
int soundio_outstream_pause | ( | struct SoundIoOutStream * | outstream, |
bool | pause | ||
) |
If the underlying device supports pausing, this pauses the stream.
SoundIoOutStream::write_callback may be called a few more times if the buffer is not full. Pausing might put the hardware into a low power state which is ideal if your software is silent for some time. This function may be called from any thread. Pausing when already paused or unpausing when already unpaused has no effect and always returns SoundIoErrorNone.
Possible errors:
int soundio_outstream_start | ( | struct SoundIoOutStream * | outstream | ) |
After you call this function, SoundIoOutStream::write_callback will be called.
Possible errors:
enum SoundIoChannelId soundio_parse_channel_id | ( | const char * | str, |
int | str_len | ||
) |
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.
void soundio_ring_buffer_advance_read_ptr | ( | struct SoundIoRingBuffer * | ring_buffer, |
int | count | ||
) |
count
in bytes.
void soundio_ring_buffer_advance_write_ptr | ( | struct SoundIoRingBuffer * | ring_buffer, |
int | count | ||
) |
count
in bytes.
int soundio_ring_buffer_capacity | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
When you create a ring buffer, capacity might be more than the requested capacity for alignment purposes.
This function returns the actual capacity.
void soundio_ring_buffer_clear | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
Must be called by the writer.
struct SoundIoRingBuffer* soundio_ring_buffer_create | ( | struct SoundIo * | soundio, |
int | requested_capacity | ||
) |
requested_capacity
in bytes.
Returns NULL
if and only if memory could not be allocated. Use soundio_ring_buffer_capacity to get the actual capacity, which might be greater for alignment purposes. See also soundio_ring_buffer_destroy
void soundio_ring_buffer_destroy | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
int soundio_ring_buffer_fill_count | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
Returns how many bytes of the buffer is used, ready for reading.
int soundio_ring_buffer_free_count | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
Returns how many bytes of the buffer is free, ready for writing.
char* soundio_ring_buffer_read_ptr | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
Do not read more than capacity.
char* soundio_ring_buffer_write_ptr | ( | struct SoundIoRingBuffer * | ring_buffer | ) |
Do not write more than capacity.
void soundio_sort_channel_layouts | ( | struct SoundIoChannelLayout * | layouts, |
int | layout_count | ||
) |
Sorts by channel count, descending.
const char* soundio_strerror | ( | int | error | ) |
Get a string representation of a SoundIoError.
void soundio_wait_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_wakeup | ( | struct SoundIo * | soundio | ) |
Makes soundio_wait_events stop blocking.