Fork of Tangara with customizations
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.
tangara-fw/src/audio/include/fatfs_audio_input.hpp

45 lines
1.1 KiB

#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include "chunk.hpp"
#include "freertos/FreeRTOS.h"
2 years ago
#include "freertos/message_buffer.h"
#include "freertos/queue.h"
#include "span.hpp"
#include "audio_element.hpp"
#include "storage.hpp"
#include "stream_buffer.hpp"
namespace audio {
class FatfsAudioInput : public IAudioElement {
public:
explicit FatfsAudioInput(std::shared_ptr<drivers::SdStorage> storage);
~FatfsAudioInput();
auto HasUnprocessedInput() -> bool override;
auto ProcessStreamInfo(const StreamInfo& info)
-> cpp::result<void, AudioProcessingError> override;
auto ProcessChunk(const cpp::span<std::byte>& chunk)
-> cpp::result<std::size_t, AudioProcessingError> override;
auto ProcessEndOfStream() -> void override;
auto Process() -> cpp::result<void, AudioProcessingError> override;
FatfsAudioInput(const FatfsAudioInput&) = delete;
FatfsAudioInput& operator=(const FatfsAudioInput&) = delete;
private:
std::shared_ptr<drivers::SdStorage> storage_;
FIL current_file_;
bool is_file_open_;
};
} // namespace audio