URY playd
C++ minimalist audio player
NoAudio Class Reference

A dummy Audio implementation representing a lack of file. More...

#include <audio.hpp>

+ Inheritance diagram for NoAudio:
+ Collaboration diagram for NoAudio:

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

A dummy Audio implementation representing a lack of file.

NoAudio throws exceptions if any attempt is made to change, start, or stop the audio, and returns Audio::State::NONE during any attempt to Update. If asked to emit the audio file, NoAudio does nothing.

See also
Audio

Definition at line 122 of file audio.hpp.

Member Function Documentation

§ CurrentState()

Audio::State NoAudio::CurrentState ( ) const
overridevirtual

The state of this Audio.

Returns
this Audio's current state.

Implements Audio.

Definition at line 33 of file audio.cpp.

References Audio::NONE.

34 {
35  return Audio::State::NONE;
36 }
There is no Audio.

§ File()

const std::string & NoAudio::File ( ) const
overridevirtual

This Audio's current file.

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

Implements Audio.

Definition at line 53 of file audio.cpp.

References MSG_CMD_NEEDS_LOADED.

54 {
56 }
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&#39;t anything...
Definition: messages.h:42
An Error signifying that no audio is loaded.
Definition: errors.hpp:120

§ Position()

std::uint64_t NoAudio::Position ( ) const
overridevirtual

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

Implements Audio.

Definition at line 48 of file audio.cpp.

References MSG_CMD_NEEDS_LOADED.

49 {
51 }
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&#39;t anything...
Definition: messages.h:42
An Error signifying that no audio is loaded.
Definition: errors.hpp:120

§ SetPlaying()

void NoAudio::SetPlaying ( bool  playing)
overridevirtual

Sets whether this Audio should be playing or not.

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

Implements Audio.

Definition at line 38 of file audio.cpp.

References MSG_CMD_NEEDS_LOADED.

39 {
41 }
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&#39;t anything...
Definition: messages.h:42
An Error signifying that no audio is loaded.
Definition: errors.hpp:120

§ SetPosition()

void NoAudio::SetPosition ( std::uint64_t  position)
overridevirtual

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

Implements Audio.

Definition at line 43 of file audio.cpp.

References MSG_CMD_NEEDS_LOADED.

44 {
46 }
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&#39;t anything...
Definition: messages.h:42
An Error signifying that no audio is loaded.
Definition: errors.hpp:120

§ Update()

Audio::State NoAudio::Update ( )
overridevirtual

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

Implements Audio.

Definition at line 28 of file audio.cpp.

References Audio::NONE.

29 {
30  return Audio::State::NONE;
31 }
There is no Audio.

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