From 9e5d2c5bb7093dd10337a5b77f6271e06baa0ebe Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 17 Apr 2013 22:22:37 +0200 Subject: encoder_list: convert to C++ --- Makefile.am | 3 +- src/CommandLine.cxx | 2 +- src/EncoderList.cxx | 65 +++++++++++++++++++++++++++++++++++++ src/EncoderList.hxx | 43 ++++++++++++++++++++++++ src/encoder_list.c | 65 ------------------------------------- src/encoder_list.h | 51 ----------------------------- src/output/HttpdOutputPlugin.cxx | 2 +- src/output/RecorderOutputPlugin.cxx | 2 +- src/output/ShoutOutputPlugin.cxx | 2 +- test/run_encoder.cxx | 2 +- test/test_vorbis_encoder.cxx | 2 +- 11 files changed, 115 insertions(+), 124 deletions(-) create mode 100644 src/EncoderList.cxx create mode 100644 src/EncoderList.hxx delete mode 100644 src/encoder_list.c delete mode 100644 src/encoder_list.h diff --git a/Makefile.am b/Makefile.am index cc7a9c294..cb3539021 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,6 @@ mpd_headers = \ src/decoder_api.h \ src/decoder_plugin.h \ src/encoder_plugin.h \ - src/encoder_list.h \ src/encoder_api.h \ src/fd_util.h \ src/gerror.h \ @@ -633,7 +632,7 @@ ENCODER_LIBS = \ libencoder_plugins_a_SOURCES = \ src/encoder/OggStream.hxx \ src/encoder/null_encoder.c \ - src/encoder_list.c + src/EncoderList.cxx src/EncoderList.hxx if ENABLE_WAVE_ENCODER libencoder_plugins_a_SOURCES += src/encoder/wave_encoder.c diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx index ec6d8c7b1..d1f386f82 100644 --- a/src/CommandLine.cxx +++ b/src/CommandLine.cxx @@ -35,7 +35,7 @@ #include "fs/FileSystem.hxx" #ifdef ENABLE_ENCODER -#include "encoder_list.h" +#include "EncoderList.hxx" #include "encoder_plugin.h" #endif diff --git a/src/EncoderList.cxx b/src/EncoderList.cxx new file mode 100644 index 000000000..e8ec9110e --- /dev/null +++ b/src/EncoderList.cxx @@ -0,0 +1,65 @@ +/* + * 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. + */ + +#include "config.h" +#include "EncoderList.hxx" +#include "encoder_plugin.h" +#include "encoder/VorbisEncoderPlugin.hxx" +#include "encoder/OpusEncoderPlugin.hxx" + +#include + +extern const struct encoder_plugin null_encoder_plugin; +extern const struct encoder_plugin lame_encoder_plugin; +extern const struct encoder_plugin twolame_encoder_plugin; +extern const struct encoder_plugin wave_encoder_plugin; +extern const struct encoder_plugin flac_encoder_plugin; + +const struct encoder_plugin *const encoder_plugins[] = { + &null_encoder_plugin, +#ifdef ENABLE_VORBIS_ENCODER + &vorbis_encoder_plugin, +#endif +#ifdef HAVE_OPUS + &opus_encoder_plugin, +#endif +#ifdef ENABLE_LAME_ENCODER + &lame_encoder_plugin, +#endif +#ifdef ENABLE_TWOLAME_ENCODER + &twolame_encoder_plugin, +#endif +#ifdef ENABLE_WAVE_ENCODER + &wave_encoder_plugin, +#endif +#ifdef ENABLE_FLAC_ENCODER + &flac_encoder_plugin, +#endif + NULL +}; + +const struct encoder_plugin * +encoder_plugin_get(const char *name) +{ + encoder_plugins_for_each(plugin) + if (strcmp(plugin->name, name) == 0) + return plugin; + + return NULL; +} diff --git a/src/EncoderList.hxx b/src/EncoderList.hxx new file mode 100644 index 000000000..69ee8e2bc --- /dev/null +++ b/src/EncoderList.hxx @@ -0,0 +1,43 @@ +/* + * 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_ENCODER_LIST_HXX +#define MPD_ENCODER_LIST_HXX + +struct encoder_plugin; + +extern const struct encoder_plugin *const encoder_plugins[]; + +#define encoder_plugins_for_each(plugin) \ + for (const struct encoder_plugin *plugin, \ + *const*encoder_plugin_iterator = &encoder_plugins[0]; \ + (plugin = *encoder_plugin_iterator) != NULL; \ + ++encoder_plugin_iterator) + +/** + * Looks up an encoder plugin by its name. + * + * @param name the encoder name to look for + * @return the encoder plugin with the specified name, or NULL if none + * was found + */ +const struct encoder_plugin * +encoder_plugin_get(const char *name); + +#endif diff --git a/src/encoder_list.c b/src/encoder_list.c deleted file mode 100644 index 029b4be34..000000000 --- a/src/encoder_list.c +++ /dev/null @@ -1,65 +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. - */ - -#include "config.h" -#include "encoder_list.h" -#include "encoder_plugin.h" -#include "encoder/VorbisEncoderPlugin.hxx" -#include "encoder/OpusEncoderPlugin.hxx" - -#include - -extern const struct encoder_plugin null_encoder_plugin; -extern const struct encoder_plugin lame_encoder_plugin; -extern const struct encoder_plugin twolame_encoder_plugin; -extern const struct encoder_plugin wave_encoder_plugin; -extern const struct encoder_plugin flac_encoder_plugin; - -const struct encoder_plugin *const encoder_plugins[] = { - &null_encoder_plugin, -#ifdef ENABLE_VORBIS_ENCODER - &vorbis_encoder_plugin, -#endif -#ifdef HAVE_OPUS - &opus_encoder_plugin, -#endif -#ifdef ENABLE_LAME_ENCODER - &lame_encoder_plugin, -#endif -#ifdef ENABLE_TWOLAME_ENCODER - &twolame_encoder_plugin, -#endif -#ifdef ENABLE_WAVE_ENCODER - &wave_encoder_plugin, -#endif -#ifdef ENABLE_FLAC_ENCODER - &flac_encoder_plugin, -#endif - NULL -}; - -const struct encoder_plugin * -encoder_plugin_get(const char *name) -{ - encoder_plugins_for_each(plugin) - if (strcmp(plugin->name, name) == 0) - return plugin; - - return NULL; -} diff --git a/src/encoder_list.h b/src/encoder_list.h deleted file mode 100644 index 31663c751..000000000 --- a/src/encoder_list.h +++ /dev/null @@ -1,51 +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_ENCODER_LIST_H -#define MPD_ENCODER_LIST_H - -struct encoder_plugin; - -extern const struct encoder_plugin *const encoder_plugins[]; - -#define encoder_plugins_for_each(plugin) \ - for (const struct encoder_plugin *plugin, \ - *const*encoder_plugin_iterator = &encoder_plugins[0]; \ - (plugin = *encoder_plugin_iterator) != NULL; \ - ++encoder_plugin_iterator) - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Looks up an encoder plugin by its name. - * - * @param name the encoder name to look for - * @return the encoder plugin with the specified name, or NULL if none - * was found - */ -const struct encoder_plugin * -encoder_plugin_get(const char *name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/output/HttpdOutputPlugin.cxx b/src/output/HttpdOutputPlugin.cxx index cb515e657..bb644c318 100644 --- a/src/output/HttpdOutputPlugin.cxx +++ b/src/output/HttpdOutputPlugin.cxx @@ -23,7 +23,7 @@ #include "HttpdClient.hxx" #include "output_api.h" #include "encoder_plugin.h" -#include "encoder_list.h" +#include "EncoderList.hxx" #include "resolver.h" #include "Page.hxx" #include "IcyMetaDataServer.hxx" diff --git a/src/output/RecorderOutputPlugin.cxx b/src/output/RecorderOutputPlugin.cxx index 8b821d773..7d15ed4b6 100644 --- a/src/output/RecorderOutputPlugin.cxx +++ b/src/output/RecorderOutputPlugin.cxx @@ -21,7 +21,7 @@ #include "RecorderOutputPlugin.hxx" #include "output_api.h" #include "encoder_plugin.h" -#include "encoder_list.h" +#include "EncoderList.hxx" #include "fd_util.h" #include "open.h" diff --git a/src/output/ShoutOutputPlugin.cxx b/src/output/ShoutOutputPlugin.cxx index d95a7eae6..7662e33ab 100644 --- a/src/output/ShoutOutputPlugin.cxx +++ b/src/output/ShoutOutputPlugin.cxx @@ -21,7 +21,7 @@ #include "ShoutOutputPlugin.hxx" #include "output_api.h" #include "encoder_plugin.h" -#include "encoder_list.h" +#include "EncoderList.hxx" #include "mpd_error.h" #include diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index 9039f2db5..91993c95a 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "encoder_list.h" +#include "EncoderList.hxx" #include "encoder_plugin.h" #include "audio_format.h" #include "AudioParser.hxx" diff --git a/test/test_vorbis_encoder.cxx b/test/test_vorbis_encoder.cxx index 0e502b154..7ac36e3ec 100644 --- a/test/test_vorbis_encoder.cxx +++ b/test/test_vorbis_encoder.cxx @@ -18,7 +18,7 @@ */ #include "config.h" -#include "encoder_list.h" +#include "EncoderList.hxx" #include "encoder_plugin.h" #include "audio_format.h" #include "conf.h" -- cgit v1.2.3