pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Media::ThreadedPlayer Class Referenceabstract

Base class for audio players that are spawned to a new thread. More...

#include <mediaplayer.h>

Inheritance diagram for Media::ThreadedPlayer:
Inheritance graph
[legend]
Collaboration diagram for Media::ThreadedPlayer:
Collaboration graph
[legend]

Public Member Functions

virtual void pausing (void)
 Invoked when pausing. More...
 
virtual void resuming (void)
 Invoked when when resuming. More...
 
 ThreadedPlayer (void)
 
virtual ~ThreadedPlayer (void)
 
- Public Member Functions inherited from Media::Player
virtual ~Player (void)
 
virtual void setVolume (float volume)=0
 Adjust volume in decibels. More...
 
virtual float trackDuration (void) const =0
 Length of track in seconds, or a negative number if unknown. More...
 
virtual float playPoint (void) const =0
 Seconds from start, or a negative value if unknown. More...
 
virtual float playRemaining (void) const
 Seconds left in playback, or a negative number if unknown. More...
 
virtual State currentState (void) const =0
 
bool ready (void) const
 Indicate if player has finished initializing. More...
 
bool playbackComplete (void) const
 Indicate if playback is complete and ready for cleanup. More...
 
virtual time_t getPauseTimeout (void)
 When paused, get the time at which the song will expire. More...
 

Protected Member Functions

bool checkForPauseOrQuit (void)
 
virtual RESPONSE_CODE playerThread (void)=0
 

Private Member Functions

void setThreadState (bool pause, bool quit)
 
virtual void pause (void) override
 Implementations. More...
 
virtual void abort () override
 Don't play the rest of the song. More...
 
virtual void cue (void) override
 Starts thread in paused mode. More...
 
virtual void play (void) override
 Calls resume() to starting playback. More...
 
virtual RESPONSE_CODE completionStatus (void) override
 Get the player completion status, when it is done. More...
 

Private Attributes

volatile bool do_quit = false
 protected by pauseMutex More...
 
volatile bool do_pause = true
 protected by pauseMutex More...
 
std::mutex pause_mutex
 
std::condition_variable pause_changed
 
std::thread player_thread
 
std::future< RESPONSE_CODEplayer_response
 

Additional Inherited Members

- Public Types inherited from Media::Player
enum  State {
  DoesNotExist , Initializing , Cueing , Playing ,
  Done
}
 
- Static Public Member Functions inherited from Media::Player
static Media::PlayergetPlayer (const AudioSettings &settings, const std::string &media_url, float initial_gain)
 Get the a media player currently compiled in the code. More...
 

Detailed Description

Base class for audio players that are spawned to a new thread.

Constructor & Destructor Documentation

◆ ThreadedPlayer()

Media::ThreadedPlayer::ThreadedPlayer ( void  )

◆ ~ThreadedPlayer()

Media::ThreadedPlayer::~ThreadedPlayer ( void  )
virtual

Member Function Documentation

◆ abort()

void Media::ThreadedPlayer::abort ( void  )
overrideprivatevirtual

Don't play the rest of the song.

Implements Media::Player.

Here is the call graph for this function:

◆ checkForPauseOrQuit()

bool Media::ThreadedPlayer::checkForPauseOrQuit ( void  )
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ completionStatus()

RESPONSE_CODE Media::ThreadedPlayer::completionStatus ( void  )
overrideprivatevirtual

Get the player completion status, when it is done.

Exceptions
Ifthe player thread threw an exception, the promise/ future holds it and get() rethrows it when asked for it.

Implements Media::Player.

◆ cue()

void Media::ThreadedPlayer::cue ( void  )
overrideprivatevirtual

Starts thread in paused mode.

Start the player thread.

Starts in a paused state.

Implements Media::Player.

Here is the call graph for this function:

◆ pause()

void Media::ThreadedPlayer::pause ( void  )
overrideprivatevirtual

Implementations.

Pause playback. If already paused, do nothing.

Implements Media::Player.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pausing()

void Media::ThreadedPlayer::pausing ( void  )
virtual

Invoked when pausing.

Called when the playback thread is pausing.

Reimplemented in Audio::LavPlayer.

Here is the caller graph for this function:

◆ play()

void Media::ThreadedPlayer::play ( void  )
overrideprivatevirtual

Calls resume() to starting playback.

Implements Media::Player.

Here is the call graph for this function:

◆ playerThread()

virtual RESPONSE_CODE Media::ThreadedPlayer::playerThread ( void  )
protectedpure virtual

Implemented in ToneGenerator::Player, and Audio::LavPlayer.

Here is the caller graph for this function:

◆ resuming()

void Media::ThreadedPlayer::resuming ( void  )
virtual

Invoked when when resuming.

Called when the playback thread is resuming playback.

Reimplemented in Audio::LavPlayer.

Here is the caller graph for this function:

◆ setThreadState()

void Media::ThreadedPlayer::setThreadState ( bool  pause,
bool  quit 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ do_pause

volatile bool Media::ThreadedPlayer::do_pause = true
private

protected by pauseMutex

◆ do_quit

volatile bool Media::ThreadedPlayer::do_quit = false
private

protected by pauseMutex

◆ pause_changed

std::condition_variable Media::ThreadedPlayer::pause_changed
private

◆ pause_mutex

std::mutex Media::ThreadedPlayer::pause_mutex
private

◆ player_response

std::future<RESPONSE_CODE> Media::ThreadedPlayer::player_response
private

◆ player_thread

std::thread Media::ThreadedPlayer::player_thread
private

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