31 int sample_rate{48000};
34 static constexpr std::size_t ring_size = 65536;
35 std::vector<std::vector<float>> ring;
36 std::atomic<std::size_t> write_pos{0};
37 std::atomic<std::size_t> read_pos{0};
40 std::vector<ossia::float_vector>* output_data{};
42 void init(
int nchannels);
43 void write_planar(
float** data,
int num_samples,
int channels);
44 void write_interleaved_float(
const float* data,
int num_samples,
int channels);
45 void write_interleaved_s16(
const int16_t* data,
int num_samples,
int channels);
46 void read_into_output(
int block_size);
60 bool load(
const std::string& url)
noexcept;
62 const std::string& url,
63 const std::map<std::string, std::string>& options)
noexcept;
67 bool probe()
noexcept;
69 bool start()
noexcept override;
70 void stop()
noexcept override;
72 AVFrame* dequeue_frame()
noexcept override;
73 void release_frame(AVFrame* frame)
noexcept override;
75 bool has_audio()
const noexcept {
return m_audioStream !=
nullptr; }
77 const std::string& url()
const noexcept {
return m_url; }
80 void buffer_thread()
noexcept;
81 void close_file()
noexcept;
82 bool open_streams()
noexcept;
83 void close_streams()
noexcept;
84 void decode_audio_packet(AVPacket& packet)
noexcept;
87 std::map<std::string, std::string> m_options;
90 AVStream* m_audioStream{};
91 const AVCodec* m_audioCodec{};
92 AVCodecContext* m_audioCodecContext{};
93 AVFrame* m_audioFrame{};
97 std::atomic_bool m_running{};
105 bool m_needsPacing{
false};