pianod2
multisource multiuser scriptable networked music player
Classes | Macros | Typedefs | Enumerations | Functions | Variables
fundamentals.h File Reference

Essential data structures and support. More...

#include <config.h>
#include <ctime>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <stdexcept>
Include dependency graph for fundamentals.h:

Go to the source code of this file.

Classes

struct  AudioSettings_t
 Audio output device & driver parameters. More...
 
class  CommandError
 Exception for command execution problems. More...
 
class  InitializationException
 
class  Ownership
 Privilege management for media sources. More...
 

Macros

#define kept_assert(x)   assert(x)
 kept_assert: An assert with important code inside it. More...
 
#define FAR_FUTURE   ((time_t) (((time_t) 0x7fffffff) << ((sizeof (time_t) - 4) * 8)))
 
#define A_LONG_TIME   (999999)
 
#define CMD_RANGE_SERVICE   (1000)
 
#define CMD_RANGE_ENGINE   (2000)
 
#define CMD_RANGE_USER   (3000)
 
#define CMD_RANGE_MEDIA_MANAGER   (4000)
 
#define CMD_RANGE_TUNING   (5000)
 
#define CMD_RANGE_PANDORA   (10000)
 
#define CMD_RANGE_TONEGENERATOR   (11000)
 
#define CMD_RANGE_FILESYSTEM   (12000)
 
#define CMD_RANGE_SPOTIFY   (13000)
 

Typedefs

typedef struct AudioSettings_t AudioSettings
 Audio output device & driver parameters. More...
 
typedef enum server_status_t RESPONSE_CODE
 
using UserList = std::vector< const class User * >
 

Enumerations

enum class  SearchRange {
  EXHAUSTIVE , SHALLOW , KNOWN , REQUESTABLE ,
  REQUESTS
}
 
enum  server_status_t {
  NO_REPLY = 0 , V_PLAYING = 1 , V_PAUSED = 2 , V_STALLED = 3 ,
  V_TRACK_COMPLETE = 4 , V_BETWEEN_TRACKS = 5 , V_IDLE = 6 , V_QUEUE_STOPPED = 7 ,
  V_QUEUE_REQUEST = 8 , V_QUEUE_RANDOM = 9 , V_SELECTEDSOURCE = 11 , V_SELECTEDPLAYLIST = 12 ,
  V_MIX_CHANGED = 21 , V_PLAYLISTS_CHANGED = 22 , V_PLAYLISTRATING_CHANGED = 23 , V_SOURCES_CHANGED = 24 ,
  V_SONGRATING_CHANGED = 25 , V_QUEUE_CHANGED = 26 , V_YELL = 31 , V_USERACTION = 32 ,
  V_SERVER_STATUS = 33 , V_SOURCE_STATUS = 34 , V_SELECTIONMETHOD = 41 , I_WELCOME = 100 ,
  I_ID = 111 , I_ALBUM = 112 , I_ARTIST = 113 , I_SONG = 114 ,
  I_PLAYLIST = 115 , I_RATING = 116 , I_INFO_URL = 117 , I_COVERART = 118 ,
  I_GENRE = 119 , I_PLAYLISTRATING = 120 , I_CHOICEEXPLANATION = 121 , I_OWNER = 122 ,
  I_SOURCE = 123 , I_NAME = 124 , I_YEAR = 125 , I_DURATION = 126 ,
  I_ACTIONS = 127 , I_INFO = 132 , I_USER_PRIVILEGES = 136 , I_VOLUME = 141 ,
  I_HISTORYSIZE = 142 , I_AUDIOQUALITY = 143 , I_AUTOTUNE_MODE = 144 , I_PAUSE_TIMEOUT = 146 ,
  I_PLAYLIST_TIMEOUT = 147 , I_ROOM = 148 , I_PROXY = 161 , I_CONTROLPROXY = 162 ,
  I_SERVICE_USER = 170 , I_SERVICE_PASSWORD = 171 , I_CACHE_MINIMUM = 172 , I_CACHE_MAXIMUM = 173 ,
  I_PATHNAME = 174 , I_SELECTION_ALGORITHM = 175 , I_OUTPUT_DRIVER = 181 , I_OUTPUT_DEVICE = 182 ,
  I_OUTPUT_ID = 183 , I_OUTPUT_SERVER = 184 , I_STATISTICS_ATTEMPTS = 190 , I_STATISTICS_PLAYS = 191 ,
  I_STATISTICS_FAILURES = 192 , I_STATISTICS_SEQUENTIAL_FAILS = 193 , I_STATISTICS_REPLACEMENTS = 194 , I_STATISTICS_DONATIONS = 195 ,
  I_ATTACHED_THING = 198 , I_ATTACHED_SONG = 199 , S_OK = 200 , S_ANSWER_YES = 201 ,
  S_ANSWER_NO = 202 , S_DATA = 203 , S_DATA_END = 204 , S_SIGNOFF = 205 ,
  S_MATCH = 206 , S_ROUNDING = 207 , S_NOOP = 208 , S_PARTIAL = 209 ,
  S_PENDING = 210 , E_BAD_COMMAND = 400 , E_UNAUTHORIZED = 401 , E_NAK = 402 ,
  E_DUPLICATE = 403 , E_NOTFOUND = 404 , E_WRONG_STATE = 405 , E_CREDENTIALS = 406 ,
  E_INVALID = 407 , E_TRANSFORM_FAILED = 408 , E_CONFLICT = 409 , E_REQUESTPENDING = 410 ,
  E_QUOTA = 411 , E_LOGINREQUIRED = 412 , E_UNSUPPORTED = 413 , E_RESOURCE = 414 ,
  E_RANGE = 415 , E_METAPLAYLIST = 416 , E_WRONGTYPE = 417 , E_PERSISTENT = 418 ,
  E_AMBIGUOUS = 419 , E_TYPE_DISALLOWED = 420 , E_PARTIAL = 421 , E_VARIOUS = 422 ,
  E_NO_ASSOCIATION = 423 , E_EXPRESSION = 424 , E_TIMEOUT = 425 , E_PLAYLIST_REQUIRED = 426 ,
  E_BAD_SCHEMA = 427 , E_MEDIA_ACTION = 460 , E_MEDIA_VALUE = 461 , E_MEDIA_MANAGER = 462 ,
  E_MEDIA_FAILURE = 463 , E_MEDIA_TRANSIENT = 464 , E_BUG = 498 , E_NOT_IMPLEMENTED = 499 ,
  F_FAILURE = 500 , F_PLAYER_EMPTY = 501 , F_NETWORK_FAILURE = 502 , F_SHUTDOWN = 503 ,
  F_AUTHENTICATION = 504 , F_RESOURCE = 505 , F_PANDORA = 507 , F_INCOMPLETE = 508 ,
  F_PERMISSION = 509 , F_EXCEPTION = 510 , F_NETWORK_TIMEOUT = 511 , F_CANNOT_OUTPUT = 512 ,
  F_AUDIO_FAILURE = 513 , A_SIGNED_IN = 1000 , A_SIGNED_OUT = 1001 , A_KICKED = 1002 ,
  A_IMBECILE = 1003 , A_SKIPPED = 1010 , A_STOPPED = 1011 , A_PAUSED = 1012 ,
  A_RESUMED = 1013 , A_CHANGED_MIX = 1014 , A_MIX_ADDED = 1015 , A_MIX_REMOVED = 1016 ,
  A_REQUESTS = 1017 , A_RANDOMPLAY = 1018 , A_ADJUSTAUDIO = 1019 , A_SELECTED_PLAYLIST = 1020 ,
  A_CREATED_PLAYLIST = 1021 , A_RENAMED_PLAYLIST = 1022 , A_DELETED_PLAYLIST = 1023 , A_SOURCE_ADD = 1030 ,
  A_SOURCE_BORROW = 1031 , A_SOURCE_REMOVE = 1032 , A_REQUEST_ADD = 1040 , A_REQUEST_CLEAR = 1041 ,
  A_REQUEST_CANCEL = 1042 , A_SHUTDOWN = 1100 , FUTURE_CATEGORY = 3000
}
 

Functions

bool forRequest (SearchRange range)
 
bool deepSearch (SearchRange range)
 
bool isStatusChange (RESPONSE_CODE code)
 
bool isDataField (RESPONSE_CODE code)
 
bool isSuccess (RESPONSE_CODE code)
 
bool isCommandError (RESPONSE_CODE code)
 
bool isServerFailure (RESPONSE_CODE code)
 
bool isUserAction (RESPONSE_CODE code)
 

Variables

const int CMD_INVALID = 0
 

Detailed Description

Essential data structures and support.

Macro Definition Documentation

◆ A_LONG_TIME

#define A_LONG_TIME   (999999)

◆ CMD_RANGE_ENGINE

#define CMD_RANGE_ENGINE   (2000)

◆ CMD_RANGE_FILESYSTEM

#define CMD_RANGE_FILESYSTEM   (12000)

◆ CMD_RANGE_MEDIA_MANAGER

#define CMD_RANGE_MEDIA_MANAGER   (4000)

◆ CMD_RANGE_PANDORA

#define CMD_RANGE_PANDORA   (10000)

◆ CMD_RANGE_SERVICE

#define CMD_RANGE_SERVICE   (1000)

◆ CMD_RANGE_SPOTIFY

#define CMD_RANGE_SPOTIFY   (13000)

◆ CMD_RANGE_TONEGENERATOR

#define CMD_RANGE_TONEGENERATOR   (11000)

◆ CMD_RANGE_TUNING

#define CMD_RANGE_TUNING   (5000)

◆ CMD_RANGE_USER

#define CMD_RANGE_USER   (3000)

◆ FAR_FUTURE

#define FAR_FUTURE   ((time_t) (((time_t) 0x7fffffff) << ((sizeof (time_t) - 4) * 8)))

◆ kept_assert

#define kept_assert (   x)    assert(x)

kept_assert: An assert with important code inside it.

In debugging mode, the result must be true/non-0. In release mode, the result is unchecked but the expression is still evaluated.

Typedef Documentation

◆ AudioSettings

Audio output device & driver parameters.

◆ RESPONSE_CODE

◆ UserList

using UserList = std::vector<const class User *>

Enumeration Type Documentation

◆ SearchRange

enum SearchRange
strong
Enumerator
EXHAUSTIVE 

Get everything matching, and all their contents.

SHALLOW 

Get matching things, but not their contents.

KNOWN 

Get whatever we know about; don't perform external searches.

REQUESTABLE 

Search requestable sources for matches; return all items matching.

REQUESTS 

Search requestable sources for matches, but not their contents.

◆ server_status_t

Enumerator
NO_REPLY 

Do not transmit any reply.

V_PLAYING 
V_PAUSED 
V_STALLED 
V_TRACK_COMPLETE 
V_BETWEEN_TRACKS 
V_IDLE 
V_QUEUE_STOPPED 
V_QUEUE_REQUEST 
V_QUEUE_RANDOM 
V_SELECTEDSOURCE 
V_SELECTEDPLAYLIST 
V_MIX_CHANGED 
V_PLAYLISTS_CHANGED 
V_PLAYLISTRATING_CHANGED 
V_SOURCES_CHANGED 
V_SONGRATING_CHANGED 
V_QUEUE_CHANGED 
V_YELL 
V_USERACTION 
V_SERVER_STATUS 
V_SOURCE_STATUS 
V_SELECTIONMETHOD 
I_WELCOME 
I_ID 
I_ALBUM 
I_ARTIST 
I_SONG 
I_PLAYLIST 
I_RATING 
I_INFO_URL 
I_COVERART 
I_GENRE 
I_PLAYLISTRATING 
I_CHOICEEXPLANATION 
I_OWNER 
I_SOURCE 
I_NAME 
I_YEAR 
I_DURATION 
I_ACTIONS 
I_INFO 
I_USER_PRIVILEGES 
I_VOLUME 
I_HISTORYSIZE 
I_AUDIOQUALITY 
I_AUTOTUNE_MODE 
I_PAUSE_TIMEOUT 
I_PLAYLIST_TIMEOUT 
I_ROOM 
I_PROXY 
I_CONTROLPROXY 
I_SERVICE_USER 
I_SERVICE_PASSWORD 
I_CACHE_MINIMUM 
I_CACHE_MAXIMUM 
I_PATHNAME 
I_SELECTION_ALGORITHM 
I_OUTPUT_DRIVER 
I_OUTPUT_DEVICE 
I_OUTPUT_ID 
I_OUTPUT_SERVER 
I_STATISTICS_ATTEMPTS 
I_STATISTICS_PLAYS 
I_STATISTICS_FAILURES 
I_STATISTICS_SEQUENTIAL_FAILS 
I_STATISTICS_REPLACEMENTS 
I_STATISTICS_DONATIONS 
I_ATTACHED_THING 

Transmit the attached thing instead of a response message.

I_ATTACHED_SONG 

Transmit the essentials of the attached song (but not ratings, etc).

S_OK 
S_ANSWER_YES 
S_ANSWER_NO 
S_DATA 
S_DATA_END 
S_SIGNOFF 
S_MATCH 

Matches for criteria were found.

S_ROUNDING 

Success but with rounding.

S_NOOP 

Nothing to do; default success.

S_PARTIAL 

Command partially succeeded, but there were failures.

S_PENDING 

Request is pending but will succeed eventually.

E_BAD_COMMAND 
E_UNAUTHORIZED 
E_NAK 
E_DUPLICATE 
E_NOTFOUND 
E_WRONG_STATE 
E_CREDENTIALS 
E_INVALID 
E_TRANSFORM_FAILED 
E_CONFLICT 
E_REQUESTPENDING 

Request couldn't be completed now, we'll try again later.

E_QUOTA 

Quota restriction encountered.

E_LOGINREQUIRED 

Command/feature requires user be logged in.

E_UNSUPPORTED 
E_RESOURCE 

Inadequate memory, disk, etc.

E_RANGE 

Request puts value out of range.

E_METAPLAYLIST 

Require a real playlist.

E_WRONGTYPE 

Operand was of wrong type.

E_PERSISTENT 

Require persistent data.

E_AMBIGUOUS 

Ambiguous expression.

E_TYPE_DISALLOWED 

Type not allowed with expression.

E_PARTIAL 

Partial failure, but a portion succeeded.

E_VARIOUS 

All failures, but a varity of reasons.

E_NO_ASSOCIATION 

Missing association data, i.e., song has no playlist.

E_EXPRESSION 

Invalid expression.

E_TIMEOUT 

Event did not occur within specified duration.

E_PLAYLIST_REQUIRED 

Song must have a playlist for this action.

E_BAD_SCHEMA 

JSON command is structured incorrectly.

E_MEDIA_ACTION 

Source doesn't do that.

E_MEDIA_VALUE 

Source doesn't accept a certain value.

E_MEDIA_MANAGER 

Can't do that on media manager.

E_MEDIA_FAILURE 

Source failure.

E_MEDIA_TRANSIENT 

Transient playlist.

E_BUG 

A bug was encountered (likely hit default in a case statement.)

E_NOT_IMPLEMENTED 
F_FAILURE 
F_PLAYER_EMPTY 
F_NETWORK_FAILURE 
F_SHUTDOWN 
F_AUTHENTICATION 
F_RESOURCE 
F_PANDORA 
F_INCOMPLETE 
F_PERMISSION 
F_EXCEPTION 
F_NETWORK_TIMEOUT 
F_CANNOT_OUTPUT 
F_AUDIO_FAILURE 
A_SIGNED_IN 
A_SIGNED_OUT 
A_KICKED 
A_IMBECILE 
A_SKIPPED 
A_STOPPED 
A_PAUSED 
A_RESUMED 
A_CHANGED_MIX 
A_MIX_ADDED 
A_MIX_REMOVED 
A_REQUESTS 
A_RANDOMPLAY 
A_ADJUSTAUDIO 
A_SELECTED_PLAYLIST 
A_CREATED_PLAYLIST 
A_RENAMED_PLAYLIST 
A_DELETED_PLAYLIST 
A_SOURCE_ADD 
A_SOURCE_BORROW 
A_SOURCE_REMOVE 
A_REQUEST_ADD 
A_REQUEST_CLEAR 
A_REQUEST_CANCEL 
A_SHUTDOWN 
FUTURE_CATEGORY 

Function Documentation

◆ deepSearch()

bool deepSearch ( SearchRange  range)
inline
Here is the caller graph for this function:

◆ forRequest()

bool forRequest ( SearchRange  range)
inline
Here is the caller graph for this function:

◆ isCommandError()

bool isCommandError ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

◆ isDataField()

bool isDataField ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

◆ isServerFailure()

bool isServerFailure ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

◆ isStatusChange()

bool isStatusChange ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

◆ isSuccess()

bool isSuccess ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

◆ isUserAction()

bool isUserAction ( RESPONSE_CODE  code)
inline
Here is the caller graph for this function:

Variable Documentation

◆ CMD_INVALID

const int CMD_INVALID = 0