修改部分调试打印代码
This commit is contained in:
parent
fafa916aca
commit
a315492cc2
@ -9,16 +9,6 @@ add_subdirectory(Third_Party/fatfs)
|
||||
add_subdirectory(Third_Party/dr_libs)
|
||||
add_subdirectory(Third_Party/tlsf)
|
||||
|
||||
# 屏蔽第三方库中的警告
|
||||
# target_compile_options(FLAC PRIVATE
|
||||
# -Wformat=0
|
||||
# -Wno-incompatible-pointer-types
|
||||
# )
|
||||
|
||||
# target_compile_options(grabbag PRIVATE
|
||||
# -Wformat=0
|
||||
# )
|
||||
|
||||
# target_compile_options(lvgl_demos PRIVATE
|
||||
# -Wformat=0
|
||||
# )
|
||||
|
||||
@ -13,11 +13,11 @@ const static char *TAG = "audio_flac";
|
||||
|
||||
static size_t flac_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED_Y_GPIO_Port, LED_Y_Pin);
|
||||
|
||||
UINT br;
|
||||
FRESULT f_result = f_read(pUserData, pBufferOut, bytesToRead, &br); //从文件中读取新的内容
|
||||
|
||||
HAL_GPIO_TogglePin(LED_Y_GPIO_Port, LED_Y_Pin);
|
||||
|
||||
if (f_result != FR_OK) {
|
||||
elog_error(TAG, "file read error");
|
||||
return 0;
|
||||
@ -62,12 +62,17 @@ static void* flac_malloc(size_t sz, void* pUserData)
|
||||
{
|
||||
UNUSED(pUserData);
|
||||
|
||||
if (sz == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *ptr = malloc(sz);
|
||||
|
||||
// tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
// tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
// elog_debug(TAG, "flac_malloc: allocated %d bytes memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
// sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "flac_malloc: allocated %d bytes memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
if (ptr == NULL) {
|
||||
elog_error(TAG, "flac_malloc: error while allocating %d bytes of memory", sz);
|
||||
}
|
||||
@ -81,6 +86,11 @@ static void* flac_realloc(void* p, size_t sz, void* pUserData)
|
||||
|
||||
void *ptr = realloc(p, sz);
|
||||
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "flac_realloc: allocated %d bytes new memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
if (ptr == NULL) {
|
||||
elog_error(TAG, "flac_realloc: error while allocating %d bytes of new memory", sz);
|
||||
}
|
||||
@ -92,10 +102,14 @@ static void flac_free(void* p, void* pUserData)
|
||||
{
|
||||
UNUSED(pUserData);
|
||||
|
||||
// tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
// tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
// elog_debug(TAG, "flac_free: memory freed @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
// p, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "flac_free: memory freed @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
p, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
static const char *TAG = "audio_hal";
|
||||
|
||||
typedef struct {
|
||||
void *buffer_ptr;
|
||||
const void *buffer_ptr;
|
||||
uint32_t buffer_size;
|
||||
} audio_sample_t;
|
||||
|
||||
@ -86,7 +86,7 @@ void audio_hal_stop(void)
|
||||
audio_buffer = NULL;
|
||||
}
|
||||
|
||||
void audio_hal_write(void *buffer_ptr, uint32_t buffer_size)
|
||||
void audio_hal_write(const void *buffer_ptr, uint32_t buffer_size)
|
||||
{
|
||||
if (buffer_size == 0) {
|
||||
return;
|
||||
|
||||
@ -7,6 +7,6 @@
|
||||
|
||||
void audio_hal_start(uint32_t sample_count, uint8_t sample_size);
|
||||
void audio_hal_stop(void);
|
||||
void audio_hal_write(void *buffer, uint32_t sample_count);
|
||||
void audio_hal_write(const void *buffer, uint32_t sample_count);
|
||||
|
||||
#endif
|
||||
|
||||
@ -12,11 +12,11 @@ const static char *TAG = "player_mp3";
|
||||
|
||||
static size_t mp3_read(void* pUserData, void* pBufferOut, size_t bytesToRead)
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED_Y_GPIO_Port, LED_Y_Pin);
|
||||
|
||||
UINT br;
|
||||
FRESULT f_result = f_read(pUserData, pBufferOut, bytesToRead, &br); //从文件中读取新的内容
|
||||
|
||||
HAL_GPIO_TogglePin(LED_Y_GPIO_Port, LED_Y_Pin);
|
||||
|
||||
if (f_result != FR_OK) {
|
||||
elog_error(TAG, "file read error");
|
||||
return 0;
|
||||
@ -62,12 +62,17 @@ static void* mp3_malloc(size_t sz, void* pUserData)
|
||||
{
|
||||
UNUSED(pUserData);
|
||||
|
||||
if (sz == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *ptr = malloc(sz);
|
||||
|
||||
// tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
// tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
// elog_debug(TAG, "mp3_malloc: allocated %d bytes memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
// sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "mp3_malloc: allocated %d bytes memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
if (ptr == NULL) {
|
||||
elog_error(TAG, "mp3_malloc: error while allocating %d bytes of memory", sz);
|
||||
}
|
||||
@ -81,6 +86,11 @@ static void* mp3_realloc(void* p, size_t sz, void* pUserData)
|
||||
|
||||
void *ptr = realloc(p, sz);
|
||||
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "mp3_realloc: allocated %d bytes new memory @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
sz, ptr, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
if (ptr == NULL) {
|
||||
elog_error(TAG, "mp3_realloc: error while allocating %d bytes of new memory", sz);
|
||||
}
|
||||
@ -92,10 +102,14 @@ static void mp3_free(void* p, void* pUserData)
|
||||
{
|
||||
UNUSED(pUserData);
|
||||
|
||||
// tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
// tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
// elog_debug(TAG, "mp3_free: memory freed @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
// p, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
tlsf_pool_statistics *axi_heap_statistics = get_axi_heap_statistics();
|
||||
tlsf_pool_statistics *ahb_heap_statistics = get_ahb_heap_statistics();
|
||||
elog_debug(TAG, "mp3_free: memory freed @%p, free memory: AXI %d bytes, AHB %d bytes",
|
||||
p, axi_heap_statistics->free_size, ahb_heap_statistics->free_size);
|
||||
|
||||
free(p);
|
||||
}
|
||||
@ -107,14 +121,6 @@ static const drmp3_allocation_callbacks mp3_allocation_cbs = {
|
||||
.pUserData = NULL
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 播放MP3文件
|
||||
*
|
||||
* @param file_name 文件路径
|
||||
* @return esp_err_t 错误代码
|
||||
*
|
||||
* @note 本函数需要至少25600字节任务栈空间
|
||||
*/
|
||||
void music_mp3_play(const char *file_name)
|
||||
{
|
||||
FIL *file = malloc(sizeof(FIL));
|
||||
@ -154,7 +160,7 @@ void music_mp3_play(const char *file_name)
|
||||
uint32_t sample_count = drmp3_read_pcm_frames_s16(&mp3, DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME, pcm_sample); //解码新一帧MP3数据
|
||||
|
||||
if (sample_count != 0) {
|
||||
audio_hal_write(pcm_sample, DRMP3_MAX_SAMPLES_PER_FRAME * sizeof(drmp3_int16)); ///将解码后的PCM数据写入SAI
|
||||
audio_hal_write(pcm_sample, DRMP3_MAX_SAMPLES_PER_FRAME * sizeof(drmp3_int16)); //将解码后的PCM数据写入SAI
|
||||
} else {
|
||||
free(pcm_sample);
|
||||
elog_info(TAG, "play done");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user