From bf1fc5a2a0f408a8d8a54d4329257a10d077c4fb Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 5 Oct 2023 14:23:48 +1100 Subject: Guard audio pipeline file accesses --- src/audio/fatfs_source.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/audio/fatfs_source.cpp') diff --git a/src/audio/fatfs_source.cpp b/src/audio/fatfs_source.cpp index 7fe4adf9..a5d172e7 100644 --- a/src/audio/fatfs_source.cpp +++ b/src/audio/fatfs_source.cpp @@ -15,6 +15,7 @@ #include "audio_source.hpp" #include "codec.hpp" +#include "spi.hpp" #include "types.hpp" namespace audio { @@ -25,10 +26,12 @@ FatfsSource::FatfsSource(codecs::StreamType t, std::unique_ptr file) : IStream(t), file_(std::move(file)) {} FatfsSource::~FatfsSource() { + auto lock = drivers::acquire_spi(); f_close(file_.get()); } auto FatfsSource::Read(cpp::span dest) -> ssize_t { + auto lock = drivers::acquire_spi(); if (f_eof(file_.get())) { return 0; } @@ -46,6 +49,7 @@ auto FatfsSource::CanSeek() -> bool { } auto FatfsSource::SeekTo(int64_t destination, SeekFrom from) -> void { + auto lock = drivers::acquire_spi(); switch (from) { case SeekFrom::kStartOfStream: f_lseek(file_.get(), destination); -- cgit v1.2.3