@@ -584,7 +584,6 @@ if (_cfg.pin_bck < 0 || _cfg.pin_ws < 0) {
584584 dst_remain = current_rec->length ;
585585 if (dst_remain == 0 )
586586 {
587- self->_is_recording = false ;
588587 ulTaskNotifyTake ( pdTRUE, portMAX_DELAY );
589588 src_idx = ~0u ;
590589 src_len = 0 ;
@@ -593,7 +592,6 @@ if (_cfg.pin_bck < 0 || _cfg.pin_ws < 0) {
593592 continue ;
594593 }
595594 }
596- self->_is_recording = true ;
597595
598596 for (;;)
599597 {
@@ -702,7 +700,6 @@ if (_cfg.pin_bck < 0 || _cfg.pin_ws < 0) {
702700 }
703701 }
704702 }
705- self->_is_recording = false ;
706703 _i2s_stop (self->_cfg .i2s_port );
707704
708705 self->_task_handle = nullptr ;
@@ -736,13 +733,16 @@ if (_cfg.pin_bck < 0 || _cfg.pin_ws < 0) {
736733#if portNUM_PROCESSORS > 1
737734 if (_cfg.task_pinned_core < portNUM_PROCESSORS)
738735 {
739- xTaskCreatePinnedToCore (mic_task, " mic_task" , stack_size, this , _cfg.task_priority , &_task_handle, _cfg.task_pinned_core );
736+ res = (pdPASS == xTaskCreatePinnedToCore (mic_task, " mic_task" , stack_size, this , _cfg.task_priority , &_task_handle, _cfg.task_pinned_core ) );
740737 }
741738 else
742739#endif
743740 {
744- xTaskCreate (mic_task, " mic_task" , stack_size, this , _cfg.task_priority , &_task_handle);
741+ res = (pdPASS == xTaskCreate (mic_task, " mic_task" , stack_size, this , _cfg.task_priority , &_task_handle) );
745742 }
743+ // end() takes the driver and the callback back down; it still sees the
744+ // class as running, which is what lets it do that.
745+ if (!res) { end (); }
746746 }
747747
748748 return res;
@@ -758,6 +758,10 @@ if (_cfg.pin_bck < 0 || _cfg.pin_ws < 0) {
758758 do { vTaskDelay (1 ); } while (_task_handle);
759759 }
760760
761+ // an unfinished request would otherwise keep isRecording() reporting a recording.
762+ _rec_info[0 ] = recording_info_t ();
763+ _rec_info[1 ] = recording_info_t ();
764+
761765 if (_cb_set_enabled) { _cb_set_enabled (_cb_set_enabled_args, false ); }
762766 _i2s_driver_uninstall (_cfg.i2s_port );
763767 }
0 commit comments