mirror of
https://github.com/m5stack/CoreS3-Box.git
synced 2026-05-20 10:59:43 -07:00
factory demo - SR broadcast no sound; Playing the next track keeps decreasing the volume
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "ui_sr.h"
|
||||
#include "app_sr_handler.h"
|
||||
#include "settings.h"
|
||||
#include "es8311.h"
|
||||
|
||||
|
||||
static const char *TAG = "sr_handler";
|
||||
@@ -79,10 +80,17 @@ static esp_err_t sr_echo_play(audio_segment_t audio)
|
||||
size_t len = g_audio_data[audio].len - sizeof(wav_header_t);
|
||||
len = len & 0xfffffffc;
|
||||
ESP_LOGD(TAG, "frame_rate=%d, ch=%d, width=%d", wav_head->SampleRate, wav_head->NumChannels, wav_head->BitsPerSample);
|
||||
i2s_set_clk(I2S_NUM_0,wav_head->SampleRate,wav_head->BitsPerSample,I2S_CHANNEL_STEREO);
|
||||
|
||||
i2s_zero_dma_buffer(I2S_NUM_0);
|
||||
sys_param_t *param = settings_get_parameter();
|
||||
bsp_codec_set_voice_volume(param->volume);
|
||||
es8311_set_voice_mute(false);
|
||||
ESP_LOGI(TAG, "bsp_codec_set_voice_volume=%d", param->volume);
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
bsp_board_power_ctrl(POWER_MODULE_AUDIO, true);// turn on the speaker
|
||||
|
||||
size_t bytes_written = 0;
|
||||
b_audio_playing = true;
|
||||
i2s_write(I2S_NUM_0, p, len, &bytes_written, portMAX_DELAY);
|
||||
|
||||
@@ -70,12 +70,9 @@ static esp_err_t audio_mute_function(AUDIO_PLAYER_MUTE_SETTING setting) {
|
||||
// as es8311_set_voice_mute(true) results in voice volume (REG32) being set to zero.
|
||||
static int last_volume;
|
||||
|
||||
ESP_LOGI(TAG, "mute setting %d", setting);
|
||||
int volume;
|
||||
|
||||
ESP_RETURN_ON_ERROR(es8311_codec_get_voice_volume(&volume), TAG, "get voice volume");
|
||||
if(volume != 0) {
|
||||
last_volume = volume;
|
||||
sys_param_t *param = settings_get_parameter();
|
||||
if(param->volume != 0) {
|
||||
last_volume = param->volume;
|
||||
}
|
||||
|
||||
ESP_RETURN_ON_ERROR(es8311_set_voice_mute(setting == AUDIO_PLAYER_MUTE ? true : false), TAG, "set voice mute");
|
||||
@@ -85,6 +82,8 @@ static esp_err_t audio_mute_function(AUDIO_PLAYER_MUTE_SETTING setting) {
|
||||
es8311_codec_set_voice_volume(last_volume);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "mute setting %d, volume:%d", setting, last_volume);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user