summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/chunk.cpp2
-rw-r--r--src/audio/fatfs_audio_input.cpp5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/audio/chunk.cpp b/src/audio/chunk.cpp
index fb7f1354..abc42bc7 100644
--- a/src/audio/chunk.cpp
+++ b/src/audio/chunk.cpp
@@ -16,7 +16,7 @@ namespace audio {
ChunkReader::ChunkReader(std::size_t chunk_size)
: raw_working_buffer_(static_cast<std::byte*>(
- heap_caps_malloc(chunk_size * 1.5, MALLOC_CAP_SPIRAM))),
+ heap_caps_malloc(chunk_size * 2, MALLOC_CAP_SPIRAM))),
working_buffer_(raw_working_buffer_, chunk_size * 1.5) {}
ChunkReader::~ChunkReader() {
diff --git a/src/audio/fatfs_audio_input.cpp b/src/audio/fatfs_audio_input.cpp
index 14176eae..08f39347 100644
--- a/src/audio/fatfs_audio_input.cpp
+++ b/src/audio/fatfs_audio_input.cpp
@@ -20,7 +20,7 @@ static const char* kTag = "SRC";
namespace audio {
// 32KiB to match the minimum himen region size.
-static const std::size_t kChunkSize = 32 * 1024;
+static const std::size_t kChunkSize = 24 * 1024;
FatfsAudioInput::FatfsAudioInput(std::shared_ptr<drivers::SdStorage> storage)
: IAudioElement(),
@@ -88,7 +88,8 @@ auto FatfsAudioInput::Process() -> cpp::result<void, AudioProcessingError> {
dest_event->chunk_data.bytes.first(bytes_read);
SendOrBufferEvent(std::move(dest_event));
- if (f_eof(&current_file_)) {
+ if (bytes_read < kChunkSize || f_eof(&current_file_)) {
+ ESP_LOGI(kTag, "closing file");
f_close(&current_file_);
is_file_open_ = false;
}