summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio/audio_converter.cpp2
-rw-r--r--src/audio/audio_decoder.cpp2
-rw-r--r--src/drivers/include/i2s_dac.hpp10
3 files changed, 8 insertions, 6 deletions
diff --git a/src/audio/audio_converter.cpp b/src/audio/audio_converter.cpp
index 77773c5b..dc2fef95 100644
--- a/src/audio/audio_converter.cpp
+++ b/src/audio/audio_converter.cpp
@@ -25,7 +25,7 @@
[[maybe_unused]] static constexpr char kTag[] = "mixer";
static constexpr std::size_t kSampleBufferLength =
- drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2;
+ drivers::kI2SBufferLengthFrames * sizeof(sample::Sample);
static constexpr std::size_t kSourceBufferLength = kSampleBufferLength * 2;
namespace audio {
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp
index 5b057240..bd728e5a 100644
--- a/src/audio/audio_decoder.cpp
+++ b/src/audio/audio_decoder.cpp
@@ -48,7 +48,7 @@ namespace audio {
[[maybe_unused]] static const char* kTag = "audio_dec";
static constexpr std::size_t kCodecBufferLength =
- drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2;
+ drivers::kI2SBufferLengthFrames * sizeof(sample::Sample);
Timer::Timer(std::shared_ptr<Track> t,
const codecs::ICodec::OutputFormat& format)
diff --git a/src/drivers/include/i2s_dac.hpp b/src/drivers/include/i2s_dac.hpp
index fdd7e976..bd837ca0 100644
--- a/src/drivers/include/i2s_dac.hpp
+++ b/src/drivers/include/i2s_dac.hpp
@@ -27,10 +27,12 @@
namespace drivers {
-// We normalise to 2-channel, 16 bit audio, which gives us a max of 4092 / 2 / 2
-// (16 bits) frames. This in turn means that at 48kHz, we have about 10ms of
-// budget to fill each buffer.
-constexpr size_t kI2SBufferLengthFrames = 512;
+// DMA max buffer size for I2S is 4092. We normalise to 2-channel, 16 bit
+// audio, which gives us a max of 4092 / 2 / 2 (16 bits) frames. This in turn
+// means that at 48kHz, we have about 21ms of budget to fill each buffer.
+// We base this off of the maximum DMA size in order to minimise the amount of
+// work the CPU has to do to service the DMA callbacks.
+constexpr size_t kI2SBufferLengthFrames = 1024;
/**
* Interface for a DAC that receives PCM samples over I2S.