#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#include <assert.h>
#include <stdbool.h>
#include <sys/time.h>
#include "common.h"
#include "audio.h"
#include "mp3.h"
#include "parsetime.h"
#include "report.h"
#include "snprintf/snprintf.h"
Go to the source code of this file.
Defines | |
#define | AUDIO_MAGIC_NUMBER 0x6B2F6EEF |
Functions | |
bool | open_file (struct_audio_data_t *data, const char *fname) |
audio_file_t | get_file_type (const char *file) |
bool | is_new_file (struct_audio_data_t *data) |
void * | audio_decoder (void *) |
void * | audio_decoder (audio_data_t _data) |
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 progress_ms) |
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 status, const char *daisy_status_msg), void(*progress)(void *data, long int progress_ms)) |
void * | audio_thread (void *_data) |
audio_state_t | audio_get_state (audio_data_t _data) |
|
Includes Definition at line 57 of file audio.c. Referenced by audio_decoder(), audio_initiate(), audio_pause(), audio_play(), audio_stop(), audio_terminate(), audio_thread(), callback(), is_new_file(), and open_file(). |
|
Finds out the type of file and starts the aproporiate decoder.
Definition at line 222 of file audio.c. References aac_initiate(), aac_play(), aac_terminate(), audio_data_t, AUDIO_FILE_AAC, AUDIO_FILE_MP3, AUDIO_MAGIC_NUMBER, AUDIO_STATE_STOP, audio_state_t, struct_audio_data_t::do_callback_done, struct_audio_data_t::file_name, get_file_type(), is_new_file(), struct_audio_data_t::is_playing, struct_audio_data_t::magic, mp3_close(), mp3_init(), mp3_play(), struct_audio_data_t::mutex, struct_audio_data_t::prev_file_type, REP_DEBUG, REP_MESSAGE, report(), and struct_audio_data_t::state. |
|
Referenced by audio_thread(). |
|
Returns the current 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(). |
|
|
Pause audio. Sets the audio engine state to pause.
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(). |
|
Plays a file from start to stop.
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(). |
|
Stops audio. Sets the state to stop and blocks to make sure that audio has actually stopped.
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(). |
|
Stops and frees audio engine resources. This is called when the user wants us to terminate.
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(). |
|
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.
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. |
|
callback is called by the decoder loop.
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(). |
|
Returns the filetype based on const char *fname. This is used by audio_decoder to start the apropriate audio decoder.
Definition at line 183 of file audio.c. References AUDIO_FILE_MP3, audio_file_t, REP_DEBUG, and report(). Referenced by audio_decoder(), and open_file(). |
|
Checks if this file is new.
Definition at line 196 of file audio.c. References AUDIO_MAGIC_NUMBER, struct_audio_data_t::file_name, struct_audio_data_t::magic, and struct_audio_data_t::prev_file_name. Referenced by audio_decoder(). |
|
Opens an audio file (if it's not already opened). This function will load a file if it's not already loaded. The freeing and generating of mmaps are handled here.
Definition at line 90 of file audio.c. References AUDIO_MAGIC_NUMBER, struct_audio_data_t::cb_error, struct_audio_data_t::daisy, DAISY_ERROR_AUDIO_CREATE_MMAP, DAISY_ERROR_AUDIO_FREE_MMAP, DAISY_ERROR_AUDIO_FSTAT, DAISY_ERROR_AUDIO_MALLOC, DAISY_ERROR_AUDIO_OPEN, struct_audio_data_t::fd, struct_audio_data_t::fdm, struct_audio_data_t::file_name, struct_audio_data_t::file_type, get_file_type(), struct_audio_data_t::magic, struct_audio_data_t::prev_file_type, REP_DEBUG, REP_ERROR, REP_WARNING, report(), struct_audio_data_t::stat, and STRLEN. Referenced by audio_play(). |