Skip to content

Commit

Permalink
I2S: register I2S object to platform failed (#568)
Browse files Browse the repository at this point in the history
ESP32: When calling destructor after stop, and then create a new object, then an error is shown "I2S: register I2S object to platform failed" because i2s_driver_uninstall had not been called.
ESP8266 : i2s_end is not called when stopping, but i2sOn is false, resulting in new call i2s_rxtx_begin
  • Loading branch information
FedericoBusero committed Sep 1, 2022
1 parent 72ed4f7 commit f95f15f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/AudioOutputI2S.cpp
Expand Up @@ -67,18 +67,7 @@ AudioOutputI2S::AudioOutputI2S(long sampleRate, pin_size_t sck, pin_size_t data)

AudioOutputI2S::~AudioOutputI2S()
{
#ifdef ESP32
if (i2sOn) {
audioLogger->printf("UNINSTALL I2S\n");
i2s_driver_uninstall((i2s_port_t)portNo); //stop & destroy i2s driver
}
#elif defined(ESP8266)
if (i2sOn)
i2s_end();
#elif defined(ARDUINO_ARCH_RP2040)
stop();
#endif
i2sOn = false;
stop();
}

bool AudioOutputI2S::SetPinout()
Expand Down Expand Up @@ -359,6 +348,10 @@ bool AudioOutputI2S::stop()

#ifdef ESP32
i2s_zero_dma_buffer((i2s_port_t)portNo);
audioLogger->printf("UNINSTALL I2S\n");
i2s_driver_uninstall((i2s_port_t)portNo); //stop & destroy i2s driver
#elif defined(ESP8266)
i2s_end();
#elif defined(ARDUINO_ARCH_RP2040)
i2s.end();
#endif
Expand Down

2 comments on commit f95f15f

@riraosan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that when I use i2s_driver_uninstall to remove the driver for I2S1, I2S0 is also removed at the same time.
I think I should modify the code. What should I do? @earlephilhower

@riraosan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using I2S0 and I2S1 at the same time.

Please sign in to comment.