From 43f613d9be9aa2953dcfc0aacfbdfb56d5d1a708 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 28 Jul 2013 13:18:48 +0200 Subject: decoder_api: convert to C++ --- src/CommandLine.cxx | 2 +- src/DecoderAPI.cxx | 2 +- src/DecoderAPI.hxx | 169 +++++++++++++++++++++++++ src/DecoderBuffer.cxx | 2 +- src/DecoderCommand.hxx | 30 +++++ src/DecoderControl.hxx | 2 +- src/DecoderError.hxx | 35 ++++++ src/DecoderInternal.hxx | 2 +- src/DecoderList.cxx | 2 +- src/DecoderPlugin.cxx | 2 +- src/DecoderPlugin.hxx | 215 ++++++++++++++++++++++++++++++++ src/DecoderPrint.cxx | 2 +- src/DecoderThread.cxx | 6 +- src/SongUpdate.cxx | 2 +- src/TagFile.cxx | 2 +- src/UpdateContainer.cxx | 2 +- src/UpdateSong.cxx | 2 +- src/decoder/AdPlugDecoderPlugin.cxx | 2 +- src/decoder/AudiofileDecoderPlugin.cxx | 2 +- src/decoder/DsdLib.cxx | 2 +- src/decoder/DsdiffDecoderPlugin.cxx | 2 +- src/decoder/DsfDecoderPlugin.cxx | 2 +- src/decoder/FaadDecoderPlugin.cxx | 2 +- src/decoder/FfmpegDecoderPlugin.cxx | 2 +- src/decoder/FlacCommon.hxx | 2 +- src/decoder/FlacInput.cxx | 2 +- src/decoder/FluidsynthDecoderPlugin.cxx | 2 +- src/decoder/GmeDecoderPlugin.cxx | 2 +- src/decoder/MadDecoderPlugin.cxx | 2 +- src/decoder/MikmodDecoderPlugin.cxx | 2 +- src/decoder/ModplugDecoderPlugin.cxx | 2 +- src/decoder/MpcdecDecoderPlugin.cxx | 2 +- src/decoder/Mpg123DecoderPlugin.cxx | 2 +- src/decoder/OggCodec.hxx | 2 +- src/decoder/OggUtil.cxx | 2 +- src/decoder/OpusDecoderPlugin.cxx | 2 +- src/decoder/PcmDecoderPlugin.cxx | 2 +- src/decoder/SndfileDecoderPlugin.cxx | 2 +- src/decoder/VorbisDecoderPlugin.cxx | 2 +- src/decoder/WavpackDecoderPlugin.cxx | 2 +- src/decoder/WildmidiDecoderPlugin.cxx | 2 +- src/decoder/sidplay_decoder_plugin.cxx | 2 +- src/decoder_api.h | 179 -------------------------- src/decoder_command.h | 30 ----- src/decoder_error.h | 35 ------ src/decoder_plugin.h | 215 -------------------------------- 46 files changed, 489 insertions(+), 499 deletions(-) create mode 100644 src/DecoderAPI.hxx create mode 100644 src/DecoderCommand.hxx create mode 100644 src/DecoderError.hxx create mode 100644 src/DecoderPlugin.hxx delete mode 100644 src/decoder_api.h delete mode 100644 src/decoder_command.h delete mode 100644 src/decoder_error.h delete mode 100644 src/decoder_plugin.h (limited to 'src') diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx index d1f386f82..194bf3e2b 100644 --- a/src/CommandLine.cxx +++ b/src/CommandLine.cxx @@ -23,7 +23,7 @@ #include "Log.hxx" #include "conf.h" #include "DecoderList.hxx" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "OutputList.hxx" #include "OutputPlugin.hxx" #include "InputRegistry.hxx" diff --git a/src/DecoderAPI.cxx b/src/DecoderAPI.cxx index d86b93fb4..bfadcfd8a 100644 --- a/src/DecoderAPI.cxx +++ b/src/DecoderAPI.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "AudioConfig.hxx" #include "replay_gain_config.h" #include "MusicChunk.hxx" diff --git a/src/DecoderAPI.hxx b/src/DecoderAPI.hxx new file mode 100644 index 000000000..79d733649 --- /dev/null +++ b/src/DecoderAPI.hxx @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/*! \file + * \brief The MPD Decoder API + * + * This is the public API which is used by decoder plugins to + * communicate with the mpd core. + */ + +#ifndef MPD_DECODER_API_HXX +#define MPD_DECODER_API_HXX + +#include "check.h" +#include "DecoderCommand.hxx" +#include "DecoderPlugin.hxx" +#include "input_stream.h" +#include "replay_gain_info.h" +#include "tag.h" +#include "audio_format.h" +#include "conf.h" + +/** + * Notify the player thread that it has finished initialization and + * that it has read the song's meta data. + * + * @param decoder the decoder object + * @param audio_format the audio format which is going to be sent to + * decoder_data() + * @param seekable true if the song is seekable + * @param total_time the total number of seconds in this song; -1 if unknown + */ +void +decoder_initialized(struct decoder *decoder, + const struct audio_format *audio_format, + bool seekable, float total_time); + +/** + * Determines the pending decoder command. + * + * @param decoder the decoder object + * @return the current command, or DECODE_COMMAND_NONE if there is no + * command pending + */ +enum decoder_command +decoder_get_command(struct decoder *decoder); + +/** + * Called by the decoder when it has performed the requested command + * (dc->command). This function resets dc->command and wakes up the + * player thread. + * + * @param decoder the decoder object + */ +void +decoder_command_finished(struct decoder *decoder); + +/** + * Call this when you have received the DECODE_COMMAND_SEEK command. + * + * @param decoder the decoder object + * @return the destination position for the week + */ +double +decoder_seek_where(struct decoder *decoder); + +/** + * Call this instead of decoder_command_finished() when seeking has + * failed. + * + * @param decoder the decoder object + */ +void +decoder_seek_error(struct decoder *decoder); + +/** + * Blocking read from the input stream. + * + * @param decoder the decoder object + * @param is the input stream to read from + * @param buffer the destination buffer + * @param length the maximum number of bytes to read + * @return the number of bytes read, or 0 if one of the following + * occurs: end of file; error; command (like SEEK or STOP). + */ +size_t +decoder_read(struct decoder *decoder, struct input_stream *is, + void *buffer, size_t length); + +/** + * Sets the time stamp for the next data chunk [seconds]. The MPD + * core automatically counts it up, and a decoder plugin only needs to + * use this function if it thinks that adding to the time stamp based + * on the buffer size won't work. + */ +void +decoder_timestamp(struct decoder *decoder, double t); + +/** + * This function is called by the decoder plugin when it has + * successfully decoded block of input data. + * + * @param decoder the decoder object + * @param is an input stream which is buffering while we are waiting + * for the player + * @param data the source buffer + * @param length the number of bytes in the buffer + * @return the current command, or DECODE_COMMAND_NONE if there is no + * command pending + */ +enum decoder_command +decoder_data(struct decoder *decoder, struct input_stream *is, + const void *data, size_t length, + uint16_t kbit_rate); + +/** + * This function is called by the decoder plugin when it has + * successfully decoded a tag. + * + * @param decoder the decoder object + * @param is an input stream which is buffering while we are waiting + * for the player + * @param tag the tag to send + * @return the current command, or DECODE_COMMAND_NONE if there is no + * command pending + */ +enum decoder_command +decoder_tag(struct decoder *decoder, struct input_stream *is, + const struct tag *tag); + +/** + * Set replay gain values for the following chunks. + * + * @param decoder the decoder object + * @param rgi the replay_gain_info object; may be NULL to invalidate + * the previous replay gain values + */ +void +decoder_replay_gain(struct decoder *decoder, + const struct replay_gain_info *replay_gain_info); + +/** + * Store MixRamp tags. + * + * @param decoder the decoder object + * @param mixramp_start the mixramp_start tag; may be NULL to invalidate + * @param mixramp_end the mixramp_end tag; may be NULL to invalidate + */ +void +decoder_mixramp(struct decoder *decoder, + char *mixramp_start, char *mixramp_end); + +#endif diff --git a/src/DecoderBuffer.cxx b/src/DecoderBuffer.cxx index 8e7da859b..0cc20450f 100644 --- a/src/DecoderBuffer.cxx +++ b/src/DecoderBuffer.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "DecoderBuffer.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include diff --git a/src/DecoderCommand.hxx b/src/DecoderCommand.hxx new file mode 100644 index 000000000..e6dc26982 --- /dev/null +++ b/src/DecoderCommand.hxx @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_DECODER_COMMAND_HXX +#define MPD_DECODER_COMMAND_HXX + +enum decoder_command { + DECODE_COMMAND_NONE = 0, + DECODE_COMMAND_START, + DECODE_COMMAND_STOP, + DECODE_COMMAND_SEEK +}; + +#endif diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx index c2d7b33aa..09bf1b834 100644 --- a/src/DecoderControl.hxx +++ b/src/DecoderControl.hxx @@ -20,7 +20,7 @@ #ifndef MPD_DECODER_CONTROL_HXX #define MPD_DECODER_CONTROL_HXX -#include "decoder_command.h" +#include "DecoderCommand.hxx" #include "audio_format.h" #include "thread/Mutex.hxx" #include "thread/Cond.hxx" diff --git a/src/DecoderError.hxx b/src/DecoderError.hxx new file mode 100644 index 000000000..14810dec7 --- /dev/null +++ b/src/DecoderError.hxx @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_DECODER_ERROR_HXX +#define MPD_DECODER_ERROR_HXX + +#include + +/** + * Quark for GError.domain. + */ +G_GNUC_CONST +static inline GQuark +decoder_quark(void) +{ + return g_quark_from_static_string("decoder"); +} + +#endif diff --git a/src/DecoderInternal.hxx b/src/DecoderInternal.hxx index 4cc8d3aa7..02ead763b 100644 --- a/src/DecoderInternal.hxx +++ b/src/DecoderInternal.hxx @@ -20,7 +20,7 @@ #ifndef MPD_DECODER_INTERNAL_HXX #define MPD_DECODER_INTERNAL_HXX -#include "decoder_command.h" +#include "DecoderCommand.hxx" #include "pcm/PcmConvert.hxx" #include "replay_gain_info.h" diff --git a/src/DecoderList.cxx b/src/DecoderList.cxx index a66a21e2f..0827586db 100644 --- a/src/DecoderList.cxx +++ b/src/DecoderList.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "DecoderList.hxx" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "conf.h" #include "mpd_error.h" #include "decoder/AudiofileDecoderPlugin.hxx" diff --git a/src/DecoderPlugin.cxx b/src/DecoderPlugin.cxx index bcee3ac66..9dce4b21f 100644 --- a/src/DecoderPlugin.cxx +++ b/src/DecoderPlugin.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "util/StringUtil.hxx" #include diff --git a/src/DecoderPlugin.hxx b/src/DecoderPlugin.hxx new file mode 100644 index 000000000..271595b71 --- /dev/null +++ b/src/DecoderPlugin.hxx @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_DECODER_PLUGIN_HXX +#define MPD_DECODER_PLUGIN_HXX + +#include +#include + +struct config_param; +struct input_stream; +struct tag; +struct tag_handler; + +/** + * Opaque handle which the decoder plugin passes to the functions in + * this header. + */ +struct decoder; + +struct decoder_plugin { + const char *name; + + /** + * Initialize the decoder plugin. Optional method. + * + * @param param a configuration block for this plugin, or NULL + * if none is configured + * @return true if the plugin was initialized successfully, + * false if the plugin is not available + */ + bool (*init)(const struct config_param *param); + + /** + * Deinitialize a decoder plugin which was initialized + * successfully. Optional method. + */ + void (*finish)(void); + + /** + * Decode a stream (data read from an #input_stream object). + * + * Either implement this method or file_decode(). If + * possible, it is recommended to implement this method, + * because it is more versatile. + */ + void (*stream_decode)(struct decoder *decoder, + struct input_stream *is); + + /** + * Decode a local file. + * + * Either implement this method or stream_decode(). + */ + void (*file_decode)(struct decoder *decoder, const char *path_fs); + + /** + * Scan metadata of a file. + * + * @return false if the operation has failed + */ + bool (*scan_file)(const char *path_fs, + const struct tag_handler *handler, + void *handler_ctx); + + /** + * Scan metadata of a file. + * + * @return false if the operation has failed + */ + bool (*scan_stream)(struct input_stream *is, + const struct tag_handler *handler, + void *handler_ctx); + + /** + * @brief Return a "virtual" filename for subtracks in + * container formats like flac + * @param const char* pathname full pathname for the file on fs + * @param const unsigned int tnum track number + * + * @return NULL if there are no multiple files + * a filename for every single track according to tnum (param 2) + * do not include full pathname here, just the "virtual" file + */ + char* (*container_scan)(const char *path_fs, const unsigned int tnum); + + /* last element in these arrays must always be a NULL: */ + const char *const*suffixes; + const char *const*mime_types; +}; + +/** + * Initialize a decoder plugin. + * + * @param param a configuration block for this plugin, or NULL if none + * is configured + * @return true if the plugin was initialized successfully, false if + * the plugin is not available + */ +static inline bool +decoder_plugin_init(const struct decoder_plugin *plugin, + const struct config_param *param) +{ + return plugin->init != NULL + ? plugin->init(param) + : true; +} + +/** + * Deinitialize a decoder plugin which was initialized successfully. + */ +static inline void +decoder_plugin_finish(const struct decoder_plugin *plugin) +{ + if (plugin->finish != NULL) + plugin->finish(); +} + +/** + * Decode a stream. + */ +static inline void +decoder_plugin_stream_decode(const struct decoder_plugin *plugin, + struct decoder *decoder, struct input_stream *is) +{ + plugin->stream_decode(decoder, is); +} + +/** + * Decode a file. + */ +static inline void +decoder_plugin_file_decode(const struct decoder_plugin *plugin, + struct decoder *decoder, const char *path_fs) +{ + plugin->file_decode(decoder, path_fs); +} + +/** + * Read the tag of a file. + */ +static inline bool +decoder_plugin_scan_file(const struct decoder_plugin *plugin, + const char *path_fs, + const struct tag_handler *handler, void *handler_ctx) +{ + return plugin->scan_file != NULL + ? plugin->scan_file(path_fs, handler, handler_ctx) + : false; +} + +/** + * Read the tag of a stream. + */ +static inline bool +decoder_plugin_scan_stream(const struct decoder_plugin *plugin, + struct input_stream *is, + const struct tag_handler *handler, + void *handler_ctx) +{ + return plugin->scan_stream != NULL + ? plugin->scan_stream(is, handler, handler_ctx) + : false; +} + +/** + * return "virtual" tracks in a container + */ +static inline char * +decoder_plugin_container_scan( const struct decoder_plugin *plugin, + const char* pathname, + const unsigned int tnum) +{ + return plugin->container_scan(pathname, tnum); +} + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Does the plugin announce the specified file name suffix? + */ +bool +decoder_plugin_supports_suffix(const struct decoder_plugin *plugin, + const char *suffix); + +/** + * Does the plugin announce the specified MIME type? + */ +bool +decoder_plugin_supports_mime_type(const struct decoder_plugin *plugin, + const char *mime_type); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/DecoderPrint.cxx b/src/DecoderPrint.cxx index 719a499ec..3f7f94937 100644 --- a/src/DecoderPrint.cxx +++ b/src/DecoderPrint.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "DecoderPrint.hxx" #include "DecoderList.hxx" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "Client.hxx" #include diff --git a/src/DecoderThread.cxx b/src/DecoderThread.cxx index fdc900abd..269dbdc1a 100644 --- a/src/DecoderThread.cxx +++ b/src/DecoderThread.cxx @@ -21,13 +21,13 @@ #include "DecoderThread.hxx" #include "DecoderControl.hxx" #include "DecoderInternal.hxx" -#include "decoder_error.h" -#include "decoder_plugin.h" +#include "DecoderError.hxx" +#include "DecoderPlugin.hxx" #include "song.h" #include "mpd_error.h" #include "Mapper.hxx" #include "fs/Path.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "tag.h" #include "InputStream.hxx" #include "DecoderList.hxx" diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index dde2ad57a..a7666b47d 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -30,7 +30,7 @@ extern "C" { #include "fs/FileSystem.hxx" #include "tag.h" #include "input_stream.h" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "DecoderList.hxx" extern "C" { diff --git a/src/TagFile.cxx b/src/TagFile.cxx index 3cc4c0f54..9201dd85b 100644 --- a/src/TagFile.cxx +++ b/src/TagFile.cxx @@ -21,7 +21,7 @@ #include "TagFile.hxx" #include "util/UriUtil.hxx" #include "DecoderList.hxx" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "input_stream.h" #include diff --git a/src/UpdateContainer.cxx b/src/UpdateContainer.cxx index 27ee89bae..f090cf0f1 100644 --- a/src/UpdateContainer.cxx +++ b/src/UpdateContainer.cxx @@ -24,7 +24,7 @@ #include "DatabaseLock.hxx" #include "Directory.hxx" #include "song.h" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "Mapper.hxx" #include "fs/Path.hxx" diff --git a/src/UpdateSong.cxx b/src/UpdateSong.cxx index 676ba48e2..0c2f2fb54 100644 --- a/src/UpdateSong.cxx +++ b/src/UpdateSong.cxx @@ -26,7 +26,7 @@ #include "DatabaseLock.hxx" #include "Directory.hxx" #include "song.h" -#include "decoder_plugin.h" +#include "DecoderPlugin.hxx" #include "DecoderList.hxx" #include diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx index 6d08fab56..e752295f5 100644 --- a/src/decoder/AdPlugDecoderPlugin.cxx +++ b/src/decoder/AdPlugDecoderPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "AdPlugDecoderPlugin.h" #include "tag_handler.h" -#include "decoder_api.h" +#include "DecoderAPI.hxx" extern "C" { #include "audio_check.h" diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx index e42cfc66e..4eb5c14a6 100644 --- a/src/decoder/AudiofileDecoderPlugin.cxx +++ b/src/decoder/AudiofileDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "AudiofileDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx index dd7ea70c9..40a553d91 100644 --- a/src/decoder/DsdLib.cxx +++ b/src/decoder/DsdLib.cxx @@ -25,7 +25,7 @@ #include "config.h" #include "DsdLib.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "util/bit_reverse.h" #include "tag_handler.h" diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index ed2a533b0..9934e4a37 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -28,7 +28,7 @@ #include "config.h" #include "DsdiffDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "util/bit_reverse.h" #include "tag_handler.h" diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx index a6f575d97..545f12975 100644 --- a/src/decoder/DsfDecoderPlugin.cxx +++ b/src/decoder/DsfDecoderPlugin.cxx @@ -29,7 +29,7 @@ #include "config.h" #include "DsfDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "util/bit_reverse.h" #include "DsdLib.hxx" diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx index 3e8a9b6bc..4636d08cb 100644 --- a/src/decoder/FaadDecoderPlugin.cxx +++ b/src/decoder/FaadDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "FaadDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "DecoderBuffer.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx index fe657728a..8b9810233 100644 --- a/src/decoder/FfmpegDecoderPlugin.cxx +++ b/src/decoder/FfmpegDecoderPlugin.cxx @@ -22,7 +22,7 @@ #include "config.h" #include "FfmpegDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "FfmpegMetaData.hxx" #include "tag_handler.h" #include "InputStream.hxx" diff --git a/src/decoder/FlacCommon.hxx b/src/decoder/FlacCommon.hxx index 0cd295e0d..78982e308 100644 --- a/src/decoder/FlacCommon.hxx +++ b/src/decoder/FlacCommon.hxx @@ -25,7 +25,7 @@ #define MPD_FLAC_COMMON_HXX #include "FlacInput.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" extern "C" { #include "pcm/pcm_buffer.h" diff --git a/src/decoder/FlacInput.cxx b/src/decoder/FlacInput.cxx index f5dedd97b..0bb5ec7d7 100644 --- a/src/decoder/FlacInput.cxx +++ b/src/decoder/FlacInput.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "FlacInput.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "gcc.h" #include "InputStream.hxx" diff --git a/src/decoder/FluidsynthDecoderPlugin.cxx b/src/decoder/FluidsynthDecoderPlugin.cxx index da1b41a58..5fbc83bdf 100644 --- a/src/decoder/FluidsynthDecoderPlugin.cxx +++ b/src/decoder/FluidsynthDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "FluidsynthDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "conf.h" diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx index 9693dd32b..108a589a1 100644 --- a/src/decoder/GmeDecoderPlugin.cxx +++ b/src/decoder/GmeDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "GmeDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "tag_handler.h" #include "util/UriUtil.hxx" diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx index a8b607386..bbfd2f412 100644 --- a/src/decoder/MadDecoderPlugin.cxx +++ b/src/decoder/MadDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "MadDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "conf.h" extern "C" { diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx index 94dff0856..538dfd599 100644 --- a/src/decoder/MikmodDecoderPlugin.cxx +++ b/src/decoder/MikmodDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "MikmodDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "mpd_error.h" #include "tag_handler.h" diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx index 3c6dc0ca1..a08c96f97 100644 --- a/src/decoder/ModplugDecoderPlugin.cxx +++ b/src/decoder/ModplugDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "ModplugDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "tag_handler.h" #include diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx index 36cf620c6..17130f1a8 100644 --- a/src/decoder/MpcdecDecoderPlugin.cxx +++ b/src/decoder/MpcdecDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "MpcdecDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx index f43aa5dea..ab21a9bac 100644 --- a/src/decoder/Mpg123DecoderPlugin.cxx +++ b/src/decoder/Mpg123DecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" /* must be first for large file support */ #include "Mpg123DecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/OggCodec.hxx b/src/decoder/OggCodec.hxx index e241560fb..eb709286b 100644 --- a/src/decoder/OggCodec.hxx +++ b/src/decoder/OggCodec.hxx @@ -24,7 +24,7 @@ #ifndef MPD_OGG_CODEC_HXX #define MPD_OGG_CODEC_HXX -#include "decoder_api.h" +#include "DecoderAPI.hxx" enum ogg_codec { OGG_CODEC_UNKNOWN, diff --git a/src/decoder/OggUtil.cxx b/src/decoder/OggUtil.cxx index a1125a2c6..0e2f48f51 100644 --- a/src/decoder/OggUtil.cxx +++ b/src/decoder/OggUtil.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "OggUtil.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" bool OggFeed(ogg_sync_state &oy, struct decoder *decoder, diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx index 3e3a1e4e7..f1304a1b7 100644 --- a/src/decoder/OpusDecoderPlugin.cxx +++ b/src/decoder/OpusDecoderPlugin.cxx @@ -24,7 +24,7 @@ #include "OggUtil.hxx" #include "OggFind.hxx" #include "OggSyncState.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "OggCodec.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx index a1c965bbb..c86d0fa3b 100644 --- a/src/decoder/PcmDecoderPlugin.cxx +++ b/src/decoder/PcmDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "decoder/PcmDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" extern "C" { #include "util/byte_reverse.h" diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx index d884ca2d1..0a40971a4 100644 --- a/src/decoder/SndfileDecoderPlugin.cxx +++ b/src/decoder/SndfileDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "SndfileDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "audio_check.h" #include "tag_handler.h" diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx index 822714c4e..bc3c1edce 100644 --- a/src/decoder/VorbisDecoderPlugin.cxx +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "VorbisDecoderPlugin.h" #include "VorbisComments.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "InputStream.hxx" #include "OggCodec.hxx" #include "util/UriUtil.hxx" diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx index bac62d429..6776f7193 100644 --- a/src/decoder/WavpackDecoderPlugin.cxx +++ b/src/decoder/WavpackDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "WavpackDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "InputStream.hxx" extern "C" { diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx index 28602e38a..c6979132b 100644 --- a/src/decoder/WildmidiDecoderPlugin.cxx +++ b/src/decoder/WildmidiDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "WildmidiDecoderPlugin.hxx" -#include "decoder_api.h" +#include "DecoderAPI.hxx" #include "tag_handler.h" #include "glib_compat.h" diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx index 175d2ee7c..eec9437d1 100644 --- a/src/decoder/sidplay_decoder_plugin.cxx +++ b/src/decoder/sidplay_decoder_plugin.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "../decoder_api.h" +#include "../DecoderAPI.hxx" extern "C" { #include "tag_handler.h" diff --git a/src/decoder_api.h b/src/decoder_api.h deleted file mode 100644 index 3f84ca8bc..000000000 --- a/src/decoder_api.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/*! \file - * \brief The MPD Decoder API - * - * This is the public API which is used by decoder plugins to - * communicate with the mpd core. - */ - -#ifndef MPD_DECODER_API_H -#define MPD_DECODER_API_H - -#include "check.h" -#include "decoder_command.h" -#include "decoder_plugin.h" -#include "input_stream.h" -#include "replay_gain_info.h" -#include "tag.h" -#include "audio_format.h" -#include "conf.h" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Notify the player thread that it has finished initialization and - * that it has read the song's meta data. - * - * @param decoder the decoder object - * @param audio_format the audio format which is going to be sent to - * decoder_data() - * @param seekable true if the song is seekable - * @param total_time the total number of seconds in this song; -1 if unknown - */ -void -decoder_initialized(struct decoder *decoder, - const struct audio_format *audio_format, - bool seekable, float total_time); - -/** - * Determines the pending decoder command. - * - * @param decoder the decoder object - * @return the current command, or DECODE_COMMAND_NONE if there is no - * command pending - */ -enum decoder_command -decoder_get_command(struct decoder *decoder); - -/** - * Called by the decoder when it has performed the requested command - * (dc->command). This function resets dc->command and wakes up the - * player thread. - * - * @param decoder the decoder object - */ -void -decoder_command_finished(struct decoder *decoder); - -/** - * Call this when you have received the DECODE_COMMAND_SEEK command. - * - * @param decoder the decoder object - * @return the destination position for the week - */ -double -decoder_seek_where(struct decoder *decoder); - -/** - * Call this instead of decoder_command_finished() when seeking has - * failed. - * - * @param decoder the decoder object - */ -void -decoder_seek_error(struct decoder *decoder); - -/** - * Blocking read from the input stream. - * - * @param decoder the decoder object - * @param is the input stream to read from - * @param buffer the destination buffer - * @param length the maximum number of bytes to read - * @return the number of bytes read, or 0 if one of the following - * occurs: end of file; error; command (like SEEK or STOP). - */ -size_t -decoder_read(struct decoder *decoder, struct input_stream *is, - void *buffer, size_t length); - -/** - * Sets the time stamp for the next data chunk [seconds]. The MPD - * core automatically counts it up, and a decoder plugin only needs to - * use this function if it thinks that adding to the time stamp based - * on the buffer size won't work. - */ -void -decoder_timestamp(struct decoder *decoder, double t); - -/** - * This function is called by the decoder plugin when it has - * successfully decoded block of input data. - * - * @param decoder the decoder object - * @param is an input stream which is buffering while we are waiting - * for the player - * @param data the source buffer - * @param length the number of bytes in the buffer - * @return the current command, or DECODE_COMMAND_NONE if there is no - * command pending - */ -enum decoder_command -decoder_data(struct decoder *decoder, struct input_stream *is, - const void *data, size_t length, - uint16_t kbit_rate); - -/** - * This function is called by the decoder plugin when it has - * successfully decoded a tag. - * - * @param decoder the decoder object - * @param is an input stream which is buffering while we are waiting - * for the player - * @param tag the tag to send - * @return the current command, or DECODE_COMMAND_NONE if there is no - * command pending - */ -enum decoder_command -decoder_tag(struct decoder *decoder, struct input_stream *is, - const struct tag *tag); - -/** - * Set replay gain values for the following chunks. - * - * @param decoder the decoder object - * @param rgi the replay_gain_info object; may be NULL to invalidate - * the previous replay gain values - */ -void -decoder_replay_gain(struct decoder *decoder, - const struct replay_gain_info *replay_gain_info); - -/** - * Store MixRamp tags. - * - * @param decoder the decoder object - * @param mixramp_start the mixramp_start tag; may be NULL to invalidate - * @param mixramp_end the mixramp_end tag; may be NULL to invalidate - */ -void -decoder_mixramp(struct decoder *decoder, - char *mixramp_start, char *mixramp_end); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/decoder_command.h b/src/decoder_command.h deleted file mode 100644 index 795e13fb2..000000000 --- a/src/decoder_command.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_DECODER_COMMAND_H -#define MPD_DECODER_COMMAND_H - -enum decoder_command { - DECODE_COMMAND_NONE = 0, - DECODE_COMMAND_START, - DECODE_COMMAND_STOP, - DECODE_COMMAND_SEEK -}; - -#endif diff --git a/src/decoder_error.h b/src/decoder_error.h deleted file mode 100644 index a12a31937..000000000 --- a/src/decoder_error.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2003-2012 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_DECODER_ERROR_H -#define MPD_DECODER_ERROR_H - -#include - -/** - * Quark for GError.domain. - */ -G_GNUC_CONST -static inline GQuark -decoder_quark(void) -{ - return g_quark_from_static_string("decoder"); -} - -#endif diff --git a/src/decoder_plugin.h b/src/decoder_plugin.h deleted file mode 100644 index b7ab738b5..000000000 --- a/src/decoder_plugin.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_DECODER_PLUGIN_H -#define MPD_DECODER_PLUGIN_H - -#include -#include - -struct config_param; -struct input_stream; -struct tag; -struct tag_handler; - -/** - * Opaque handle which the decoder plugin passes to the functions in - * this header. - */ -struct decoder; - -struct decoder_plugin { - const char *name; - - /** - * Initialize the decoder plugin. Optional method. - * - * @param param a configuration block for this plugin, or NULL - * if none is configured - * @return true if the plugin was initialized successfully, - * false if the plugin is not available - */ - bool (*init)(const struct config_param *param); - - /** - * Deinitialize a decoder plugin which was initialized - * successfully. Optional method. - */ - void (*finish)(void); - - /** - * Decode a stream (data read from an #input_stream object). - * - * Either implement this method or file_decode(). If - * possible, it is recommended to implement this method, - * because it is more versatile. - */ - void (*stream_decode)(struct decoder *decoder, - struct input_stream *is); - - /** - * Decode a local file. - * - * Either implement this method or stream_decode(). - */ - void (*file_decode)(struct decoder *decoder, const char *path_fs); - - /** - * Scan metadata of a file. - * - * @return false if the operation has failed - */ - bool (*scan_file)(const char *path_fs, - const struct tag_handler *handler, - void *handler_ctx); - - /** - * Scan metadata of a file. - * - * @return false if the operation has failed - */ - bool (*scan_stream)(struct input_stream *is, - const struct tag_handler *handler, - void *handler_ctx); - - /** - * @brief Return a "virtual" filename for subtracks in - * container formats like flac - * @param const char* pathname full pathname for the file on fs - * @param const unsigned int tnum track number - * - * @return NULL if there are no multiple files - * a filename for every single track according to tnum (param 2) - * do not include full pathname here, just the "virtual" file - */ - char* (*container_scan)(const char *path_fs, const unsigned int tnum); - - /* last element in these arrays must always be a NULL: */ - const char *const*suffixes; - const char *const*mime_types; -}; - -/** - * Initialize a decoder plugin. - * - * @param param a configuration block for this plugin, or NULL if none - * is configured - * @return true if the plugin was initialized successfully, false if - * the plugin is not available - */ -static inline bool -decoder_plugin_init(const struct decoder_plugin *plugin, - const struct config_param *param) -{ - return plugin->init != NULL - ? plugin->init(param) - : true; -} - -/** - * Deinitialize a decoder plugin which was initialized successfully. - */ -static inline void -decoder_plugin_finish(const struct decoder_plugin *plugin) -{ - if (plugin->finish != NULL) - plugin->finish(); -} - -/** - * Decode a stream. - */ -static inline void -decoder_plugin_stream_decode(const struct decoder_plugin *plugin, - struct decoder *decoder, struct input_stream *is) -{ - plugin->stream_decode(decoder, is); -} - -/** - * Decode a file. - */ -static inline void -decoder_plugin_file_decode(const struct decoder_plugin *plugin, - struct decoder *decoder, const char *path_fs) -{ - plugin->file_decode(decoder, path_fs); -} - -/** - * Read the tag of a file. - */ -static inline bool -decoder_plugin_scan_file(const struct decoder_plugin *plugin, - const char *path_fs, - const struct tag_handler *handler, void *handler_ctx) -{ - return plugin->scan_file != NULL - ? plugin->scan_file(path_fs, handler, handler_ctx) - : false; -} - -/** - * Read the tag of a stream. - */ -static inline bool -decoder_plugin_scan_stream(const struct decoder_plugin *plugin, - struct input_stream *is, - const struct tag_handler *handler, - void *handler_ctx) -{ - return plugin->scan_stream != NULL - ? plugin->scan_stream(is, handler, handler_ctx) - : false; -} - -/** - * return "virtual" tracks in a container - */ -static inline char * -decoder_plugin_container_scan( const struct decoder_plugin *plugin, - const char* pathname, - const unsigned int tnum) -{ - return plugin->container_scan(pathname, tnum); -} - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Does the plugin announce the specified file name suffix? - */ -bool -decoder_plugin_supports_suffix(const struct decoder_plugin *plugin, - const char *suffix); - -/** - * Does the plugin announce the specified MIME type? - */ -bool -decoder_plugin_supports_mime_type(const struct decoder_plugin *plugin, - const char *mime_type); - -#ifdef __cplusplus -} -#endif - -#endif -- cgit v1.2.3