Skip to content

Commit 3d72757

Browse files
committed
audio_render: code clean up
1 parent 5c3b4ea commit 3d72757

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

main/src/user/audio_render.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
void render_sample_block(short *sample_buff_ch0, short *sample_buff_ch1, int num_samples, unsigned int num_channels)
1717
{
1818
// pointer to left / right sample position
19-
char *ptr_l = (char*)sample_buff_ch0;
20-
char *ptr_r = (char*)sample_buff_ch1;
19+
char *ptr_l = (char *)sample_buff_ch0;
20+
char *ptr_r = (char *)sample_buff_ch1;
2121
uint8_t stride = sizeof(short);
2222

2323
if (num_channels == 1) {
@@ -27,20 +27,16 @@ void render_sample_block(short *sample_buff_ch0, short *sample_buff_ch1, int num
2727
size_t bytes_written = 0;
2828
for (int i = 0; i < num_samples; i++) {
2929
/* low - high / low - high */
30-
const char samp32[4] = {ptr_l[0], ptr_l[1], ptr_r[0], ptr_r[1]}; // ESP32 CPU is Little Endian
30+
const char samp32[4] = {ptr_l[0], ptr_l[1], ptr_r[0], ptr_r[1]}; // ESP32 CPU is little-endian
31+
3132
i2s_write(CONFIG_AUDIO_OUTPUT_I2S_NUM, (const char *)&samp32, sizeof(samp32), &bytes_written, portMAX_DELAY);
3233

33-
// DMA buffer full - retry
34-
if (bytes_written == 0) {
35-
i--;
36-
} else {
37-
ptr_l += stride;
38-
ptr_r += stride;
39-
}
34+
ptr_l += stride;
35+
ptr_r += stride;
4036
}
4137
}
4238

43-
/* Called by the NXP modifications of libmad. Sets the needed output sample rate. */
39+
/* frame callback for the libmad synth, set the needed output sample rate */
4440
void set_dac_sample_rate(int rate)
4541
{
4642
i2s_output_set_sample_rate(rate);

0 commit comments

Comments
 (0)