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/audio_sink.hpp

25 lines
668 B

#pragma once
#include "audio_element.hpp"
#include "stream_info.hpp"
namespace audio {
class IAudioSink {
private:
// TODO: tune. at least about 12KiB seems right for mp3
static const std::size_t kDrainBufferSize = 24 * 1024;
StreamBufferHandle_t buffer_;
public:
IAudioSink() : buffer_(xStreamBufferCreate(kDrainBufferSize, 1)) {}
virtual ~IAudioSink() { vStreamBufferDelete(buffer_); }
virtual auto Configure(const StreamInfo::Format& format) -> bool = 0;
virtual auto Send(const cpp::span<std::byte>& data) -> void = 0;
virtual auto Log() -> void {}
auto buffer() const -> StreamBufferHandle_t { return buffer_; }
};
} // namespace audio