39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#pragma once
|
|
#include <cstddef>
|
|
#include <memory>
|
|
#include <string>
|
|
extern "C" {
|
|
#include <libavutil/frame.h>
|
|
}
|
|
|
|
namespace playback {
|
|
// One decoding worker produces output. The native audio callback is the consumer.
|
|
// Audio is interleaved stereo float at 48 kHz; write() never blocks.
|
|
class Output {
|
|
public:
|
|
Output();
|
|
~Output();
|
|
Output(const Output &) = delete;
|
|
Output &operator=(const Output &) = delete;
|
|
bool configure_audio(std::string &error);
|
|
bool start(std::string &error);
|
|
void pause();
|
|
// Atomic target gain; callback slews to it within 240 frames (5 ms).
|
|
void set_volume(float normalized0to1) noexcept;
|
|
float volume() const noexcept;
|
|
// Called with audio stopped. Clears audio; optionally keeps the displayed frame.
|
|
void reset(bool clear_video = true);
|
|
std::size_t write(const float *samples, std::size_t frames, double pts);
|
|
std::size_t queued() const;
|
|
// Latency-aware presented position; NaN until an audio callback has run.
|
|
double clock() const;
|
|
// Retains the frame's buffers; decoder may reuse its AVFrame after return.
|
|
void present(const AVFrame *frame);
|
|
// Returns a retained NSView. The view remains safe after Output is destroyed.
|
|
void *make_video_view();
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl;
|
|
};
|
|
}
|