Skip to content

Developing your own plugin

Alexey Yakovenko edited this page Jul 6, 2014 · 10 revisions

Plugin types

We have several plugin types in Deadbeef. As a plugin author, you need to decide which type of plugin you want.

Decoder

Reads a source file(s), and converts it to PCM format for playback. Also, decoder is responsible for checking file format (probing), inserting the track (of all subtracks) to playlist, seeking in the file, reading and writing metadata. Some of these features are optional to implement, but all of them are highly desirable from a good decoder plugin. There is a decoder plugin template in the root folder of source distribution. It might be slightly outdated though, but should be very handy to start off.

Output

Accepts PCM input, and plays it back through some sound API. For example ALSA or OSS. Also needs to handle play/pause/stop commands. It is easiest to start off some existing plugin. OSS and NULL output plugins are very simple.

DSP

DSP plugins accept PCM, and do some processing on it. Good example is EQ. I'm sure most people willing to write a DSP plugin already know what to do :)

VFS

VFS plugins implement multiple data transfer protocols over a unified interface, which is similar to stdio file API. By default, Deadbeef ships with stdio (normal local files) and vfs_curl (streaming over procols provided by libcurl, such as http, ftp, etc) plugins. This plugin type can be used to implement support for GIO, archive formats, etc. Though it might need some work on the API side. At the time of writing (0.4.2) VFS plugin API only supports open/read/close operation, and some extra functions for http/icy specific stuff.

Playlist

Implements loading and saving of playlists in various formats. Each playlist plugin can support multiple formats (e.g. M3U and PLS in the same plugin).

Miscellaneous

Plugins that can do anything not directly related to audio and I/O. For example, last.fm scrobbler. Usually, they are running in their own thread, sending and receiving signals to and from Deadbeef core.

GUI

The GUI plugins, like GTKUI. The best way to learn about them is to read the GTKUI source code. The GUI plugins are very similar to Misc plugins, except they are started in a different way, and are expected to "block" the main thread with their own main loop, e.g. gtk_main, which should be running until plugin.stop is called (from another thread).

Where to start

Normally, you need to #include <deadbeef/deadbeef.h>, and build your plugin as a shared library, like this:

gcc -std=c99 -shared -O2 -o myplugin.so myplugin.c

The file /usr/include/deadbeef/deadbeef.h should've been installed with the player itself. If not -- look for deadbeef-devel package, or something like this. Or get the file from a source tarball. deadbeef.h has some important comments, so you should read it.

In the beginning of the file, there is description on how to write your plugin entry point function.

This entry point normally should only do one thing: return a pointer to plugin declaration structure. See source code of other plugins to see how it works. It is very simple concept.

What's next?

Read other plugin's source code, come chat with devs on IRC, don't be afraid to ask. We are trying to be as friendly to newcomers as possible, and we are willing to help.

Clone this wiki locally