#ifndef _PLAYER_H_552bf1db_ #define _PLAYER_H_552bf1db_ extern int playerfd; extern int playerdg; extern void player_main(void); /* * Player-to-master (_P2M_) messages. */ /* * Result of an attempt to open the audio device. * * _OPEN: success, nothing follows * _FAIL_OPEN: open() failed, one int (errno) follows * _FAIL_SETUP: AUDIO_SETINFO ioctl failed, one int (errno) follows */ #define PLAYER_P2M_AUDIO_OPEN 0x00 #define PLAYER_P2M_AUDIO_FAIL_OPEN 0x01 #define PLAYER_P2M_AUDIO_FAIL_SETUP 0x02 /* * Sent by the player to request a data download connection. No * following data. The master brings up a data download connection, * sends it over the datagram socket, and replies with * PLAYER_M2P_DATA_CONN (or, on failure, replies with * PLAYER_M2P_DATA_CONN_FAIL with no datagram message). */ #define PLAYER_P2M_WANT_DATA_CONN 0x03 /* * Sent by the player when playing is paused. No following data. * Pausing is orthogonal to audio being shut down (see the * PLAYER_P2M_AUDIO_* messages, above and below). It takes a * PLAYER_M2P_UNPAUSE message to get back to normal operation from * this state. */ #define PLAYER_P2M_PAUSED 0x04 /* * Sent by the player when playing is unpaused. No following data. */ #define PLAYER_P2M_UNPAUSED 0x05 /* * Sent by the player when the audio device has been closed. No * following data. This is orthogonal to pausing. It takes a * PLAYER_M2P_OPEN_AUDIO message to get back to normal operation from * this state. */ #define PLAYER_P2M_AUDIO_CLOSED 0x06 /* * Sent by the player to request the master display a message to the * user. Following data: the NUL-terminated message. */ #define PLAYER_P2M_MESSAGE 0x07 /* * Whenever playing is in progress (neither paused nor down because of * failed audio data connection), a status update is generated * periodically (and relatively frequently, from a human perspective). * * Following data: frame offset, relative to the CD subregion described * in the relevant PLAYER_M2P_PLAY message, as an int. */ #define PLAYER_P2M_PLAYSTATUS 0x08 /* * Whenever a PLAYER_M2P_PLAY command finishes playing, this is * generated. No following data. (This happens even if there is * nothing else to start playing at that point.) * * It is the master's responsibility to keep track of what play * operations are oustanding in order to match these up with the play * operations they indicate termination of. * * If something goes wrong, such as the data connection crashing, or if * PLAYER_M2P_PLAY_NEXT is used, it is possible these to be generated * without all (or, maybe, even any) of the requested data being * played. */ #define PLAYER_P2M_PLAYDONE 0x09 /* * Whenever a PLAYER_M2P_FLUSH_PENDING command is done, it generates * one of these in response. This is necessary to handle the race * where a PLAYER_M2P_FLUSH_PENDING arrives after a track ends and * another begins but before the master has seen the * PLAYER_P2M_PLAYDONE for that track. No following data. */ #define PLAYER_P2M_FLUSHDONE 0x0a /* * Master-to-player (_M2P_) messages. */ /* * "Play this." Following data: NUL-terminated string (CD name), then * one int (starting frame number), then one more int (frame count). * * This is never an error; if playing isn't working for some reason, * it's just queued. */ #define PLAYER_M2P_PLAY 0x80 /* * Sent to indicate that there is a data connection waiting in the * datagram socket, as requested by PLAYER_P2M_WANT_DATA_CONN. No * following data, but the datagram socket has one (meaningless) byte * of data with a descriptor riding with it. * * It is an error to send this except when provoked by * PLAYER_P2M_WANT_DATA_CONN. */ #define PLAYER_M2P_DATA_CONN 0x81 /* * Sent to indicate that a data connection requested by * PLAYER_P2M_WANT_DATA_CONN has failed. No following data. * * It is an error to send this except when provoked by * PLAYER_P2M_WANT_DATA_CONN. */ #define PLAYER_M2P_DATA_CONN_FAIL 0x82 /* * Sent to tell the player to (re)open the audio device. No following * data. * * It is not an error to send this when the audio device is already * open, though in that case it does nothing but generate a * PLAYER_P2M_AUDIO_OPEN in response. If an audio open attempt is in * progress, this is completely ignored; the result from the extant * attempt serves as response for this as well. * * If an audio open was attempted and failed, this provokes a retry. */ #define PLAYER_M2P_OPEN_AUDIO 0x83 /* * Sent to tell the player to close the audio device. No following * data. * * It is not an error to send this when the audio device is already * closed, though in that case it does nothing. If an audio open * attempt is in progress, this aborts it. In any case, * PLAYER_P2M_AUDIO_CLOSED is generated in response. */ #define PLAYER_M2P_CLOSE_AUDIO 0x84 /* * Sent to tell the player to pause playing. No following data. It is * never an error to send this; if playing is already paused, it does * nothing but provoke a PLAYER_P2M_PAUSED in response. */ #define PLAYER_M2P_PAUSE 0x85 /* * Sent to tell the player to resume playing from paused. No following * data. It is never an error to send this; if playing is not paused, * it does nothing but provoke a PLAYER_P2M_UNPAUSED in response. */ #define PLAYER_M2P_UNPAUSE 0x86 /* * Sent after PLAYER_M2P_DATA_CONN_FAIL to indicate that a retry is * worthwhile. No following data. It is never an error to send this; * if the player has no use for a(nother) data connection, it is * ignored. */ #define PLAYER_M2P_DATA_RETRY 0x87 /* * Sent to cause the playe rto skip some number of pending tracks. * Following data: one int, the number of tracks to skip. Zero is a * no-op, one means just flush the currently playing track, two means * that plus the first pending track, etc. There is no explicit * reply; things happen as if this just made the affected track * portions play infinitely fast. */ #define PLAYER_M2P_PLAY_NEXT 0x88 /* * Sent to indicate "replace the pending playlist", that is, all * playlist entries after the currently-playing one. This will be * followed by zero or more PLAYER_M2P_PLAYs to respecify the pending * playlist. * * In contrast to PLAYER_M2P_PLAY_NEXT, no PLAYER_P2M_PLAYDONEs are * generated for the dropped tracks. However, when the flush is * complete, a PLAYER_P2M_FLUSHDONE is generated. */ #define PLAYER_M2P_FLUSH_PENDING 0x89 /* * Sent to tell the player to seek to a particular place in the * currently-playing track. Following data: one int, the place to * seek to, as a number of frames from the beginning of the track. * * There is no explicit reply. If the argument is negative, zero is * used instead; if it is past the end of the track, the end of the * track is used instead. */ #define PLAYER_M2P_SEEK 0x8a /* * Set volume. Following data: a double giving the gain factor, the * number to multiply audio samples by. * * No reply. */ #define PLAYER_M2P_VOLUME 0x8b #endif