16 #include "../errors.hpp" 17 #include "../messages.h" 18 #include "../response.hpp" 63 std::unique_ptr<AudioSink> sink)
64 : src(
std::move(src)), sink(
std::move(sink))
71 return this->
src->Path();
76 assert(this->
sink !=
nullptr);
87 return this->
sink->State();
92 assert(this->
sink !=
nullptr);
93 assert(this->
src !=
nullptr);
95 return this->
src->MicrosFromSamples(this->
sink->Position());
100 assert(this->
sink !=
nullptr);
101 assert(this->
src !=
nullptr);
103 auto in_samples = this->
src->SamplesFromMicros(position);
104 auto out_samples = this->
src->Seek(in_samples);
105 this->
sink->SetPosition(out_samples);
120 assert(this->
sink !=
nullptr);
121 assert(this->
src !=
nullptr);
124 if (!more_available) this->
sink->SourceOut();
128 return this->
sink->State();
133 assert(!this->
frame.empty());
134 assert(this->
sink !=
nullptr);
135 assert(this->
src !=
nullptr);
148 assert(this->
frame.empty() ||
163 assert(this->
src !=
nullptr);
166 this->
frame = result.second;
std::uint64_t Position() const override
This Audio's current position.
Declaration of the AudioSource class.
State
Enumeration of possible states for this Audio.
const std::string & File() const override
This Audio's current file.
Audio::State CurrentState() const override
The state of this Audio.
const std::string MSG_CMD_NEEDS_LOADED
Message shown when a command that works only when a file is loaded is fired when there isn't anything...
void SetPosition(std::uint64_t position) override
Attempts to seek to the given position.
Declaration of the Audio class.
bool FrameFinished() const
Returns whether the current frame has been finished.
std::uint64_t Position() const override
This Audio's current position.
Audio::State Update() override
Performs an update cycle on this Audio.
void TransferFrame()
Transfers as much of the current frame as possible to the sink.
bool DecodeIfFrameEmpty()
Decodes a new frame, if the current frame is empty.
void SetPlaying(bool playing) override
Sets whether this Audio should be playing or not.
const std::string & File() const override
This Audio's current file.
AudioSource::DecodeVector::iterator frame_iterator
The current position in the current decoded frame.
The decoder has run out of things to decode.
AudioSource::DecodeVector frame
The current decoded frame.
Audio::State Update() override
Performs an update cycle on this Audio.
Declaration of the AudioSink class.
void SetPosition(std::uint64_t position) override
Attempts to seek to the given position.
void SetPlaying(bool playing) override
Sets whether this Audio should be playing or not.
Audio::State CurrentState() const override
The state of this Audio.
PipeAudio(std::unique_ptr< AudioSource > src, std::unique_ptr< AudioSink > sink)
Constructs a PipeAudio from a source and a sink.
std::pair< DecodeState, DecodeVector > DecodeResult
Type of the result of Decode().
void ClearFrame()
Clears the current frame and its iterator.
std::unique_ptr< AudioSource > src
The source of audio data.
An Error signifying that no audio is loaded.
std::unique_ptr< AudioSink > sink
The sink to which audio data is sent.