@@ -80,6 +80,8 @@ void i2s_reset(void) {
80
80
}
81
81
}
82
82
83
+ #define I2S_WRITE_DELAY pdMS_TO_TICKS(1)
84
+
83
85
static void i2s_fill_buffer (i2s_t * self ) {
84
86
if (self -> instance < 0 || self -> instance >= I2S_NUM_MAX ) {
85
87
return ;
@@ -92,7 +94,7 @@ static void i2s_fill_buffer(i2s_t *self) {
92
94
93
95
size_t bytes_written = 0 ;
94
96
do {
95
- CHECK_ESP_RESULT (i2s_write (self -> instance , signed_samples , sizeof (signed_samples ), & bytes_written , 0 ));
97
+ CHECK_ESP_RESULT (i2s_write (self -> instance , signed_samples , sizeof (signed_samples ), & bytes_written , I2S_WRITE_DELAY ));
96
98
} while (bytes_written != 0 );
97
99
return ;
98
100
}
@@ -120,9 +122,9 @@ static void i2s_fill_buffer(i2s_t *self) {
120
122
size_t bytecount = self -> sample_end - self -> sample_data ;
121
123
if (self -> samples_signed && self -> channel_count == 2 ) {
122
124
if (self -> bytes_per_sample == 2 ) {
123
- CHECK_ESP_RESULT (i2s_write (self -> instance , self -> sample_data , bytecount , & bytes_written , 0 ));
125
+ CHECK_ESP_RESULT (i2s_write (self -> instance , self -> sample_data , bytecount , & bytes_written , I2S_WRITE_DELAY ));
124
126
} else {
125
- CHECK_ESP_RESULT (i2s_write_expand (self -> instance , self -> sample_data , bytecount , 8 , 16 , & bytes_written , 0 ));
127
+ CHECK_ESP_RESULT (i2s_write_expand (self -> instance , self -> sample_data , bytecount , 8 , 16 , & bytes_written , I2S_WRITE_DELAY ));
126
128
}
127
129
} else {
128
130
const size_t bytes_per_output_frame = 4 ;
@@ -151,7 +153,7 @@ static void i2s_fill_buffer(i2s_t *self) {
151
153
}
152
154
}
153
155
size_t expanded_bytes_written = 0 ;
154
- CHECK_ESP_RESULT (i2s_write (self -> instance , signed_samples , bytes_per_output_frame * framecount , & expanded_bytes_written , 0 ));
156
+ CHECK_ESP_RESULT (i2s_write (self -> instance , signed_samples , bytes_per_output_frame * framecount , & expanded_bytes_written , I2S_WRITE_DELAY ));
155
157
assert (expanded_bytes_written % 4 == 0 );
156
158
bytes_written = expanded_bytes_written / bytes_per_output_frame * bytes_per_input_frame ;
157
159
}
0 commit comments