|
pianod2
multisource multiuser scriptable networked music player
|
Audio engine, responsible for one "room" worth of audio. More...
#include <engine.h>


Public Member Functions | |
| virtual void | registerInterpreter (PianodDispatcher &dispatcher) override |
| Register the interpreter with a dispatcher. More... | |
| virtual const Parsnip::Parser::Definitions & | getParserDefinitions () override |
| Retrieve the parser definitions handled by the interpreter. More... | |
| AudioEngine (PianodService *svc, const AudioSettings &audio_options) | |
| Create a new audio player attached to a service with an assigned audio output device. More... | |
| virtual | ~AudioEngine (void) |
| void | shutdown (bool immediate) |
| Initiate shutdown of the audio engine. More... | |
| float | periodic (void) |
| Periodically invoked function that monitors players, starts new songs, etc. More... | |
| ResponseGroup | assembleStatus () |
| Should be called intermittently by the main run-loop. More... | |
| ResponseGroup | updateStatus (PianodConnection &there) |
| Update audio engine status to a client. More... | |
| void | usersChangedNotification () |
| UserList | getAutotuneUsers () |
| const AudioSettings & | audioSettings () |
Public Member Functions inherited from PianodInterpreter | |
| const HelpList | getHelp (const std::vector< std::string > &search, std::set< std::string > *option_parsers) |
| Search the interpreter's definitions for any definitions matching search criteria. More... | |
Static Public Member Functions | |
| static const Parsnip::OptionParser::Definitions & | playback_selection_option_definitions () |
| static const Parsnip::Parser::Definitions & | parser_definitions () |
| static const PianodSchema::CommandIds & | json_request_names () |
| Retrieve names for our JSON requests. More... | |
Static Public Member Functions inherited from PianodInterpreter | |
| static bool | optionIs (const Parsnip::Data &options, const char *name, const char *expected) |
| Check if a string value exists and is case-blind equal to a particular value. More... | |
| template<typename ValueType , typename LookupType > | |
| static ValueType | optionalValue (const Parsnip::Data &options, const char *name, const LookupType &lookup, const ValueType default_value) |
| Retrieve the ID of a string value. More... | |
Private Types | |
| enum | requirement_t { REQUIRE_SOURCE = 0x01 , REQUIRE_PLAYLIST = 0x02 , REQUIRE_PLAYER = 0x04 , REQUIRE_EXPAND = 0x10 } |
| Prerequisites that may be necessary to execute a particular command. More... | |
| enum class | PlaybackState { PAUSED , PLAYING } |
| enum class | TransitionProgress { Playing , Purged , Cueing , Crossfading , Done } |
| States player progresses through when segueing between tracks. More... | |
| enum class | QueueMode { STOPPED , REQUESTS , RANDOMPLAY } |
| Behaviors possible when the player is idle. More... | |
| enum class | Announced { NEVER , PARTIALLY , COMPLETELY } |
| Whether and how completely track information was announced at start of playback. More... | |
| typedef enum AudioEngine::requirement_t | REQUIREMENT |
| Prerequisites that may be necessary to execute a particular command. More... | |
Private Member Functions | |
| virtual bool | authorizedCommand (Parsnip::Parser::CommandId command, PianodConnection &conn) override |
| Check whether a command is authorized. More... | |
| virtual ResponseCollector | handleCommand (Parsnip::Parser::CommandId command, const Parsnip::Data &options, PianodConnection &conn) override |
| Command handler. More... | |
| MusicThingie * | getThingOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, Ownership::Action usage=Ownership::Action::USE) const |
| Get a thing from a predicate and ensure it is usable. More... | |
| MusicThingie * | getThingOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, MusicThingie::Type want, Ownership::Action usage=Ownership::Action::USE) const |
| Get a thing from a predicate, ensure usability and it conforms to a type. More... | |
| ThingieList | getThingsOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, CommandReply *diagnostics, Ownership::Action usage=Ownership::Action::USE) const |
| Get some things from a predicate and ensure they is usable. More... | |
| ThingieList | getThingsOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, MusicThingie::Type want, CommandReply *diagnostics, Ownership::Action usage=Ownership::Action::USE) const |
| Get things from a predicate, ensure usability and it conforms to a type. More... | |
| SongList | getSongsOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, CommandReply *diagnostics, Ownership::Action usage=Ownership::Action::USE) const |
| Get a songlist predicate, or use current song. More... | |
| PianodPlaylist * | getPlaylistOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, Ownership::Action usage) const |
| Get a playlist predicate, or use current playlist. More... | |
| PlaylistList | getPlaylistsOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, CommandReply *diagnostics, Ownership::Action usage=Ownership::Action::USE) const |
| Get a playlist predicate, or use current playlist. More... | |
| PlaylistList | getPlaylistsOrCurrent (const PianodConnection &conn, const Parsnip::Data &options, CommandReply *diagnostics, Ownership::Action usage, const ThingieList &default_playlist) const |
| Get a playlist predicate, or use one implied by a thing. More... | |
| void | require (PianodConnection &conn, unsigned long requirements) const |
| Check that required state/privileges are available. More... | |
| CommandReply | controlPlayback (const Parsnip::Data &options, bool start_playback, PianodConnection &conn) |
| bool | queueEmpty (void) const |
| bool | startPlayer (void) |
| Start playback of a the next song in the queue. More... | |
| ResponseGroup | promotePlayer (void) |
| Promote the cueing player to the primary player. */. More... | |
| ResponseGroup | cleanupPlayer (void) |
| Clean up when a player completes. More... | |
| float | monitorPlayer (void) |
| Check/respond to various things with the player. More... | |
| ResponseGroup | playbackState (PlaybackState state, PianodConnection *conn=nullptr) |
| Pause or resume playback. More... | |
| ResponseGroup | queueMode (QueueMode mode, PianodConnection *conn=nullptr) |
| Set the queueing mode. More... | |
| bool | gatherPlaybackStatus (ResponseGroup *response, bool only_if_accurate=false) const |
| ResponseGroup | gatherPlaybackStatus () const |
| Response | gatherQueueMode () const |
| Response | gatherSelectedPlaylist () const |
| SongList | sendSongLists (PianodConnection &conn, const Parsnip::Data &options, bool historical) |
| Generate response messages. More... | |
| void | PurgeUnselectedSongs (void) |
| Remove songs from the front of the random queue (but not songs from the request queue). More... | |
| bool | considerCreatingPlayer (void) |
| Create a player, if the current state allows it. More... | |
| bool | acquireRandomTracks (void) |
| Retrieves some random tracks and puts them in the queue. More... | |
| void | sourceReady (const Media::Source *const) |
| When a new source is ready, clear any track aquisition delays. More... | |
| bool | sourceRemovalCheck (const Media::Source *const source) |
| Remove all songs from a given source. More... | |
| void | sourceRemoved (const Media::Source *const source) |
| Unregister a source by removing its playlists. More... | |
| void | sourceOffline (const Media::Source *const) |
| Unregister a source by removing its playlists. More... | |
| void | sourceStatus (RESPONSE_CODE status, const char *detail) |
| Transmit any source status notifications to connected clients. More... | |
| void | playlistsChanged () |
| When playlists have changed, reset track aquisition lockouts. More... | |
| void | mixChanged (bool automatic, const char *why) |
| When mix has changed, reset track aquisition lockouts. More... | |
Static Private Member Functions | |
| static DataResponse | constructSeedlist (const ThingieList &things, PianodPlaylist *playlist) |
| Prepare a list of seeds for transmission. More... | |
Private Attributes | |
| struct { | |
| time_t playback_effective_start = 0 | |
| When not stalled, current time minus playback point. More... | |
| time_t onset = 0 | |
| Clock time at which a playback stall was detected. More... | |
| time_t onset_playpoint = 0 | |
| Playback point at which a playback stall was detected. More... | |
| } | stall |
| Structure used to track player progress/status. More... | |
| const float | prefetch_time = 5 |
| Number of seconds before cuing at which queue is refreshed. More... | |
| SongList::size_type | history_size = 10 |
| Maximum number of tracks retained in history. More... | |
| volatile bool | quit_requested = false |
| Flag for signal handlers to request shutdown. More... | |
| bool | quit_initiated = false |
| Flag set once a shutdown request has been initiated. More... | |
| time_t | track_acquisition_time = 0 |
| The next time at which random track aquisition may be attempted. More... | |
| PianodService * | service = nullptr |
| Retainer< PianodSong * > | current_song = nullptr |
| Retainer< PianodSong * > | cueing_song = nullptr |
| SongList | requests |
| SongList | random_queue |
| SongList | song_history |
| bool | lockout_announced = false |
| Retainer< PianodPlaylist * > | current_playlist = nullptr |
| Media::Player * | player = nullptr |
| Media::Player * | cueing_player = nullptr |
| TransitionProgress | transition_state = TransitionProgress::Playing |
| Announced | track_announced = Announced::NEVER |
| PlaybackState | playback_state = PlaybackState::PAUSED |
| QueueMode | queue_mode = QueueMode::STOPPED |
| time_t | pause_expiration = 0 |
| signed long | abort_playpoint = 0 |
| Playpoint where crossfaded skip will abort, or 0 for not aborted. More... | |
| bool | empty_warning_given = false |
| AudioSettings | audio |
| Tuner::Tuner | mix |
Static Private Attributes | |
| static const int | pause_timeout = 1800 |
| Pause timeout applied to all sources/songs. More... | |
| static const int | aquire_tracks_retry = 600 |
| Retry period if unable to get random tracks. More... | |
Additional Inherited Members | |
Public Types inherited from PianodInterpreter | |
| using | HelpList = PianodDispatcher::HelpList |
Protected Types inherited from PianodInterpreter | |
| using | StringVector = std::vector< std::string > |
Static Protected Attributes inherited from PianodInterpreter | |
| static const Parsnip::Data | EmptyDictionary {Parsnip::Data::Dictionary} |
| An empty dictionary, often used as a default with Parsnip::Data::getOr. More... | |
| static const StringVector | EmptyStringVector |
| An empty string vector, often used as a default with Parsnip::Data::getOr. More... | |
Audio engine, responsible for one "room" worth of audio.
Each audio engine has its own queue, selected playlist(s), and playback status.
|
private |
Prerequisites that may be necessary to execute a particular command.
|
strongprivate |
|
strongprivate |
|
strongprivate |
|
private |
|
strongprivate |
States player progresses through when segueing between tracks.
| AudioEngine::AudioEngine | ( | PianodService * | svc, |
| const AudioSettings & | audio_options | ||
| ) |
Create a new audio player attached to a service with an assigned audio output device.
| svc | The Football service. |
| audio_options | The audio device settings. |

|
virtual |
|
private |
Retrieves some random tracks and puts them in the queue.


| ResponseGroup AudioEngine::assembleStatus | ( | ) |
Should be called intermittently by the main run-loop.
Send audio engine status to a client.
Used on login.


|
inline |
|
overrideprivatevirtual |
Check whether a command is authorized.
| command_id | The command requesting execution. |
| context | Connection details, including authentication state and privileges. |
Implements PianodInterpreter.

|
private |
Clean up when a player completes.


|
private |
Create a player, if the current state allows it.
If there is nothing queued, and in random mode, get some random tracks.


|
staticprivate |
Prepare a list of seeds for transmission.
| things | The seeds. |
| playlist | The playlist to which the seeds belong. |


|
private |


|
private |

|
private |

|
private |

|
private |


| UserList AudioEngine::getAutotuneUsers | ( | ) |


|
overridevirtual |
Retrieve the parser definitions handled by the interpreter.
Implements PianodInterpreter.

|
private |
Get a playlist predicate, or use current playlist.
| conn | The connection requesting the things. |
| options | Predicate details from the command line. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |


|
private |
Get a playlist predicate, or use one implied by a thing.
| conn | The connection requesting the things. |
| options | Predicate details from the command line. |
| diagnostics | Status aggregator for problems encountered. |
| usage | The manner in which the object is to be accessed. |
| default_playlist | A list of songs, from which playlist will be taken (all must have the same playlist). |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |

|
private |
Get a playlist predicate, or use current playlist.
| conn | The connection requesting the things. |
| options | Predicate details from the command line. |
| diagnostics | Status aggregator for problems encountered. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |


|
private |
Get a songlist predicate, or use current song.
| conn | The connection requesting the songs. |
| options | Predicate details from the command line. |
| diagnostics | Status aggregator for problems encountered. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |


|
private |
Get a thing from a predicate, ensure usability and it conforms to a type.
| conn | The connection requesting the items. |
| options | Predicate details from the command line. |
| want | Indicates the type of thing wanted. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges. |

|
private |
Get a thing from a predicate and ensure it is usable.
| conn | The connection requesting the items. |
| options | Predicate details from the command line. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges. |


|
private |
Get some things from a predicate and ensure they is usable.
| conn | The connection requesting the things. |
| options | Predicate details from the command line. |
| diagnostics | Status aggregator for problems encountered. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |


|
private |
Get things from a predicate, ensure usability and it conforms to a type.
| conn | The connection requesting the things. |
| options | Predicate details from the command line. |
| want | Indicates the type of thing wanted. |
| diagnostics | Status aggregator for problems encountered. |
| usage | The manner in which the object is to be accessed. |
| CommandError | on invalid request, not found, or insufficient privileges for a single-item predicate. |

|
overrideprivatevirtual |
Command handler.
| command_id | Command to execute. |
| parameters | Command parameters. |
| context | Connection details, including authentication state and privileges. |
| CommandError | or other exception if an error occurs. |
Implements PianodInterpreter.
|
static |
Retrieve names for our JSON requests.

|
private |
When mix has changed, reset track aquisition lockouts.

|
private |
Check/respond to various things with the player.


|
static |
Play/select music, queue mode, playback
Play/select music, queue mode, playback

| float AudioEngine::periodic | ( | void | ) |
Periodically invoked function that monitors players, starts new songs, etc.

|
static |
Parse definitions for playback control

|
private |
Pause or resume playback.
| state | Indicates whether to play or pause. |
| conn | Connection requesting change, or nullptr. |


|
private |
When playlists have changed, reset track aquisition lockouts.

|
private |
Promote the cueing player to the primary player. */.


|
private |
Remove songs from the front of the random queue (but not songs from the request queue).
Reasons songs may be removed:


|
inlineprivate |

|
private |
Set the queueing mode.
| mode | Indicates stopped, requests only, or random play. |
| conn | Connection requesting change, or nullptr. |


|
overridevirtual |
Register the interpreter with a dispatcher.
| dispatcher | The dispatcher with which to register. |
Reimplemented from PianodInterpreter.


|
private |
Check that required state/privileges are available.
| CommandError | if requirements are not met. |


|
private |
Generate response messages.
Send the queue or history.
Allow negative indexes from either to refer to the other; 0 refers to current track. This makes implementing paging on clients easier because it won't have to use separate commands.
| conn | The connection to which the list is being sent. |
| options | Predicate details from the command line. |
| historical | If true, looks toward history; if false, toward future. |


| void AudioEngine::shutdown | ( | bool | immediate | ) |
Initiate shutdown of the audio engine.
| immediate | If true, aborts playback. If false, allows playback to complete before shutdown. |

|
private |
Unregister a source by removing its playlists.
However, allow items to remain in the history and queue (in case it comes back online).


|
private |
When a new source is ready, clear any track aquisition delays.

|
private |
Remove all songs from a given source.
| source | The source to remove. |


|
private |
Unregister a source by removing its playlists.
However, allow items to remain in the history and queue (in case it comes back online).


|
private |
Transmit any source status notifications to connected clients.
| status | The numeric status code. |
| detail | Additional details about the status. |


|
private |
Start playback of a the next song in the queue.
Preconditons: playlist should have a list in it.


| ResponseGroup AudioEngine::updateStatus | ( | PianodConnection & | there | ) |
Update audio engine status to a client.
Used on authentication.

| void AudioEngine::usersChangedNotification | ( | void | ) |


|
private |
Playpoint where crossfaded skip will abort, or 0 for not aborted.
|
staticprivate |
Retry period if unable to get random tracks.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Maximum number of tracks retained in history.
|
private |
|
private |
| time_t AudioEngine::onset = 0 |
Clock time at which a playback stall was detected.
| time_t AudioEngine::onset_playpoint = 0 |
Playback point at which a playback stall was detected.
|
private |
|
staticprivate |
Pause timeout applied to all sources/songs.
| time_t AudioEngine::playback_effective_start = 0 |
When not stalled, current time minus playback point.
|
private |
|
private |
|
private |
Number of seconds before cuing at which queue is refreshed.
|
private |
|
private |
Flag set once a shutdown request has been initiated.
|
private |
Flag for signal handlers to request shutdown.
|
private |
|
private |
|
private |
|
private |
| struct { ... } AudioEngine::stall |
Structure used to track player progress/status.
|
private |
The next time at which random track aquisition may be attempted.
|
private |
|
private |