Plugins

SoundPlay makes use of plugins (add-ons) to read files and apply audio effects. This means that its capabilities can be expanded by adding plugins, without requiring a rewrite of SoundPlay. This document describes how these plugins are built.

General information

A SoundPlay plugin file must be located in a folder called "Plugins" that is in the same folder where SoundPlay itself is located.

A plugin file does not need to have a particular name to be identified as a plugin, and the plugin folder is scanned recursively, so you can create subdirectories in it to order your plugins if you wish. Folders that start and end with round brackets are skipped in the recursive scan. You would use this if you need a folder where your plugin stores datafiles for example.

SoundPlay currently scans the plugin folder once when it starts up, so if you add a new plugin, you will need to restart SoundPlay.

The plugin_descriptor structure

A SoundPlay plugin file exports two functions. The first one is defined as
 extern "C" plugin_descriptor _EXPORT **get_plugin_list(void);
it returns a pointer to an array of pointers to plugin_descriptor structures. The array should be terminated with a NULL pointer. Because each plugin_descriptor defines a plugin, and get_plugin_list returns a pointer to an array of pointers to these structures, you can put more than one plugin in a single plugin-file. A plugin_descriptor structure looks like this:
typedef void	op_about();
typedef BView*	op_configure(BMessage *config);
typedef void*	op_instantiate(void **data, const char *name, const char *header, uint32 size, plugin_info *info);
typedef void	op_destroy(void *plugin_ops, void *data);

typedef struct plugin_descriptor
{
	uint32		desc_magic;
	uint32		desc_version;
	char*		id;
	uint32		version;
	uint32		flags;
	char*		name;
	char*		aboutstring;

	op_about	(*About);
	op_configure	(*Configure);
	op_instantiate	(*Instantiate_Plugin);
	op_destroy	(*Destroy_Plugin);	
} plugin_descriptor;

If the plugin is a decoder plugin, Instantiate_Plugin should return a pointer to a decoder_plugin_ops structure

If the plugin is an effect plugin (audio filter or visual effect), Instantiate_Plugin should return a pointer to a filter_plugin_ops structure

If the plugin is a general purpose plugin, Instantiate_Plugin should return a pointer to an interface_plugin_ops structure


Supported types

The second function that a plugin exports is
 extern "C" supported_type _EXPORT *get_supported_types(void);
The function is optional, and if implemented returns a pointer to an array of supported_type structures, which look like this:
 typedef struct supported_type
 {
	char *mimetype;
	char *longdesc;
	char *shortdesc;
	char *extension1;
	char *extension2;
 } supported_type;
The array should contain one supported_type for each supported fileformat, and be terminated with a entry containing a NULL mimetype.

The meaning of the members of supported_type is as follows:


Copyright © 1999 Marco Nelissen