33 int sample_rate{48000};
36 static constexpr std::size_t ring_size = 65536;
37 std::vector<std::vector<float>> ring;
38 std::atomic<std::size_t> write_pos{0};
39 std::atomic<std::size_t> read_pos{0};
42 std::vector<ossia::float_vector>* output_data{};
44 void init(
int nchannels);
45 void write_planar(
float** data,
int num_samples,
int channels);
46 void write_interleaved_float(
const float* data,
int num_samples,
int channels);
47 void write_interleaved_s16(
const int16_t* data,
int num_samples,
int channels);
48 void read_into_output(
int block_size);
62 bool load(
const std::string& url)
noexcept;
64 const std::string& url,
65 const std::map<std::string, std::string>& options)
noexcept;
69 bool probe()
noexcept;
71 bool start()
noexcept override;
72 void stop()
noexcept override;
74 AVFrame* dequeue_frame()
noexcept override;
75 void release_frame(AVFrame* frame)
noexcept override;
77 bool has_audio()
const noexcept {
return m_audioStream !=
nullptr; }
79 const std::string& url()
const noexcept {
return m_url; }
82 void buffer_thread()
noexcept;
83 void close_file()
noexcept;
84 bool open_streams()
noexcept;
85 void close_streams()
noexcept;
86 void decode_audio_packet(AVPacket& packet)
noexcept;
89 std::map<std::string, std::string> m_options;
92 AVStream* m_audioStream{};
93 const AVCodec* m_audioCodec{};
94 AVCodecContext* m_audioCodecContext{};
95 AVFrame* m_audioFrame{};
99 std::atomic_bool m_running{};
107 bool m_needsPacing{
false};