URY playd
C++ minimalist audio player
AudioSink Class Referenceabstract

Abstract class for audio output sinks. More...

#include <audio_sink.hpp>

+ Inheritance diagram for AudioSink:

Public Types

using TransferIterator = AudioSource::DecodeVector::iterator
 Type of iterators used in the Transfer() method.
 

Public Member Functions

virtual ~AudioSink ()=default
 Virtual, empty destructor for AudioSink.
 
virtual void Start ()=0
 Starts the audio stream. More...
 
virtual void Stop ()=0
 Stops the audio stream. More...
 
virtual Audio::State State ()
 Gets this AudioSink's current state (playing/stopped/at end). More...
 
virtual std::uint64_t Position ()=0
 Gets the current played position in the song, in samples. More...
 
virtual void SetPosition (std::uint64_t samples)=0
 Sets the current played position, given a position in samples. More...
 
virtual void SourceOut ()=0
 Tells this AudioSink that the source has run out. More...
 
virtual void Transfer (TransferIterator &start, const TransferIterator &end)=0
 Transfers a range of sample bytes into the AudioSink. More...
 

Detailed Description

Abstract class for audio output sinks.

Definition at line 28 of file audio_sink.hpp.

Member Function Documentation

§ Position()

virtual std::uint64_t AudioSink::Position ( )
pure virtual

Gets the current played position in the song, in samples.

As this may be executing whilst the playing callback is running, do not expect it to be highly accurate.

Returns
The current position, as a count of elapsed samples.

Implemented in SdlAudioSink.

§ SetPosition()

virtual void AudioSink::SetPosition ( std::uint64_t  samples)
pure virtual

Sets the current played position, given a position in samples.

This flushes out the AudioSink ready to receive sample data from the new position.

Parameters
samplesThe new position, as a count of elapsed samples.
See also
Position

Implemented in SdlAudioSink.

§ SourceOut()

virtual void AudioSink::SourceOut ( )
pure virtual

Tells this AudioSink that the source has run out.

When this occurs, the next time the ringbuf goes empty, the sink has also run out and should stop.

Implemented in SdlAudioSink.

§ Start()

virtual void AudioSink::Start ( )
pure virtual

Starts the audio stream.

See also
Stop
IsHalted

Implemented in SdlAudioSink.

§ State()

Audio::State AudioSink::State ( )
virtual

Gets this AudioSink's current state (playing/stopped/at end).

Returns
The Audio::State representing this AudioSink's state.
See also
Audio::State

Reimplemented in SdlAudioSink.

Definition at line 31 of file audio_sink.cpp.

References SdlAudioSink::FORMATS, Audio::NONE, and SdlAudioSink::RINGBUF_POWER.

32 {
33  return Audio::State::NONE;
34 }
There is no Audio.

§ Stop()

virtual void AudioSink::Stop ( )
pure virtual

Stops the audio stream.

See also
Start
IsHalted

Implemented in SdlAudioSink.

§ Transfer()

virtual void AudioSink::Transfer ( TransferIterator start,
const TransferIterator end 
)
pure virtual

Transfers a range of sample bytes into the AudioSink.

The range may be empty, but must be valid.

  • Precondition: start <= end, start and end point to a valid contiguous block of sample bytes.
  • Postcondition: start <= end, old(start) <= start, *start and end point to a valid contiguous block of sample bytes.
Parameters
startAn iterator denoting the start of the range. This iterator will be advanced by the number of bytes accepted.
endAn iterator denoting the end of the range.

Implemented in SdlAudioSink.


The documentation for this class was generated from the following files: