10 #ifndef PLAYD_AUDIO_SINK_HPP    11 #define PLAYD_AUDIO_SINK_HPP    42     virtual void Start() = 0;
    49     virtual void Stop() = 0;
    64     virtual std::uint64_t 
Position() = 0;
    73     virtual void SetPosition(std::uint64_t samples) = 0;
   121     void Start() 
override;
   122     void Stop() 
override;
   137     void Callback(std::uint8_t *out, 
int nbytes);
   144     static std::vector<std::pair<int, std::string>> GetDevicesInfo();
   151     static bool IsOutputDevice(
int id);
   154     static void InitLibrary();
   157     static void CleanupLibrary();
   168     static const std::array<SDL_AudioFormat, SAMPLE_FORMAT_COUNT> 
FORMATS;
   186 #endif // PLAYD_AUDIO_SINK_HPP Declaration of the AudioSource class. 
 
State
Enumeration of possible states for this Audio. 
 
Abstract class for audio output sinks. 
 
An object responsible for decoding an audio file. 
 
virtual std::uint64_t Position()=0
Gets the current played position in the song, in samples. 
 
virtual void SetPosition(std::uint64_t samples)=0
Sets the current played position, given a position in samples. 
 
An output stream for audio, using SDL. 
 
Declaration of the Audio class. 
 
AudioSource::DecodeVector::iterator TransferIterator
Type of iterators used in the Transfer() method. 
 
RingBuffer ring_buf
The ring buffer used to transfer samples to the playing callback. 
 
virtual void Transfer(TransferIterator &start, const TransferIterator &end)=0
Transfers a range of sample bytes into the AudioSink. 
 
SDL_AudioDeviceID device
The SDL device to which we are outputting sound. 
 
std::uint64_t position_sample_count
The current position, in samples. 
 
virtual Audio::State State()
Gets this AudioSink's current state (playing/stopped/at end). 
 
virtual void SourceOut()=0
Tells this AudioSink that the source has run out. 
 
The RingBuffer class template. 
 
bool source_out
Whether the source has run out of things to feed the sink. 
 
static const std::array< SDL_AudioFormat, SAMPLE_FORMAT_COUNT > FORMATS
Mapping from SampleFormats to their equivalent SDL_AudioFormats. 
 
virtual ~AudioSink()=default
Virtual, empty destructor for AudioSink. 
 
virtual void Start()=0
Starts the audio stream. 
 
Audio::State state
The decoder's current state. 
 
size_t bytes_per_sample
Number of bytes in one sample. 
 
static const size_t RINGBUF_POWER
n, where 2^n is the capacity of the Audio ring buffer. 
 
virtual void Stop()=0
Stops the audio stream.