summaryrefslogtreecommitdiff
path: root/src/audio/audio_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-10-19 13:01:28 +1100
committerjacqueline <me@jacqueline.id.au>2023-10-19 13:01:28 +1100
commit912f9c0757a911b10478a2b498d551dc1fe6e7e4 (patch)
treef6e7bbdb0fd724e1d735141921f2029652ccc27f /src/audio/audio_fsm.cpp
parent782e8dc8c25402171fc4724075b998eae4fa2c76 (diff)
downloadtangara-fw-912f9c0757a911b10478a2b498d551dc1fe6e7e4.tar.gz
Free the i2s dma channel when it's not in use
It turns out this is why bluetooth playback keeps running out of memory /facepalm
Diffstat (limited to 'src/audio/audio_fsm.cpp')
-rw-r--r--src/audio/audio_fsm.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index 5020a6ef..7480934b 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -98,13 +98,6 @@ namespace states {
void Uninitialised::react(const system_fsm::BootComplete& ev) {
sServices = ev.services;
- auto dac = drivers::I2SDac::create(sServices->gpios());
- if (!dac) {
- events::System().Dispatch(system_fsm::FatalError{});
- events::Ui().Dispatch(system_fsm::FatalError{});
- return;
- }
-
constexpr size_t kDrainBufferSize =
drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2 * 8;
ESP_LOGI(kTag, "allocating drain buffer, size %u KiB",
@@ -113,8 +106,7 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) {
kDrainBufferSize, sizeof(sample::Sample) * 2, MALLOC_CAP_DMA);
sFileSource.reset(new FatfsAudioInput(sServices->tag_parser()));
- sI2SOutput.reset(new I2SAudioOutput(stream, sServices->gpios(),
- std::unique_ptr<drivers::I2SDac>{*dac}));
+ sI2SOutput.reset(new I2SAudioOutput(stream, sServices->gpios()));
sBtOutput.reset(new BluetoothAudioOutput(stream, sServices->bluetooth()));
auto& nvs = sServices->nvs();