Tizen Native API
5.0
|
The Audio Output API provides a set of functions to directly manage the system audio output devices.
#include <audio_io.h>
The Audio Output API provides a set of functions to play recorded audio data from Audio Input.
Functions | |
int | audio_out_create_new (int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_out_h *output) |
Creates an audio device instance and returns an output handle to play PCM (pulse-code modulation) data. | |
int | audio_out_destroy (audio_out_h output) |
Releases the audio output handle, along with all its resources. | |
int | audio_out_set_sound_stream_info (audio_out_h output, sound_stream_info_h stream_info) |
Sets the sound stream information to the audio output. | |
int | audio_out_prepare (audio_out_h output) |
Prepares the audio output for playback, this must be called before audio_out_write(). | |
int | audio_out_unprepare (audio_out_h output) |
Unprepares the audio output. | |
int | audio_out_pause (audio_out_h output) |
Pauses feeding of audio data to the device. | |
int | audio_out_resume (audio_out_h output) |
Resumes feeding of audio data to the device. | |
int | audio_out_drain (audio_out_h output) |
Drains buffered audio data from the output stream. | |
int | audio_out_flush (audio_out_h output) |
Flushes and discards buffered audio data from the output stream. | |
int | audio_out_write (audio_out_h output, void *buffer, unsigned int length) |
Starts writing the audio data to the device. | |
int | audio_out_get_buffer_size (audio_out_h output, int *size) |
Gets the size to be allocated for the audio output buffer. | |
int | audio_out_get_sample_rate (audio_out_h output, int *sample_rate) |
Gets the sample rate of the audio output data stream. | |
int | audio_out_get_channel (audio_out_h output, audio_channel_e *channel) |
Gets the channel type of the audio output data stream. | |
int | audio_out_get_sample_type (audio_out_h output, audio_sample_type_e *type) |
Gets the sample audio format (8-bit or 16-bit) of the audio output data stream. | |
int | audio_out_get_sound_type (audio_out_h output, sound_type_e *type) |
Gets the sound type supported by the audio output device. | |
int | audio_out_set_stream_cb (audio_out_h output, audio_out_stream_cb callback, void *user_data) |
Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data. | |
int | audio_out_unset_stream_cb (audio_out_h output) |
Unregisters the callback function. | |
int | audio_out_set_state_changed_cb (audio_out_h output, audio_out_state_changed_cb callback, void *user_data) |
Sets the state changed callback function to the audio output handle. | |
int | audio_out_unset_state_changed_cb (audio_out_h output) |
Unregisters the state changed callback function of the audio output handle. | |
Typedefs | |
typedef struct audio_io_s * | audio_out_h |
The audio output handle. | |
typedef void(* | audio_out_stream_cb )(audio_out_h handle, size_t nbytes, void *user_data) |
Called when audio out data can be written in asynchronous(event) mode. | |
typedef void(* | audio_out_state_changed_cb )(audio_out_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data) |
Called when the state of audio output is changed. |
typedef struct audio_io_s* audio_out_h |
The audio output handle.
typedef void(* audio_out_state_changed_cb)(audio_out_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data) |
Called when the state of audio output is changed.
[in] | handle | The handle of the audio output |
[in] | previous | The previous state of the audio output |
[in] | current | The current state of the audio output |
[in] | by_policy | true if the state is changed by policy, otherwise false if the state is not changed by policy |
[in] | user_data | The user data passed from the callback registration function |
typedef void(* audio_out_stream_cb)(audio_out_h handle, size_t nbytes, void *user_data) |
Called when audio out data can be written in asynchronous(event) mode.
[in] | handle | The handle to the audio output |
[in] | nbytes | The amount of audio in data which can be written. |
[in] | user_data | The user data passed from the callback registration function |
int audio_out_create_new | ( | int | sample_rate, |
audio_channel_e | channel, | ||
audio_sample_type_e | type, | ||
audio_out_h * | output | ||
) |
Creates an audio device instance and returns an output handle to play PCM (pulse-code modulation) data.
This function is used for audio output initialization.
[in] | sample_rate | The audio sample rate in 8000[Hz] ~ 48000[Hz] (Before 5.0), 8000[Hz] ~ 192000[Hz] (Since 5.0) |
[in] | channel | The audio channel type (mono or stereo) |
[in] | type | The type of audio sample (8-bit or 16-bit) |
[out] | output | An audio output handle is created on success |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_OUT_OF_MEMORY | Out of memory |
AUDIO_IO_ERROR_DEVICE_NOT_OPENED | Device not opened |
AUDIO_IO_ERROR_SOUND_POLICY | Sound policy error |
int audio_out_destroy | ( | audio_out_h | output | ) |
Releases the audio output handle, along with all its resources.
[in] | output | The handle to the audio output to destroy |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_OUT_OF_MEMORY | Out of memory |
AUDIO_IO_ERROR_DEVICE_NOT_CLOSED | Device not closed |
int audio_out_drain | ( | audio_out_h | output | ) |
Drains buffered audio data from the output stream.
This function waits until drains stream buffer completely. (e.g end of playback)
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_flush | ( | audio_out_h | output | ) |
Flushes and discards buffered audio data from the output stream.
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_get_buffer_size | ( | audio_out_h | output, |
int * | size | ||
) |
Gets the size to be allocated for the audio output buffer.
[in] | output | The handle to the audio output |
[out] | size | The suggested buffer size (in bytes, the maximum size is 1 MB) |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_get_channel | ( | audio_out_h | output, |
audio_channel_e * | channel | ||
) |
Gets the channel type of the audio output data stream.
The audio channel type defines whether the audio is mono or stereo.
[in] | output | The handle to the audio output |
[out] | channel | The audio channel type |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_get_sample_rate | ( | audio_out_h | output, |
int * | sample_rate | ||
) |
Gets the sample rate of the audio output data stream.
[in] | output | The handle to the audio output |
[out] | sample_rate | The audio sample rate in Hertz (8000 ~ 48000) (Before 5.0), (8000 ~ 192000) (Since 5.0) |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_get_sample_type | ( | audio_out_h | output, |
audio_sample_type_e * | type | ||
) |
Gets the sample audio format (8-bit or 16-bit) of the audio output data stream.
[in] | output | The handle to the audio output |
[out] | type | The audio sample type |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_get_sound_type | ( | audio_out_h | output, |
sound_type_e * | type | ||
) |
Gets the sound type supported by the audio output device.
[in] | output | The handle to the audio output |
[out] | type | The sound type |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_pause | ( | audio_out_h | output | ) |
Pauses feeding of audio data to the device.
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_prepare | ( | audio_out_h | output | ) |
Prepares the audio output for playback, this must be called before audio_out_write().
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_resume | ( | audio_out_h | output | ) |
Resumes feeding of audio data to the device.
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_set_sound_stream_info | ( | audio_out_h | output, |
sound_stream_info_h | stream_info | ||
) |
Sets the sound stream information to the audio output.
[in] | output | The handle to the audio output |
[in] | stream_info | The handle of stream information |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_NOT_SUPPORTED | Not supported |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
AUDIO_IO_ERROR_NOT_SUPPORTED_TYPE | Not supported stream type |
int audio_out_set_state_changed_cb | ( | audio_out_h | output, |
audio_out_state_changed_cb | callback, | ||
void * | user_data | ||
) |
Sets the state changed callback function to the audio output handle.
[in] | output | The audio output handle |
[in] | callback | the state changed callback called when the state of the handle is changed (audio_out_state_changed_cb) |
[in] | user_data | user data to be retrieved when callback is called |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_set_stream_cb | ( | audio_out_h | output, |
audio_out_stream_cb | callback, | ||
void * | user_data | ||
) |
Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data.
callback will be called when you can write a PCM data. It might cause dead lock if change the state of audio handle in callback. (ex: audio_out_destroy, audio_out_prepare, audio_out_unprepare) Recommend to use as a VOIP only. Recommend not to hold callback too long.(it affects latency)
[in] | output | An audio output handle |
[in] | callback | notify stream callback when user can write data (audio_out_stream_cb) |
[in] | user_data | user data to be retrieved when callback is called |
AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_OUT_OF_MEMORY | Out of memory |
AUDIO_IO_ERROR_DEVICE_NOT_OPENED | Device not opened |
AUDIO_IO_ERROR_SOUND_POLICY | Sound policy error |
int audio_out_unprepare | ( | audio_out_h | output | ) |
Unprepares the audio output.
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |
int audio_out_unset_state_changed_cb | ( | audio_out_h | output | ) |
Unregisters the state changed callback function of the audio output handle.
[in] | output | The handle to the audio output |
0
on success, otherwise a negative error value AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
int audio_out_unset_stream_cb | ( | audio_out_h | output | ) |
Unregisters the callback function.
[in] | output | The handle to the audio output |
AUDIO_IO_ERROR_NONE | Successful |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_OPERATION | Invalid operation |
int audio_out_write | ( | audio_out_h | output, |
void * | buffer, | ||
unsigned int | length | ||
) |
Starts writing the audio data to the device.
[in] | output | The handle to the audio output |
[in,out] | buffer | The PCM buffer address |
[in] | length | The length of the PCM buffer (in bytes) |
AUDIO_IO_ERROR_INVALID_PARAMETER | Invalid parameter |
AUDIO_IO_ERROR_INVALID_BUFFER | Invalid buffer pointer |
AUDIO_IO_ERROR_SOUND_POLICY | Sound policy error |
AUDIO_IO_ERROR_INVALID_STATE | Invalid state |