@@ -192,7 +192,7 @@ static void audioout_convert_s16s_u8s(
192192 * out_buffer_size = in_buffer_size / 2 ;
193193}
194194
195- #define CONV_MATCH (bps ,sign ,ichans ,ochans ) ( (bps& 0xf) | ((sign& 0x1)<< 4) | ((ichans& 0x3)<< 5) | ((ochans& 0x3)<<7) )
195+ #define CONV_MATCH (bps , sign , ichans , ochans ) ((bps & 0xf) | ((sign & 0x1) << 4) | ((ichans & 0x3) << 5) | ((ochans & 0x3) << 7) )
196196
197197static audioout_sample_convert_func_t audioout_get_samples_convert_func (
198198 size_t in_bits_per_sample ,
@@ -201,36 +201,36 @@ static audioout_sample_convert_func_t audioout_get_samples_convert_func(
201201 int out_channels ) {
202202
203203 switch CONV_MATCH (in_bits_per_sample , in_signed , in_channels , out_channels ) {
204- case CONV_MATCH (8 ,false,1 , 1 ):
205- case CONV_MATCH (8 ,false,2 , 2 ):
204+ case CONV_MATCH (8 , false, 1 , 1 ):
205+ case CONV_MATCH (8 , false, 2 , 2 ):
206206 return audioout_convert_noop ;
207- case CONV_MATCH (8 ,false,2 , 1 ):
207+ case CONV_MATCH (8 , false, 2 , 1 ):
208208 return audioout_convert_u8s_u8m ;
209- case CONV_MATCH (8 ,false,1 , 2 ):
209+ case CONV_MATCH (8 , false, 1 , 2 ):
210210 return audioout_convert_u8m_u8s ;
211- case CONV_MATCH (8 ,true,1 , 1 ):
211+ case CONV_MATCH (8 , true, 1 , 1 ):
212212 return audioout_convert_s8m_u8m ;
213- case CONV_MATCH (8 ,true,2 , 1 ):
213+ case CONV_MATCH (8 , true, 2 , 1 ):
214214 return audioout_convert_s8s_u8m ;
215- case CONV_MATCH (8 ,true,1 , 2 ):
215+ case CONV_MATCH (8 , true, 1 , 2 ):
216216 return audioout_convert_s8m_u8s ;
217- case CONV_MATCH (8 ,true,2 , 2 ):
217+ case CONV_MATCH (8 , true, 2 , 2 ):
218218 return audioout_convert_s8s_u8s ;
219- case CONV_MATCH (16 ,false,1 , 1 ):
219+ case CONV_MATCH (16 , false, 1 , 1 ):
220220 return audioout_convert_u16m_u8m ;
221- case CONV_MATCH (16 ,false,1 , 2 ):
221+ case CONV_MATCH (16 , false, 1 , 2 ):
222222 return audioout_convert_u16m_u8s ;
223- case CONV_MATCH (16 ,false,2 , 1 ):
223+ case CONV_MATCH (16 , false, 2 , 1 ):
224224 return audioout_convert_u16s_u8m ;
225- case CONV_MATCH (16 ,false,2 , 2 ):
225+ case CONV_MATCH (16 , false, 2 , 2 ):
226226 return audioout_convert_u16s_u8s ;
227- case CONV_MATCH (16 ,true,1 , 1 ):
227+ case CONV_MATCH (16 , true, 1 , 1 ):
228228 return audioout_convert_s16m_u8m ;
229- case CONV_MATCH (16 ,true,1 , 2 ):
229+ case CONV_MATCH (16 , true, 1 , 2 ):
230230 return audioout_convert_s16m_u8s ;
231- case CONV_MATCH (16 ,true,2 , 1 ):
231+ case CONV_MATCH (16 , true, 2 , 1 ):
232232 return audioout_convert_s16s_u8m ;
233- case CONV_MATCH (16 ,true,2 , 2 ):
233+ case CONV_MATCH (16 , true, 2 , 2 ):
234234 return audioout_convert_s16s_u8s ;
235235 default :
236236 mp_raise_RuntimeError (MP_ERROR_TEXT ("audio format not supported" ));
@@ -247,7 +247,7 @@ static bool audioout_fill_buffer(audioio_audioout_obj_t *self) {
247247 uint8_t dma_buf_idx = self -> get_buffer_index ;
248248
249249 if (dma_buf_idx == self -> put_buffer_index ) {
250- return false;
250+ return false;
251251 }
252252
253253 self -> get_buffer_index = INCREMENT_BUF_IDX (dma_buf_idx );
@@ -267,7 +267,7 @@ static bool audioout_fill_buffer(audioio_audioout_obj_t *self) {
267267 if (self -> sample_buffer != NULL && self -> sample_buffer_size > 0 ) {
268268 sample_buf = self -> sample_buffer ;
269269 sample_buf_size = self -> sample_buffer_size ;
270- get_buffer_result = self -> sample_buffer_result ;
270+ get_buffer_result = self -> sample_buffer_result ;
271271 } else {
272272 get_buffer_result = audiosample_get_buffer (self -> sample ,
273273 single_channel_output ,
@@ -320,7 +320,9 @@ static bool audioout_fill_buffer(audioio_audioout_obj_t *self) {
320320}
321321
322322static void audioout_fill_buffers (audioio_audioout_obj_t * self ) {
323- while (audioout_fill_buffer (self ));
323+ while (audioout_fill_buffer (self )) {
324+ ;
325+ }
324326}
325327
326328static void audioout_buf_callback_fun (void * user_data ) {
@@ -357,11 +359,11 @@ static void audioout_init(audioio_audioout_obj_t *self) {
357359 dac_continuous_config_t cfg = {
358360 .chan_mask = self -> channel_mask ,
359361 .desc_num = NUM_DMA_BUFFERS ,
360- .buf_size = DMA_BUFFER_SIZE ,
362+ .buf_size = DMA_BUFFER_SIZE ,
361363 .freq_hz = self -> freq_hz ,
362364 .offset = 0 ,
363365 .clk_src = DAC_DIGI_CLK_SRC_APLL ,
364- .chan_mode = self -> channel_mode ,
366+ .chan_mode = self -> channel_mode ,
365367 };
366368
367369 esp_err_t ret ;
@@ -381,7 +383,7 @@ static void audioout_init(audioio_audioout_obj_t *self) {
381383
382384 dac_event_callbacks_t callbacks = {
383385 .on_convert_done = handle_convert_done ,
384- .on_stop = NULL ,
386+ .on_stop = NULL ,
385387 };
386388
387389 ret = dac_continuous_register_event_callback (self -> handle , & callbacks , (void * )self );
@@ -411,29 +413,29 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self,
411413 * if different pins are supplied for left and right then use true stereo.
412414 * if the same pin is supplied for left and right then use dual mono.
413415 */
414- if ( (left_channel_pin == & pin_CHANNEL_0 &&
415- right_channel_pin == & pin_CHANNEL_1 ) ||
416- (left_channel_pin == & pin_CHANNEL_1 &&
417- right_channel_pin == & pin_CHANNEL_0 ) ) {
416+ if ((left_channel_pin == & pin_CHANNEL_0 &&
417+ right_channel_pin == & pin_CHANNEL_1 ) ||
418+ (left_channel_pin == & pin_CHANNEL_1 &&
419+ right_channel_pin == & pin_CHANNEL_0 )) {
418420 self -> channel_mask = DAC_CHANNEL_MASK_ALL ;
419- self -> num_channels = 2 ;
420- self -> channel_mode = DAC_CHANNEL_MODE_ALTER ;
421- } else if ( (left_channel_pin == & pin_CHANNEL_0 ||
422- left_channel_pin == & pin_CHANNEL_1 ) &&
423- right_channel_pin == left_channel_pin ) {
421+ self -> num_channels = 2 ;
422+ self -> channel_mode = DAC_CHANNEL_MODE_ALTER ;
423+ } else if ((left_channel_pin == & pin_CHANNEL_0 ||
424+ left_channel_pin == & pin_CHANNEL_1 ) &&
425+ right_channel_pin == left_channel_pin ) {
424426 self -> channel_mask = DAC_CHANNEL_MASK_ALL ;
425427 self -> num_channels = 1 ;
426- self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
428+ self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
427429 } else if (left_channel_pin == & pin_CHANNEL_0 &&
428430 right_channel_pin == NULL ) {
429- self -> channel_mask = DAC_CHANNEL_MASK_CH0 ;
431+ self -> channel_mask = DAC_CHANNEL_MASK_CH0 ;
430432 self -> num_channels = 1 ;
431- self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
433+ self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
432434 } else if (left_channel_pin == & pin_CHANNEL_1 &&
433435 right_channel_pin == NULL ) {
434- self -> channel_mask = DAC_CHANNEL_MASK_CH1 ;
436+ self -> channel_mask = DAC_CHANNEL_MASK_CH1 ;
435437 self -> num_channels = 1 ;
436- self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
438+ self -> channel_mode = DAC_CHANNEL_MODE_SIMUL ;
437439 } else {
438440 raise_ValueError_invalid_pin ();
439441 }
@@ -553,7 +555,7 @@ void common_hal_audioio_audioout_stop(audioio_audioout_obj_t *self) {
553555}
554556
555557bool common_hal_audioio_audioout_get_playing (audioio_audioout_obj_t * self ) {
556- return self -> playing && !self -> paused ;
558+ return self -> playing && !self -> paused ;
557559}
558560
559561#else
@@ -566,20 +568,25 @@ bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t *self) {
566568 return true;
567569}
568570
569- void common_hal_audioio_audioout_deinit (audioio_audioout_obj_t * self ) {}
571+ void common_hal_audioio_audioout_deinit (audioio_audioout_obj_t * self ) {
572+ }
570573
571574void common_hal_audioio_audioout_play (audioio_audioout_obj_t * self ,
572- mp_obj_t sample , bool loop ) {}
575+ mp_obj_t sample , bool loop ) {
576+ }
573577
574- void common_hal_audioio_audioout_pause (audioio_audioout_obj_t * self ) {}
578+ void common_hal_audioio_audioout_pause (audioio_audioout_obj_t * self ) {
579+ }
575580
576- void common_hal_audioio_audioout_resume (audioio_audioout_obj_t * self ) {}
581+ void common_hal_audioio_audioout_resume (audioio_audioout_obj_t * self ) {
582+ }
577583
578584bool common_hal_audioio_audioout_get_paused (audioio_audioout_obj_t * self ) {
579585 return false;
580586}
581587
582- void common_hal_audioio_audioout_stop (audioio_audioout_obj_t * self ) {}
588+ void common_hal_audioio_audioout_stop (audioio_audioout_obj_t * self ) {
589+ }
583590
584591bool common_hal_audioio_audioout_get_playing (audioio_audioout_obj_t * self ) {
585592 return false;
0 commit comments