@@ -40,7 +40,7 @@ void render_sample_block(short *sample_buff_ch0, short *sample_buff_ch1, int num
40
40
}
41
41
42
42
size_t bytes_written = 0 ;
43
- for (int i = 0 ; i < num_samples ; i ++ ) {
43
+ for (int i = 0 ; i < num_samples ; i ++ ) {
44
44
/* low - high / low - high */
45
45
const char samp32 [4 ] = {ptr_l [0 ], ptr_l [1 ], ptr_r [0 ], ptr_r [1 ]}; // ESP32 CPU is little-endian
46
46
@@ -82,7 +82,7 @@ static void audio_buffer_reset(void)
82
82
83
83
static void audio_render_task (void * pvParameter )
84
84
{
85
- bool clear = true ;
85
+ bool clear = false ;
86
86
bool start = false;
87
87
uint16_t count = 0 ;
88
88
EventBits_t uxBits = 0 ;
@@ -94,18 +94,13 @@ static void audio_render_task(void *pvParameter)
94
94
uint32_t size = 0 ;
95
95
uint32_t remain = 0 ;
96
96
97
- xEventGroupWaitBits (
98
- user_event_group ,
99
- AUDIO_RENDER_RUN_BIT ,
100
- pdFALSE ,
101
- pdFALSE ,
102
- portMAX_DELAY
103
- );
104
-
105
- if (!clear ) {
97
+ uxBits = xEventGroupGetBits (user_event_group );
98
+ if (!clear && !(uxBits & AUDIO_RENDER_CLR_BIT )) {
106
99
audio_buffer_reset ();
107
100
108
101
clear = true;
102
+
103
+ xEventGroupSetBits (user_event_group , AUDIO_RENDER_CLR_BIT );
109
104
}
110
105
111
106
if (start ) {
@@ -143,6 +138,8 @@ static void audio_render_task(void *pvParameter)
143
138
} else {
144
139
if (xRingbufferGetCurFreeSize (audio_buff ) < 512 ) {
145
140
start = true;
141
+
142
+ xEventGroupClearBits (user_event_group , AUDIO_RENDER_CLR_BIT );
146
143
} else {
147
144
vTaskDelay (1 / portTICK_RATE_MS );
148
145
}
@@ -213,8 +210,6 @@ static void audio_render_task(void *pvParameter)
213
210
214
211
void audio_render_init (void )
215
212
{
216
- xEventGroupSetBits (user_event_group , AUDIO_RENDER_RUN_BIT );
217
-
218
213
memset (& buff_struct , 0x00 , sizeof (StaticRingbuffer_t ));
219
214
audio_buff = xRingbufferCreateStatic (sizeof (buff_data ), RINGBUF_TYPE_BYTEBUF , buff_data , & buff_struct );
220
215
0 commit comments