#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "compiler.h"
#include "file.h"
#include "conf_audio_player.h"
#include "audio_mixer.h"
#include "mad.h"
#include "reader_id3.h"
#include "com_task.h"
#include "navigation.h"
#include "audio_interface.h"
Data Structures | |
struct | mp3_play_data |
This is a private message structure. More... | |
Macros | |
#define | FILEPOSDELAY 4000 |
#define | MP3_MAX_DATA_REQUESTED (2881 + MAD_BUFFER_GUARD) |
Maximal number of input bytes requested by the decoder at once. More... | |
#define | NBSAVFILEPOS 200 |
#define | OFFSETFILEPOS 50 |
#define | PCM_BUF_BYTE_SIZE (PCM_BUF_SAMP_SIZE * 2 * sizeof(int16_t)) |
Size of each PCM buffer in bytes. More... | |
#define | PCM_BUF_SAMP_SIZE 1152 |
Size of each PCM buffer in samples per channel. More... | |
Functions | |
static enum mad_flow | error (void *data, struct mad_stream *stream, struct mad_frame *frame) |
This is the error callback function. More... | |
static enum mad_flow | header (void *data, struct mad_header const *header) |
static enum mad_flow | input (void *data, struct mad_stream *stream) |
This is the input callback. More... | |
static enum mad_flow | output (void *data, const struct mad_header *header, struct mad_pcm *pcm) |
This is the output callback function. More... | |
bool | play_mp3 (const char *filename, bool verbose) |
This is the function called by ushell_task() to perform all the MP3 decoding. More... | |
Variables | |
uint16_t | cptms |
uint16_t | FilePosPtr |
uint32_t | g_player_currentTime_ms |
uint32_t | g_player_duration |
Ai_player_flag_t | g_player_flag |
uint32_t | g_player_target_file_pos |
uint8_t | g_smooth_com_cnt |
uint32_t | time_goal |
This is the header callback function. More... | |
uint32_t | TimeStampOffset |
uint32_t * | tSavFilePos |
#define FILEPOSDELAY 4000 |
Referenced by header().
#define MP3_MAX_DATA_REQUESTED (2881 + MAD_BUFFER_GUARD) |
Maximal number of input bytes requested by the decoder at once.
Referenced by input(), and play_mp3().
#define NBSAVFILEPOS 200 |
Referenced by header(), and play_mp3().
#define OFFSETFILEPOS 50 |
Referenced by header().
#define PCM_BUF_BYTE_SIZE (PCM_BUF_SAMP_SIZE * 2 * sizeof(int16_t)) |
Size of each PCM buffer in bytes.
Referenced by play_mp3().
#define PCM_BUF_SAMP_SIZE 1152 |
Size of each PCM buffer in samples per channel.
|
static |
This is the error callback function.
It is called whenever a decoding error occurs. The error is indicated by stream->error; the list of possible MAD_ERROR_* errors can be found in the mad.h (or stream.h) header file.
References data, mad_stream::error, mp3_play_data::frame_buf_guard, MAD_ERROR_LOSTSYNC, MAD_FLOW_CONTINUE, mad_stream::this_frame, and mp3_play_data::verbose.
Referenced by et024006_DrawFilledCircle(), and play_mp3().
|
static |
References cptms, data, mad_header::duration, file_seek(), FILEPOSDELAY, FilePosPtr, mad_timer_t::fraction, FS_SEEK_SET, g_player_currentTime_ms, g_player_duration, g_player_target_file_pos, MAD_FLOW_CONTINUE, MAD_FLOW_IGNORE, MAD_TIMER_RESOLUTION, mp3_play_data::mp3_pos, mp3_play_data::mp3_start_file_pos, NBSAVFILEPOS, OFFSETFILEPOS, PLAYER_FLAG_FFW, PLAYER_FLAG_FRW, PLAYER_FLAG_NORMAL, Ai_player_flag_t::status_fast, time_goal, TimeStampOffset, and tSavFilePos.
Referenced by play_mp3().
|
static |
This is the input callback.
The purpose of this callback is to (re)fill the stream buffer which is to be decoded.
References data, file_eof(), file_getpos(), file_read_buf(), mp3_play_data::frame_buf, mp3_play_data::frame_buf_data_size, mp3_play_data::frame_buf_end, mp3_play_data::frame_buf_guard, MAD_BUFFER_GUARD, MAD_FLOW_BREAK, MAD_FLOW_CONTINUE, MAD_FLOW_STOP, mad_stream_buffer(), mp3_play_data::mp3_end_file_pos, MP3_MAX_DATA_REQUESTED, mp3_play_data::mp3_pos, nav_checkdisk_disable(), nav_checkdisk_enable(), mad_stream::next_frame, PLAYER_FLAG_STOP, Ai_player_flag_t::status, and mp3_play_data::unrecoverable_error.
|
static |
This is the output callback function.
It is called after each frame of MPEG audio data has been completely decoded. The purpose of this callback is to output (or play) the decoded PCM audio.
References audio_mixer_dacs_flush, audio_mixer_dacs_output, audio_mixer_dacs_setup, audio_mixer_get_buffer, audio_mixer_mute_audio, mad_pcm::channels, com_task(), data, mad_header::duration, mp3_play_data::duration_played, fat_check_mount_select_open(), FS_NAV_ID_AUDIO, g_smooth_com_cnt, mad_pcm::length, MAD_FLOW_CONTINUE, MAD_FLOW_STOP, mad_timer_add(), mad_timer_compare(), mad_timer_zero, nav_select(), PLAYER_FLAG_NORMAL, PLAYER_FLAG_PAUSE, PLAYER_FLAG_PLAY, PLAYER_FLAG_STOP, mad_pcm::samplerate, mad_pcm::samples, Ai_player_flag_t::status, and Ai_player_flag_t::status_fast.
This is the function called by ushell_task() to perform all the MP3 decoding.
It instantiates a decoder object and configures it with the input, output, and error callback functions above. A single call to mad_decoder_run() continues until a callback function returns MAD_FLOW_STOP (to stop decoding) or MAD_FLOW_BREAK (to stop decoding and signal an error).
References St_id3size::appended_tag, audio_mixer_close, audio_mixer_create_buffers, audio_mixer_dacs_flush, cptms, error(), file_close(), file_open(), file_seek(), filename, FilePosPtr, FOPEN_MODE_R, mp3_play_data::frame_buf, mp3_play_data::frame_buf_end, mp3_play_data::frame_buf_guard, FS_NAV_ID_AUDIO, FS_SEEK_SET, header(), input, mad_decoder_finish(), mad_decoder_init(), MAD_DECODER_MODE_SYNC, mad_decoder_run(), mad_timer_zero, mp3_play_data::mp3_end_file_pos, MP3_MAX_DATA_REQUESTED, mp3_play_data::mp3_start_file_pos, nav_file_lgt(), nav_select(), NBSAVFILEPOS, output, PCM_BUF_BYTE_SIZE, St_id3size::prepended_tag, reader_id3_size(), time_goal, TimeStampOffset, tSavFilePos, and mp3_play_data::unrecoverable_error.
Referenced by codec_mp3_task().
uint16_t cptms |
Referenced by header(), and play_mp3().
uint16_t FilePosPtr |
Referenced by header(), and play_mp3().
uint32_t g_player_currentTime_ms |
Referenced by header().
uint32_t g_player_duration |
Referenced by header().
Ai_player_flag_t g_player_flag |
uint32_t g_player_target_file_pos |
Referenced by header().
uint8_t g_smooth_com_cnt |
Referenced by output().
uint32_t time_goal |
This is the header callback function.
It is called whenever a asf header is found
Referenced by header(), and play_mp3().
uint32_t TimeStampOffset |
Referenced by header(), and play_mp3().
uint32_t* tSavFilePos |
Referenced by header(), and play_mp3().