PM123 Decoder Plugins (1)

This is the description for the decoder interface before revision 2. This interface is deprecated. For new developments you should have a look at the recent level 3 interface.

Interface revision level 0 and 1

Decoder plugins must implement and export the functions defined in decoder_plug.h.

Playback interface

int DLLENTRY decoder_init ( struct DECODER_STRUCT **w )
BOOL DLLENTRY decoder_uninit( struct DECODER_STRUCT *w )

Init function is called when PM123 needs the specified decoder to play the stream demanded by the user. So only one decoder plugin is active at any given time. It should initialize the necessary semaphores and threads. decoder_uninit is called when another decoder than yours is needed, and should destroy the decoder's thread, semaphores, other opened handles and free allocated memory for w.

ULONG DLLENTRY decoder_command( struct DECODER_STRUCT *w, ULONG msg, DECODER_PARAMS *params )

There is a lot of commands to implement for this function. Parameters needed for each of the are described in the definition of the structure in the decoder_plug.h file. The decoder necessarily should support following commands: DECODER_SETUP, DECODER_PLAY and DECODER_STOP.

The decoder plugin must WinPostMsg() the following messages to hwnd:

Streaming meta data currently is for SHOUTcast (and icecast is using the same method), so it is a string with the following format:

StreamingTitle='blah blah';StreamingURL='more useless information';
Only StreamingTitle is used by PM123.

Status interface

The status interface has to be thread safe.

ULONG DLLENTRY decoder_status( struct DECODER_STRUCT *w )
ULONG DLLENTRY decoder_length( struct DECODER_STRUCT *w )

The call to this function must be valid even if DECODER_STARTING or DECODER_STOPPED is reported (when the stream plays too fast for example).

Output interface

The decoder must use this interface to pass the decoded samples to the output stage. Strictly speaking this is part of the playback interface, but the interface functions have to be called by the decoder in a separate thread. The function entry points for these callbacks are passed in DECODER_PARAMS at the DECODER_SETUP call.

int (DLLENTRYPP output_play_samples)( void* a, const FORMAT_INFO* format,
const char* buf, int len, int posmarker )

The decoder should pass the decoded samples to this function. The decoder should pass a bunch of samples at once unless the end of the data is reached to keep the performance reasonable.

Info interface

The info interface functions must be independent of the current decoder status. They should always be functional and give consistent results in any conditions. The functions must be thread-safe.

ULONG DLLENTRY decoder_fileinfo( const char *url, DECODER_INFO *info )
ULONG DLLENTRY decoder_saveinfo( char* url, const DECODER_INFO* info )

It is called if it is necessary to change the meta information for the specified file and the decoder supports this feature. Exporting this function is optional. See decoder_support.

ULONG DLLENTRY decoder_trackinfo( const char *drive, int track, DECODER_INFO *info )
ULONG DLLENTRY decoder_cdinfo( char *drive, DECODER_CDINFO *info )

This function is unused by PM123 since version 1.40 but it might still be invoked by visual plugins. You need not to export the CD related functions unless decoder_support returns the DECODER_TRACK flag.

ULONG DLLENTRY decoder_support( char *fileext[], int *size )

This is used by PM123 to suggest to the user what he can play with the decoder and what features are supported. Extensions can be for example "*.MOD".

GUI enhancement interface

See level 3 GUI enhancement interface. This part of the interface is new with PM123 1.40, but since all of the functions are optional it is compatible anyway.