34 int sample_rate{48000};
37 static constexpr std::size_t ring_size = 65536;
38 std::vector<std::vector<float>> ring;
39 std::atomic<std::size_t> write_pos{0};
40 std::atomic<std::size_t> read_pos{0};
43 std::vector<ossia::float_vector>* output_data{};
45 void init(
int nchannels);
46 void write_planar(
float** data,
int num_samples,
int channels);
47 void write_interleaved_float(
const float* data,
int num_samples,
int channels);
48 void write_interleaved_s16(
const int16_t* data,
int num_samples,
int channels);
49 void read_into_output(
int block_size);
63 bool load(
const std::string& url)
noexcept;
65 const std::string& url,
66 const std::map<std::string, std::string>& options)
noexcept;
70 bool probe()
noexcept;
72 bool start()
noexcept override;
73 void stop()
noexcept override;
75 AVFrame* dequeue_frame()
noexcept override;
76 void release_frame(AVFrame* frame)
noexcept override;
78 bool has_audio()
const noexcept {
return m_audioStream !=
nullptr; }
80 const std::string& url()
const noexcept {
return m_url; }
83 void buffer_thread()
noexcept;
84 void close_file()
noexcept;
85 bool open_streams()
noexcept;
86 void close_streams()
noexcept;
87 void decode_audio_packet(AVPacket& packet)
noexcept;
90 std::map<std::string, std::string> m_options;
93 AVStream* m_audioStream{};
94 const AVCodec* m_audioCodec{};
95 AVCodecContext* m_audioCodecContext{};
96 AVFrame* m_audioFrame{};
100 static const constexpr auto probe_timeout = std::chrono::milliseconds(10000);
104 std::thread m_thread;
105 std::atomic_bool m_running{};
113 bool m_needsPacing{
false};