Ecore_Audio - Convenience audio API

Data Structures

struct  _Ecore_Audio_Vio
 

Typedefs

typedef enum _Ecore_Audio_Type Ecore_Audio_Type
 
typedef struct _Ecore_Audio_Module Ecore_Audio_Module
 The audio module.
 
typedef struct _Ecore_Audio_Object Ecore_Audio_Object
 The audio object.
 
typedef struct _Ecore_Audio_Format Ecore_Audio_Format
 The format of the audio data.
 
typedef int(* Ecore_Audio_Read_Callback )(void *user_data, void *data, int len)
 
typedef struct _Ecore_Audio_Vio Ecore_Audio_Vio
 Functions to implement IO virtually.
 

Enumerations

enum  _Ecore_Audio_Type {
  ECORE_AUDIO_TYPE_PULSE,
  ECORE_AUDIO_TYPE_ALSA,
  ECORE_AUDIO_TYPE_SNDFILE,
  ECORE_AUDIO_TYPE_TONE,
  ECORE_AUDIO_TYPE_CUSTOM,
  ECORE_AUDIO_MODULE_LAST
}
 

Functions

int ecore_audio_init (void)
 Initialize the Ecore_Audio library.
 
int ecore_audio_shutdown (void)
 Shut down the Ecore_Audio library.
 
Ecore_Audio_Objectecore_audio_output_add (Ecore_Audio_Type type)
 Create a new Ecore_Audio_Output instance.
 
void ecore_audio_output_name_set (Ecore_Audio_Object *output, const char *name)
 Set the name of an output.
 
const char * ecore_audio_output_name_get (Ecore_Audio_Object *output)
 Get the name of an output.
 
void ecore_audio_output_del (Ecore_Audio_Object *output)
 Free an Ecore_Audio_Output instance.
 
void ecore_audio_output_userdata_set (Ecore_Audio_Object *output, void *data)
 Set the user data pointer.
 
void * ecore_audio_output_userdata_get (Ecore_Audio_Object *output)
 Get the user data pointer.
 
void ecore_audio_output_volume_set (Ecore_Audio_Object *output, double volume)
 Set the volume of the output.
 
double ecore_audio_output_volume_get (Ecore_Audio_Object *output)
 Get the volume of the output.
 
void ecore_audio_output_paused_set (Ecore_Audio_Object *output, Eina_Bool paused)
 Set the paused state of an output.
 
Eina_Bool ecore_audio_output_paused_get (Ecore_Audio_Object *output)
 Get the paused state of an output.
 
Eina_Bool ecore_audio_output_input_add (Ecore_Audio_Object *output, Ecore_Audio_Object *input)
 Add an input to an output.
 
Eina_Bool ecore_audio_output_input_del (Ecore_Audio_Object *output, Ecore_Audio_Object *input)
 Disconnect an input from an output.
 
Eina_Listecore_audio_output_inputs_get (Ecore_Audio_Object *output)
 Get the inputs connected to an output.
 
Eina_Bool ecore_audio_output_input_chain_after (Ecore_Audio_Object *output, Ecore_Audio_Object *input, Ecore_Audio_Object *after)
 Set up an input to play after another input.
 
Ecore_Audio_Objectecore_audio_input_add (Ecore_Audio_Type type)
 Create a new Ecore_Audio_Input instance.
 
const char * ecore_audio_input_name_get (Ecore_Audio_Object *input)
 Get the name of an input.
 
void ecore_audio_input_name_set (Ecore_Audio_Object *input, const char *name)
 Set the name of an input.
 
void ecore_audio_input_del (Ecore_Audio_Object *input)
 Free an Ecore_Audio_Input instance.
 
void ecore_audio_input_userdata_set (Ecore_Audio_Object *input, void *data)
 Set the user data pointer.
 
void * ecore_audio_input_userdata_get (Ecore_Audio_Object *input)
 Get the user data pointer.
 
int ecore_audio_input_samplerate_get (Ecore_Audio_Object *input)
 Get the sample rate of the input.
 
void ecore_audio_input_samplerate_set (Ecore_Audio_Object *input, int samplerate)
 Set the sample rate of the input.
 
int ecore_audio_input_channels_get (Ecore_Audio_Object *input)
 Get the channels of the input.
 
void ecore_audio_input_channels_set (Ecore_Audio_Object *input, int channels)
 Set the amount of channels in the input.
 
double ecore_audio_input_seek (Ecore_Audio_Object *input, double offset, int mode)
 Seek within an input stream.
 
int ecore_audio_input_read (Ecore_Audio_Object *input, void *data, int len)
 Read data from an input stream.
 
Eina_Bool ecore_audio_input_paused_get (Ecore_Audio_Object *input)
 Get the paused state of an input.
 
void ecore_audio_input_paused_set (Ecore_Audio_Object *input, Eina_Bool paused)
 Set the paused state of an input.
 
void ecore_audio_input_volume_set (Ecore_Audio_Object *input, double volume)
 Set the volume of the input.
 
double ecore_audio_input_volume_get (Ecore_Audio_Object *input)
 Get the volume of the input.
 
void ecore_audio_input_looped_set (Ecore_Audio_Object *input, Eina_Bool looped)
 Set whether the input loops.
 
Eina_Bool ecore_audio_input_looped_get (Ecore_Audio_Object *input)
 Get whether the input loops.
 
double ecore_audio_input_length_get (Ecore_Audio_Object *input)
 Get the length of the input in seconds.
 
void ecore_audio_input_preloaded_set (Ecore_Audio_Object *input, Eina_Bool preloaded)
 Set whether the input is preloaded.
 
Eina_Bool ecore_audio_input_preloaded_get (Ecore_Audio_Object *input)
 Get whether the input is preloaded.
 
Ecore_Audio_Objectecore_audio_input_output_get (Ecore_Audio_Object *input)
 Get the outputs this input is connected to.
 
double ecore_audio_input_remaining_get (Ecore_Audio_Object *input)
 Get the remaining time of the input.
 
void ecore_audio_input_sndfile_filename_set (Ecore_Audio_Object *input, const char *filename)
 
void ecore_audio_input_sndfile_format_set (Ecore_Audio_Object *input, int format)
 
void ecore_audio_input_sndfile_vio_set (Ecore_Audio_Object *input, Ecore_Audio_Vio *vio)
 
void ecore_audio_output_sndfile_filename_set (Ecore_Audio_Object *output, const char *filename)
 
void ecore_audio_output_sndfile_format_set (Ecore_Audio_Object *output, int format)
 
void ecore_audio_output_sndfile_vio_set (Ecore_Audio_Object *output, Ecore_Audio_Vio *vio)
 
void ecore_audio_input_tone_frequency_set (Ecore_Audio_Object *input, int frequency)
 
void ecore_audio_input_tone_duration_set (Ecore_Audio_Object *input, double duration)
 
void ecore_audio_input_callback_setup (Ecore_Audio_Object *input, Ecore_Audio_Read_Callback read_cb, void *data)
 

Variables

int ECORE_AUDIO_INPUT_STARTED
 Sound was started.
 
int ECORE_AUDIO_INPUT_STOPPED
 Sound was stopped.
 
int ECORE_AUDIO_INPUT_LOOPED
 Sound looped.
 
int ECORE_AUDIO_INPUT_ENDED
 Sound playback ended.
 
int ECORE_AUDIO_INPUT_PAUSED
 Sound paused.
 
int ECORE_AUDIO_OUTPUT_INPUT_ADDED
 Input added to output.
 
int ECORE_AUDIO_OUTPUT_INPUT_REMOVED
 Input removed from output.
 

Detailed Description

Since
1.8

Typedef Documentation

The audio module.

Since
1.8

The audio object.

Since
1.8

The format of the audio data.

Since
1.8

Enumeration Type Documentation

Since
1.8
Enumerator:
ECORE_AUDIO_TYPE_PULSE 

Use Pulseaudio module.

ECORE_AUDIO_TYPE_ALSA 

Use ALSA module.

ECORE_AUDIO_TYPE_SNDFILE 

Use libsndfile module.

ECORE_AUDIO_TYPE_TONE 

Use tone module.

ECORE_AUDIO_TYPE_CUSTOM 

Use custom module.

ECORE_AUDIO_MODULE_LAST 

Sentinel.

Function Documentation

int ecore_audio_init ( void  )

Initialize the Ecore_Audio library.

Returns
1 or greater on success, 0 on error.
Since
1.8

This function sets up Ecore_Audio and initializes the modules that provide the in- and outputs to use. It returns 0 on failure, otherwise it returns the number of times it has already been called.

When Ecore_Audio is not used anymore, call ecore_audio_shutdown() to shut down the Ecore_Audio library.

References ecore_audio_custom_init(), ECORE_AUDIO_INPUT_ENDED, ECORE_AUDIO_INPUT_LOOPED, ECORE_AUDIO_INPUT_PAUSED, ECORE_AUDIO_INPUT_STARTED, ECORE_AUDIO_INPUT_STOPPED, ECORE_AUDIO_OUTPUT_INPUT_ADDED, ECORE_AUDIO_OUTPUT_INPUT_REMOVED, ecore_audio_tone_init(), ecore_event_type_new(), ecore_init(), eina_list_append(), eina_log_domain_register(), and EINA_LOG_ERR.

int ecore_audio_shutdown ( void  )

Shut down the Ecore_Audio library.

Returns
0 when the library is completely shut down, 1 or greater otherwise.
Since
1.8

This function shuts down the Ecore_Audio library. It returns 0 when it has been called the same number of times than ecore_audio_init(). In that case it shuts down all the services it uses.

References ecore_audio_custom_shutdown(), ecore_audio_tone_shutdown(), ecore_shutdown(), eina_list_free(), and eina_log_domain_unregister().

Ecore_Audio_Object* ecore_audio_output_add ( Ecore_Audio_Type  type)

Create a new Ecore_Audio_Output instance.

Parameters
namethe name of the output to create
Returns
a new instance or NULL on error
Since
1.8

References _Ecore_Audio_Output::inputs, and output_api::output_new.

void ecore_audio_output_name_set ( Ecore_Audio_Object output,
const char *  name 
)

Set the name of an output.

Parameters
outputThe output
nameThe name
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, eina_stringshare_add(), and eina_stringshare_del().

const char* ecore_audio_output_name_get ( Ecore_Audio_Object output)

Get the name of an output.

Parameters
outputthe output
Returns
the name of the output
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL.

void ecore_audio_output_del ( Ecore_Audio_Object output)

Free an Ecore_Audio_Output instance.

Parameters
outthe output
Since
1.8

References ecore_audio_output_input_del(), EINA_LIST_FREE, EINA_SAFETY_ON_NULL_RETURN, eina_stringshare_del(), _Ecore_Audio_Output::inputs, and output_api::output_del.

void ecore_audio_output_userdata_set ( Ecore_Audio_Object output,
void *  data 
)

Set the user data pointer.

Parameters
outputThe output
dataThe pointer to set
Since
1.8
void* ecore_audio_output_userdata_get ( Ecore_Audio_Object output)

Get the user data pointer.

Parameters
outputThe output
Returns
The pointer to the user data
Since
1.8
void ecore_audio_output_volume_set ( Ecore_Audio_Object output,
double  volume 
)

Set the volume of the output.

Parameters
outthe output
volumethe volume
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, and output_api::output_volume_set.

double ecore_audio_output_volume_get ( Ecore_Audio_Object output)

Get the volume of the output.

Parameters
outthe output
Returns
the volume
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and output_api::output_volume_get.

void ecore_audio_output_paused_set ( Ecore_Audio_Object output,
Eina_Bool  paused 
)

Set the paused state of an output.

Parameters
outthe output
pausedthe paused state
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, and output_api::output_paused_set.

Eina_Bool ecore_audio_output_paused_get ( Ecore_Audio_Object output)

Get the paused state of an output.

Parameters
outthe output
Returns
the paused state
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_TRUE.

Eina_Bool ecore_audio_output_input_add ( Ecore_Audio_Object output,
Ecore_Audio_Object input 
)

Add an input to an output.

Parameters
outthe output
inthe input
Returns
True if connecting was successful, False otherwise
Since
1.8

References ECORE_AUDIO_OUTPUT_INPUT_ADDED, ecore_audio_output_input_del(), ecore_event_add(), EINA_FALSE, eina_list_append(), EINA_SAFETY_ON_NULL_RETURN_VAL, _Ecore_Audio_Output::inputs, _Ecore_Audio_Input::output, and output_api::output_add_input.

Eina_Bool ecore_audio_output_input_del ( Ecore_Audio_Object output,
Ecore_Audio_Object input 
)

Disconnect an input from an output.

This will stop playback of the input.

Parameters
outthe output
inthe input
Returns
True if disconnecting was successful, False otherwise
Since
1.8

References ECORE_AUDIO_OUTPUT_INPUT_REMOVED, ecore_event_add(), EINA_FALSE, eina_list_remove(), EINA_SAFETY_ON_NULL_RETURN_VAL, _Ecore_Audio_Output::inputs, _Ecore_Audio_Input::output, and output_api::output_del_input.

Referenced by ecore_audio_input_del(), ecore_audio_output_del(), and ecore_audio_output_input_add().

Eina_List* ecore_audio_output_inputs_get ( Ecore_Audio_Object output)

Get the inputs connected to an output.

Parameters
outthe output
Returns
A list of Ecore_Audio_Input that are connected to the output
Since
1.8

References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and _Ecore_Audio_Output::inputs.

Eina_Bool ecore_audio_output_input_chain_after ( Ecore_Audio_Object output,
Ecore_Audio_Object input,
Ecore_Audio_Object after 
)

Set up an input to play after another input.

Parameters
outthe output
afterthe input relative to which the other input will be chained
inthe input to chain
Returns
True if chaining was successful, False otherwise
Since
1.8

References EINA_FALSE, eina_list_data_find(), EINA_SAFETY_ON_NULL_RETURN_VAL, and _Ecore_Audio_Output::inputs.

Ecore_Audio_Object* ecore_audio_input_add ( Ecore_Audio_Type  type)

Create a new Ecore_Audio_Input instance.

Parameters
namethe name of the input to create
Returns
a new instance or NULL on error
Since
1.8

References EINA_FALSE, input_api::input_new, _Ecore_Audio_Input::output, and _Ecore_Audio_Input::paused.

const char* ecore_audio_input_name_get ( Ecore_Audio_Object input)

Get the name of an input.

Parameters
inputthe input
Returns
the name of the input
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL.

void ecore_audio_input_name_set ( Ecore_Audio_Object input,
const char *  name 
)

Set the name of an input.

Parameters
inputthe input
nameThe name to set
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, eina_stringshare_add(), and eina_stringshare_del().

void ecore_audio_input_del ( Ecore_Audio_Object input)

Free an Ecore_Audio_Input instance.

Parameters
inthe input
Since
1.8

References ecore_audio_output_input_del(), eina_stringshare_del(), input_api::input_del, and _Ecore_Audio_Input::output.

void ecore_audio_input_userdata_set ( Ecore_Audio_Object input,
void *  data 
)

Set the user data pointer.

Parameters
inputThe input
dataThe pointer to set
Since
1.8
void* ecore_audio_input_userdata_get ( Ecore_Audio_Object input)

Get the user data pointer.

Parameters
inputThe input
Returns
The pointer to the user data
Since
1.8
int ecore_audio_input_samplerate_get ( Ecore_Audio_Object input)

Get the sample rate of the input.

Parameters
inputThe input
Returns
The samplerate in Hz
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL.

void ecore_audio_input_samplerate_set ( Ecore_Audio_Object input,
int  samplerate 
)

Set the sample rate of the input.

Parameters
inputThe input
samplerateThe sample rate in Hz
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, and _Ecore_Audio_Input::output.

int ecore_audio_input_channels_get ( Ecore_Audio_Object input)

Get the channels of the input.

Parameters
inputThe input
Returns
The number of channels
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL.

void ecore_audio_input_channels_set ( Ecore_Audio_Object input,
int  channels 
)

Set the amount of channels in the input.

Parameters
inputThe input
channelsThe number of channels to set
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN.

double ecore_audio_input_seek ( Ecore_Audio_Object input,
double  offset,
int  mode 
)

Seek within an input stream.

Parameters
inthe input the offset in seconds seek mode (SEEK_SET, SEEK_END, or SEEK_CUR)
Returns
the current offset
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and input_api::input_seek.

int ecore_audio_input_read ( Ecore_Audio_Object input,
void *  data,
int  len 
)

Read data from an input stream.

Parameters
inthe input
datathe buffer to write the audio data into
lenthe size of the buffer
Returns
the number of bytes that were read
Since
1.8

References ECORE_AUDIO_INPUT_ENDED, ECORE_AUDIO_INPUT_LOOPED, ecore_event_add(), EINA_SAFETY_ON_NULL_RETURN_VAL, input_api::input_read, input_api::input_seek, _Ecore_Audio_Input::looped, and _Ecore_Audio_Input::paused.

Eina_Bool ecore_audio_input_paused_get ( Ecore_Audio_Object input)

Get the paused state of an input.

Parameters
inthe input
Returns
EINA_TRUE if the input is paused, EINA_FALSE otherwise
Since
1.8

References EINA_FALSE, and EINA_SAFETY_ON_NULL_RETURN_VAL.

void ecore_audio_input_paused_set ( Ecore_Audio_Object input,
Eina_Bool  paused 
)

Set the paused state of an input.

Parameters
inthe input
pausedthe paused state to set
Since
1.8

If paused is EINA_TRUE if the input is paused, if it is EINA_FALSE the input plays normally.

References ECORE_AUDIO_INPUT_PAUSED, ecore_event_add(), and EINA_SAFETY_ON_NULL_RETURN.

void ecore_audio_input_volume_set ( Ecore_Audio_Object input,
double  volume 
)

Set the volume of the input.

Parameters
inthe input
volumethe volume
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, and input_api::input_volume_set.

double ecore_audio_input_volume_get ( Ecore_Audio_Object input)

Get the volume of the input.

Parameters
inthe input
Returns
the volume
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and input_api::input_volume_get.

void ecore_audio_input_looped_set ( Ecore_Audio_Object input,
Eina_Bool  looped 
)

Set whether the input loops.

Parameters
inthe input
loopedif the input should loop
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN, and _Ecore_Audio_Input::looped.

Eina_Bool ecore_audio_input_looped_get ( Ecore_Audio_Object input)

Get whether the input loops.

Parameters
inthe input
Returns
if the input loops
Since
1.8

References EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and _Ecore_Audio_Input::looped.

double ecore_audio_input_length_get ( Ecore_Audio_Object input)

Get the length of the input in seconds.

Parameters
inthe input
Returns
the length in seconds
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and _Ecore_Audio_Input::length.

void ecore_audio_input_preloaded_set ( Ecore_Audio_Object input,
Eina_Bool  preloaded 
)

Set whether the input is preloaded.

Parameters
inthe input
preloadedif the input is preloaded
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN.

Eina_Bool ecore_audio_input_preloaded_get ( Ecore_Audio_Object input)

Get whether the input is preloaded.

Parameters
inthe input
Returns
EINA_TRUE if the input is preloaded, otherwise EINA_FALSE
Since
1.8

References EINA_FALSE, and EINA_SAFETY_ON_NULL_RETURN_VAL.

Ecore_Audio_Object* ecore_audio_input_output_get ( Ecore_Audio_Object input)

Get the outputs this input is connected to.

Parameters
inthe input
Returns
A list of outputs
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, and _Ecore_Audio_Input::output.

double ecore_audio_input_remaining_get ( Ecore_Audio_Object input)

Get the remaining time of the input.

Parameters
inthe input
Returns
The remaining time in seconds
Since
1.8

References EINA_SAFETY_ON_NULL_RETURN_VAL, input_api::input_seek, and _Ecore_Audio_Input::length.