This section is a detailed description of the function decoder_command of the level 3 decoder interface.
The operation sequence is in general:
This structure is used to pass parameters to decoder_command.
typedef struct _DECODER_PARAMS2
{
/* --- DECODER_PLAY */
xstring URL; /**< URL to play */
const INFO_BUNDLE_CV* Info;/**< Info about the URL to play */
/* --- DECODER_PLAY DECODER_REW, FFWD and JUMPTO */
PM123_TIME JumpTo; /**< absolute positioning in seconds */
DECFASTMODE Fast; /**< fast forward/rewind */
/* --- DECODER_SETUP */
/** specify a function which the decoder should use for output */
int DLLENTRYP(OutRequestBuffer)(void* a, const FORMAT_INFO2* format, float** buf);
void DLLENTRYP(OutCommitBuffer )(void* a, int len, PM123_TIME posmarker);
/** decoder events */
void DLLENTRYP(DecEvent )(void* a, DECEVENTTYPE event, void* param);
void* A; /**< only to be used with the precedent functions */
/* --- DECODER_SAVEDATA */
xstring SaveFilename;/**< File where to save the raw stream. */
} DECODER_PARAMS2;
The DECODER_SETUP command is used to pass callback pointers to the decoder engine. But the decoder could use it to do other initializations as well.
The following fields of the DECODER_PARAMS2 structure are guaranteed to be valid at this call:
All other fields should not be accessed during the processing of DECODER_SETUP as their content is undefined.
This command kicks off the decoder thread to start decoding of an URL. The command implicitly implies the DECODER_JUMPTO command if the JumpTo field in DECODER_PARAMS2 is grater than zero.
The following fields of the DECODER_PARAMS2 structure are guaranteed to be valid at this call:
DECODER_PLAY should not wait for data to become available. It should also not wait for the desired URL to open, because this could lead to time-outs.
When a decoder starts playing it might start at a certain location
of the target rather than the beginning of the song. In this case JumpTo
is set to the starting position. Otherwise it is 0.
If a start position makes no sense e.g. because the source is an
internet radio stream, the decoder should ignore this and just start
decoding. It is not an error that JumpTo is greater than zero
in this case.
The stop command resets the decoder into it's initial state. It could take a while for this command to complete, i.e. until no more callbacks to OutRequestBuffer/OutCommitBuffer are on the way. DECODER_STOP must not wait for that condition or deadlocks may occur. PM123 considers DECODER_STOP to have completed as soon as decoder_status returns DECODER_STOPPED.
DECODER_STOP does not have parameters.
The return value of the DECODER_STOP is currently ignored by PM123.
Interrupt decoding immediately and continue at a certain position of the source. The command should not wait for the seek operation to complete.
The JumpTo field points to a location from the start of
the current object in seconds where the decoding should continue.
The position should be rounded to the closest sample.
Change fast forward/rewind mode. This could happen before DECODER_PLAY if playback should immediately start in scan mode. In case decoding should start in rewind mode the following DECODER_PLAY command will always set the JumpTo filed to a location close to the end of the current URL.
A DECODER_FFWD command is usually preceded by DECODER_JUMPTO to reset the decoding position to the current playing position.
The field Fast will contain the new mode.
Save the raw stream to a file. The decoder should append an existing file.
SaveFilename contains the name/URL of the file where to save the stream data. If SaveFilename is NULL then stream saving should be turned off.