You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
901 B
44 lines
901 B
/*
|
|
* 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
|