Main Page   Data Structures   File List   Data Fields   Globals  

audio.h File Reference

#include <mad.h>
#include <ao/ao.h>
#include <sys/stat.h>
#include <pthread.h>
#include "daisylibao.h"
#include "libdaisy.h"

Go to the source code of this file.

Data Structures

struct  buffer
struct  struct_audio_data_t

Typedefs

typedef void * audio_data_t
typedef enum AUDIO_FILE_TYPE audio_file_t

Enumerations

enum  AUDIO_FILE_TYPE { AUDIO_FILE_WAV, AUDIO_FILE_MP3, AUDIO_FILE_AAC, AUDIO_FILE_UNKNOWN }
enum  audio_state_t { AUDIO_STATE_PLAY, AUDIO_STATE_PAUSE, AUDIO_STATE_STOP, AUDIO_STATE_NOOP }

Functions

unsigned long int audio_play (audio_data_t _data, const char *fname, const char *start, const char *stop)
int audio_pause (audio_data_t _data)
int audio_stop (audio_data_t _data)
int callback (audio_data_t _data, long int)
void audio_terminate (audio_data_t _data)
audio_data_t audio_initiate (daisyplayer_t daisy, void(*done)(daisyplayer_t d), void(*error)(void *data, enum daisy_status, const char *), void(*progress)(void *data, long int progress_ms))
void * audio_thread (void *_data)
audio_state_t audio_get_state (audio_data_t _data)


Typedef Documentation

typedef void* audio_data_t
 

Points to a struct_audio_data_t. This gives the user a possibility to refer to a struct_audio_data_t, but not access to it's internal data.

Definition at line 54 of file audio.h.

Referenced by audio_decoder(), audio_get_state(), audio_initiate(), audio_pause(), audio_play(), audio_stop(), audio_terminate(), callback(), error(), header(), input(), output(), start_audio(), and stop_audio().

typedef enum AUDIO_FILE_TYPE audio_file_t
 

Type to identify different audio file formats.

Referenced by get_file_type().


Enumeration Type Documentation

enum AUDIO_FILE_TYPE
 

Type to identify different audio file formats.

Enumeration values:
AUDIO_FILE_WAV 
AUDIO_FILE_MP3 
AUDIO_FILE_AAC 
AUDIO_FILE_UNKNOWN 

Definition at line 59 of file audio.h.

enum audio_state_t
 

Audio engine states. These are the different states the audio-engine can be in.

Enumeration values:
AUDIO_STATE_PLAY 
AUDIO_STATE_PAUSE 
AUDIO_STATE_STOP 
AUDIO_STATE_NOOP 

Definition at line 71 of file audio.h.

Referenced by audio_decoder(), audio_get_state(), audio_pause(), audio_thread(), daisy_goto_position(), and daisy_seek().


Function Documentation

audio_state_t audio_get_state audio_data_t    _data
 

Returns the current state of the audio engine.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.
Returns:
the currant state of the audio engine

Definition at line 717 of file audio.c.

References audio_data_t, audio_state_t, struct_audio_data_t::mutex, and struct_audio_data_t::state.

Referenced by audio_terminate(), daisy_goto_position(), and daisy_seek().

audio_data_t audio_initiate daisyplayer_t    daisy,
void(*    done)(daisyplayer_t d),
void(*    error)(void *data, enum daisy_status, const char *),
void(*    progress)(void *data, long int progress_ms)
 

Initiate the audio engine. This is called when the program wants us to start and prepare for audio playback This should allocate the basic resources needed by the audio engine.

Parameters:
-  daisy the daisy struct
-  done the callback function that will be called once a segment have been played.
-  error the callback function that will be called when errors occur.
-  progress the callback function that will be called during playback.

Referenced by start_audio().

int audio_pause audio_data_t    _data
 

Pause audio. Sets the audio engine state to pause.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.
Returns:
1 on success, -1 on fail.

Definition at line 357 of file audio.c.

References audio_data_t, AUDIO_MAGIC_NUMBER, AUDIO_STATE_NOOP, AUDIO_STATE_PAUSE, AUDIO_STATE_PLAY, audio_state_t, struct_audio_data_t::cb_error, struct_audio_data_t::daisy, DAISY_ERROR_AUDIO_PAUSED_WHILE_NOT_PLAYING, struct_audio_data_t::is_playing, struct_audio_data_t::magic, struct_audio_data_t::mutex, REP_DEBUG, report(), struct_audio_data_t::state, and struct_audio_data_t::unpause_cond.

Referenced by daisy_pause().

unsigned long int audio_play audio_data_t    _data,
const char *    fname,
const char *    start,
const char *    stop
 

Plays a file from start to stop.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.
const  char *fname - the filename.
const  char *start - the start time as a string in a DAISY compliant format.
const  char *stop - the stop time as a string in a DAISY compliant format.
Returns:
the duration in milliseconds or -1 if fail.

Definition at line 314 of file audio.c.

References audio_data_t, AUDIO_MAGIC_NUMBER, AUDIO_STATE_PLAY, AUDIO_STATE_STOP, struct_audio_data_t::cb_error, struct_audio_data_t::daisy, DAISY_ERROR_AUDIO_NOT_STOPPED, DAISY_ERROR_AUDIO_OPEN, struct_audio_data_t::magic, struct_audio_data_t::mutex, open_file(), parse_time_get_dur(), parse_time_mad_time_t(), struct_audio_data_t::progress, REP_ERROR, REP_WARNING, report(), struct_audio_data_t::start, struct_audio_data_t::state, struct_audio_data_t::stop, and STRLEN.

Referenced by daisy_play().

int audio_stop audio_data_t    _data
 

Stops audio. Sets the state to stop and blocks to make sure that audio has actually stopped.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.
Returns:
1 on success, -1 on fail.

Definition at line 402 of file audio.c.

References audio_data_t, AUDIO_MAGIC_NUMBER, AUDIO_STATE_PLAY, AUDIO_STATE_STOP, struct_audio_data_t::cb_error, struct_audio_data_t::daisy, DAISY_ERROR_AUDIO_DATA_IS_NULL, DAISY_ERROR_AUDIO_STOPPED_WHILE_NOT_PLAYING, daisy_status, struct_audio_data_t::is_playing, struct_audio_data_t::magic, struct_audio_data_t::mutex, REP_DEBUG, report(), and struct_audio_data_t::state.

Referenced by audio_terminate(), daisy_goto_position(), daisy_seek(), and daisy_stop().

void audio_terminate audio_data_t    _data
 

Stops and frees audio engine resources. This is called when the user wants us to terminate.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.

Definition at line 494 of file audio.c.

References aac_terminate(), audio_data_t, audio_get_state(), AUDIO_MAGIC_NUMBER, AUDIO_STATE_STOP, audio_stop(), struct_audio_data_t::cb_error, struct_audio_data_t::daisy, DAISY_ERROR_AUDIO_FREE_MMAP, struct_audio_data_t::fd, struct_audio_data_t::fdm, struct_audio_data_t::file_name, struct_audio_data_t::file_type, struct_audio_data_t::magic, mp3_close(), struct_audio_data_t::mp3_dither, struct_audio_data_t::mutex, REP_MESSAGE, report(), and struct_audio_data_t::stat.

Referenced by stop_audio().

void* audio_thread void *    _data
 

Audio thread. This is run as a thread from daisyplayer.c and keeps the audio-engine alive. audio_initiate MUST be called before this function. audio_terminate MUST be called once you are done using the audio engine.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.

Definition at line 635 of file audio.c.

References audio_decoder(), AUDIO_MAGIC_NUMBER, AUDIO_STATE_PLAY, AUDIO_STATE_STOP, audio_state_t, struct_audio_data_t::cb_playing_done, struct_audio_data_t::daisy, daisyplayer_t, struct_audio_data_t::do_callback_done, struct_audio_data_t::is_playing, struct_audio_data_t::magic, struct_audio_data_t::mutex, REP_DEBUG, report(), and struct_audio_data_t::state.

int callback audio_data_t    _data,
long int    progress_ms
 

callback is called by the decoder loop.

Parameters:
audio_data_t  _data - the struct_audio_data_t that is passed to almost all functions in the audio module.
-  progress_ms the progress (so far) in the current segment. value is in milliseconds.
Returns:
0 to continue or -1 to stop decoding.

Definition at line 461 of file audio.c.

References audio_data_t, AUDIO_MAGIC_NUMBER, AUDIO_STATE_PAUSE, AUDIO_STATE_STOP, struct_audio_data_t::cb_progress, struct_audio_data_t::daisy, struct_audio_data_t::magic, struct_audio_data_t::mutex, REP_DEBUG, report(), struct_audio_data_t::state, and struct_audio_data_t::unpause_cond.

Referenced by header().


Generated on Tue Sep 5 12:14:08 2006 for libdaisy by doxygen1.2.15