The decoder_plugin_ops structure
The decoder_plugin_ops structure that is returned by the Instantiate_Plugin function
and defines an instance of a decoder plugin, is defined as:
typedef status_t op_decoder_open(void*,const char *name, const char *header, uint32 size);
typedef void op_decoder_close(void*);
typedef status_t op_decoder_info(void*,file_info*);
typedef int32 op_decoder_read(void *,char *buf, ulong framecount);
typedef status_t op_decoder_play(void*);
typedef status_t op_decoder_stop(void*);
typedef status_t op_decoder_setvolume(void*,float);
typedef status_t op_decoder_setspeed(void *,float speed);
typedef status_t op_decoder_seek(void*, uint32 pos);
typedef uint32 op_decoder_position(void*);
typedef float op_decoder_bufferamount(void*);
typedef struct decoder_plugin_ops
{
uint32 ops_magic; // magic number
uint32 ops_version; // version of this plugin structure
op_decoder_open (*Open); // leave NULL if not implemented
op_decoder_close (*Close); // leave NULL if not implemented
op_decoder_info (*Info); // MUST be implemented
op_decoder_read (*Read); // leave NULL for decoders that don't produce data
op_decoder_play (*Play); // leave NULL if you do provide data
op_decoder_stop (*Stop); // leave NULL if you do provide data
op_decoder_setvolume (*SetVolume); // leave NULL if you do provide data
op_decoder_setspeed (*SetSpeed); // leave NULL if you do provide data
op_decoder_seek (*Seek); // leave NULL if seeking is not possible (streams)
op_decoder_position (*Position); // leave NULL if you can't provide position-info
op_decoder_bufferamount (*BufferAmount);// leave NULL if you don't want to display a buffer-indicator
} decoder_plugin_ops;
-
ops_magic is a magic number that you should set to PLUGIN_DECODER_MAGIC
-
ops_version is the current API version, and you should set it to PLUGIN_DECODER_VERSION
-
Open will be called to open the file. If you do not need to implement this function (because the
file was opened when the plugin was created for example) you can set this to NULL
-
Close will be called to close the file before the plugin is destroyed. If you prefer to close
the file when the plugin is destroyed, or for some reason do not need to close the file, you can set
this to NULL.
-
Info should fill in the file_info structure with information about the file being read/played.
-
If your plugin produces data, you should implement the Read function to return that data.
If your plugin does not produce data (a CD player for example) then you should implement the Play,Stop,
SetVolume and SetSpeed functions.
-
The Seek function is called to seek to another position in the file. If your plugin cannot
seek, you may set this to NULL.
-
The Position function should return the current position in the file. If your plugin cannot
provide this information, you may set this to NULL.
-
For plugins that provide their own buffering, and wish to indicate how full the buffer is,
you can implement the BufferAmount function. It should return a floating point value between
0.0 and 1.0 indicating how full the buffer is.
The void* that all of the functions receive as their first argument is the pointer that
was filled in by the Instantiate_Plugin function.
Copyright © 1999 Marco Nelissen