URY playd
C++ minimalist audio player
Audio Class Referenceabstract

An audio item. More...

#include <audio.hpp>

+ Inheritance diagram for Audio:

Public Types

enum  State : uint8_t { State::NONE, State::STOPPED, State::PLAYING, State::AT_END }
 Enumeration of possible states for this Audio. More...
 

Public Member Functions

virtual ~Audio ()=default
 Virtual, empty destructor for Audio.
 
virtual State Update ()=0
 Performs an update cycle on this Audio. More...
 
virtual void SetPlaying (bool playing)=0
 Sets whether this Audio should be playing or not. More...
 
virtual void SetPosition (std::uint64_t position)=0
 Attempts to seek to the given position. More...
 
virtual const std::string & File () const =0
 This Audio's current file. More...
 
virtual Audio::State CurrentState () const =0
 The state of this Audio. More...
 
virtual std::uint64_t Position () const =0
 This Audio's current position. More...
 

Detailed Description

An audio item.

Audio abstractly represents an audio item that can be played, stopped, and queried for its position and path (or equivalent).

Audio is a virtual interface implemented concretely by PipeAudio, and also by mock implementations for testing purposes.

See also
PipeAudio

Definition at line 35 of file audio.hpp.

Member Enumeration Documentation

§ State

enum Audio::State : uint8_t
strong

Enumeration of possible states for this Audio.

See also
Update
Enumerator
NONE 

There is no Audio.

STOPPED 

The Audio has been stopped, or not yet played.

PLAYING 

The Audio is currently playing.

AT_END 

The Audio has ended and can't play without a seek.

Definition at line 42 of file audio.hpp.

42  : uint8_t {
43  NONE,
44  STOPPED,
45  PLAYING,
46  AT_END,
47  };

Member Function Documentation

§ CurrentState()

virtual Audio::State Audio::CurrentState ( ) const
pure virtual

The state of this Audio.

Returns
this Audio's current state.

Implemented in PipeAudio, and NoAudio.

§ File()

virtual const std::string& Audio::File ( ) const
pure virtual

This Audio's current file.

Returns
The filename of this current file.
Exceptions
NoAudioErrorif the current state is NONE.

Implemented in PipeAudio, and NoAudio.

§ Position()

virtual std::uint64_t Audio::Position ( ) const
pure virtual

This Audio's current position.

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

Returns
The current position, in microseconds.
Exceptions
NoAudioErrorif the current state is NONE.
See also
Seek

Implemented in PipeAudio, and NoAudio.

§ SetPlaying()

virtual void Audio::SetPlaying ( bool  playing)
pure virtual

Sets whether this Audio should be playing or not.

Parameters
playingTrue for playing; false for stopped.
Exceptions
NoAudioErrorif the current state is NONE.

Implemented in PipeAudio, and NoAudio.

§ SetPosition()

virtual void Audio::SetPosition ( std::uint64_t  position)
pure virtual

Attempts to seek to the given position.

Parameters
positionThe position to seek to, in microseconds.
Exceptions
NoAudioErrorif the current state is NONE.
See also
Position

Implemented in PipeAudio, and NoAudio.

§ Update()

virtual State Audio::Update ( )
pure virtual

Performs an update cycle on this Audio.

Depending on the Audio implementation, this may do actions such as performing a decoding round, checking for end-of-file, transferring frames, and so on.

Returns
The state of the Audio after updating.
See also
State

Implemented in PipeAudio, and NoAudio.


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