mirror of
https://github.com/esphome/esphome.git
synced 2025-07-27 21:56:34 +00:00
[i2s_audio] Check for a nullptr before disabling and deleting channel (#9062)
This commit is contained in:
parent
be58cdda3b
commit
bd85ba9b6a
@ -317,15 +317,18 @@ void I2SAudioMicrophone::stop_driver_() {
|
|||||||
ESP_LOGW(TAG, "Error uninstalling I2S driver - it may not have started: %s", esp_err_to_name(err));
|
ESP_LOGW(TAG, "Error uninstalling I2S driver - it may not have started: %s", esp_err_to_name(err));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Have to stop the channel before deleting it */
|
if (this->rx_handle_ != nullptr) {
|
||||||
err = i2s_channel_disable(this->rx_handle_);
|
/* Have to stop the channel before deleting it */
|
||||||
if (err != ESP_OK) {
|
err = i2s_channel_disable(this->rx_handle_);
|
||||||
ESP_LOGW(TAG, "Error stopping I2S microphone - it may not have started: %s", esp_err_to_name(err));
|
if (err != ESP_OK) {
|
||||||
}
|
ESP_LOGW(TAG, "Error stopping I2S microphone - it may not have started: %s", esp_err_to_name(err));
|
||||||
/* If the handle is not needed any more, delete it to release the channel resources */
|
}
|
||||||
err = i2s_del_channel(this->rx_handle_);
|
/* If the handle is not needed any more, delete it to release the channel resources */
|
||||||
if (err != ESP_OK) {
|
err = i2s_del_channel(this->rx_handle_);
|
||||||
ESP_LOGW(TAG, "Error deleting I2S channel - it may not have started: %s", esp_err_to_name(err));
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "Error deleting I2S channel - it may not have started: %s", esp_err_to_name(err));
|
||||||
|
}
|
||||||
|
this->rx_handle_ = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
this->parent_->unlock();
|
this->parent_->unlock();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user