CI13LC SDK API手册  2.1.1
本手册用于描述CI13LC SDK各个组件和驱动API
结构体 | 宏定义 | 枚举 | 函数 | 变量
simple_mp3_player.c 文件参考
#include <string.h>
#include "simple_mp3_player.h"
#include "FreeRTOS.h"
#include "queue.h"
#include "romlib_api.h"
#include "codec_manager.h"
#include "ci_log_config.h"
#include "mp3dec.h"
#include "ci_log.h"
#include "board.h"
#include "flash_rw_process.h"

结构体

struct  smp_msg_t
 
struct  ci_mp3_header_t
 
struct  smp_info_t
 

宏定义

#define SMP_SOURCE_DATA_BUF_SIZE   1024
 
#define SMP_MSG_QUEUE_LENGHT   20
 
#define SMP_PCM_BUF_COUNT   4
 

枚举

enum  smp_status_t {
  SMP_STATE_START,
  SMP_STATE_PLAY,
  SMP_STATE_STOP,
  SMP_STATE_IDLE
}
 

函数

static void task_simple_mp3_player (void *pvParameters)
 Task function of player 更多...
 
static void smp_send_msg (smp_msg_t *msg, BaseType_t *xHigherPriorityTaskWoken)
 
int smp_init (void)
 Initialize the simple mp3 player module. 更多...
 
int smp_play (uint32_t data_addr, void *play_end_callback)
 Start playing. 更多...
 
void smp_stop ()
 
void audio_play_set_vol_gain (int32_t gain)
 调节播放音量 更多...
 
void audio_play_hw_pa_da_ctl (FunctionalState cmd, bool is_control_pa)
 pa、da控制,可选择是否控制功放 更多...
 
static int smp_start_play_inner (smp_msg_t *msg)
 Inner start playing function. 更多...
 
static void wait_codec_play_finish ()
 
static int smp_decode_one_frame (void)
 Decode one frame. 更多...
 
static int smp_stop_play_inner (int32_t play_cb_state)
 

变量

smp_info_t smp_info
 

结构体说明

◆ smp_msg_t

struct smp_msg_t
成员变量
uint32_t data_addr
smp_msg_id_t msg_id
SMP_PLAY_END_CALLBACK play_end_callback

◆ ci_mp3_header_t

struct ci_mp3_header_t
成员变量
char CI[2]
uint32_t file_size
char flag
uint16_t frame_flag
char frame_ID[4]
uint32_t frame_size
char ID3[3]
uint32_t pcm_size
char revision
uint32_t total_frame_size
char ver

◆ smp_info_t

struct smp_info_t
成员变量
uint8_t channels
uint32_t data_addr
uint32_t decode_frame_count
HMP3Decoder decoder_handle
uint32_t frame_pcm_size
QueueHandle_t msg_queue
uint32_t output_samples
short * pcm_buffer
uint32_t pcm_buffer_size
SMP_PLAY_END_CALLBACK play_end_callback
uint32_t sample_rate
uint32_t source_buf_bytes_left
uint8_t source_data_buf[1024]
uint32_t source_file_bytes_left
uint32_t source_frame_size
smp_status_t state
uint32_t total_pcm_size

宏定义说明

◆ SMP_MSG_QUEUE_LENGHT

#define SMP_MSG_QUEUE_LENGHT   20

◆ SMP_PCM_BUF_COUNT

#define SMP_PCM_BUF_COUNT   4

◆ SMP_SOURCE_DATA_BUF_SIZE

#define SMP_SOURCE_DATA_BUF_SIZE   1024

枚举类型说明

◆ smp_status_t

枚举值
SMP_STATE_START 
SMP_STATE_PLAY 
SMP_STATE_STOP 
SMP_STATE_IDLE 

函数说明

◆ audio_play_hw_pa_da_ctl()

void audio_play_hw_pa_da_ctl ( FunctionalState  cmd,
bool  is_control_pa 
)

pa、da控制,可选择是否控制功放

参数
cmdpa使能或失能

◆ audio_play_set_vol_gain()

void audio_play_set_vol_gain ( int32_t  gain)

调节播放音量

参数
gain音量(0–100)

◆ smp_decode_one_frame()

static int smp_decode_one_frame ( void  )
static

Decode one frame.

返回
int 0: Decode failed; 1: Decode successed,and the PCM buffer of codec manager is full, you can do some delay before the next call to this function to free up CPU for other tasks; 2: Decode successed,and the PCM buffer of codec manager is not full, you'd better call this function again immediately. 3: End of file, there's no source data any more, end of play.

◆ smp_init()

int smp_init ( void  )

Initialize the simple mp3 player module.

返回
int 1: successed; not 1: failed.

◆ smp_play()

int smp_play ( uint32_t  data_addr,
void *  play_end_callback 
)

Start playing.

参数
data_addruint32_t It's used to specifiy the address of the mp3 data.
play_end_callbackA pointer to a function that will be called when play to end.
返回
int 1: successed; not 1: failed. t

◆ smp_send_msg()

static void smp_send_msg ( smp_msg_t msg,
BaseType_t *  xHigherPriorityTaskWoken 
)
static

◆ smp_start_play_inner()

static int smp_start_play_inner ( smp_msg_t msg)
static

Inner start playing function.

参数
msgA pointer to a smp_msg_t structure used to input data address and callback function.
返回
int 0:successed, not 0:failed.

◆ smp_stop()

void smp_stop ( )

◆ smp_stop_play_inner()

static int smp_stop_play_inner ( int32_t  play_cb_state)
static

◆ task_simple_mp3_player()

static void task_simple_mp3_player ( void *  pvParameters)
static

Task function of player

参数
pvParametersTask parameter.

◆ wait_codec_play_finish()

static void wait_codec_play_finish ( )
static

变量说明

◆ smp_info

smp_info_t smp_info
初始值:
= {
.msg_queue = NULL,
.state = SMP_STATE_IDLE,
.pcm_buffer = NULL,
.source_file_bytes_left = 0,
.source_buf_bytes_left = 0,
}
#define NULL
Definition: SEGGER_RTT.c:160
Definition: simple_mp3_player.c:23