diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-16 10:57:55 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-16 10:57:55 +1000 |
| commit | 4e27de21e49900963ffa61cc9c0a676bb028f992 (patch) | |
| tree | 8123994d33bc2ff8b5d58a38155b53e401669ae8 /src/audio/include/fatfs_source.hpp | |
| parent | 62dce8d9fcc139ca6dc2041c86723d19faab304f (diff) | |
| download | tangara-fw-4e27de21e49900963ffa61cc9c0a676bb028f992.tar.gz | |
clean up a bunch of obselete audio code
Diffstat (limited to 'src/audio/include/fatfs_source.hpp')
| -rw-r--r-- | src/audio/include/fatfs_source.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/audio/include/fatfs_source.hpp b/src/audio/include/fatfs_source.hpp new file mode 100644 index 00000000..e4187d60 --- /dev/null +++ b/src/audio/include/fatfs_source.hpp @@ -0,0 +1,44 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <cstddef> +#include <cstdint> +#include <memory> + +#include "codec.hpp" +#include "ff.h" + +#include "audio_source.hpp" + +namespace audio { + +/* + * Handles coordination with a persistent background task to asynchronously + * read files from disk into a StreamBuffer. + */ +class FatfsSource : public codecs::IStream { + public: + FatfsSource(codecs::StreamType, std::unique_ptr<FIL> file); + ~FatfsSource(); + + auto Read(cpp::span<std::byte> dest) -> ssize_t override; + + auto CanSeek() -> bool override; + + auto SeekTo(int64_t destination, SeekFrom from) -> void override; + + auto CurrentPosition() -> int64_t override; + + FatfsSource(const FatfsSource&) = delete; + FatfsSource& operator=(const FatfsSource&) = delete; + + private: + std::unique_ptr<FIL> file_; +}; + +} // namespace audio
\ No newline at end of file |
