aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 09:46:41 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 09:46:41 +0100
commitde0ab43bc12be345d85779e444266153ff5be007 (patch)
treece024a0c25c6fc75c65438b562b6300c06737a33
parente12cc01aa4b25798a2887ac6c5e01309e744ea8b (diff)
output_*: convert to C++
-rw-r--r--Makefile.am28
-rw-r--r--src/CommandLine.cxx2
-rw-r--r--src/OutputAll.cxx (renamed from src/output_all.c)17
-rw-r--r--src/OutputCommand.cxx (renamed from src/output_command.c)5
-rw-r--r--src/OutputCommand.hxx (renamed from src/output_command.h)8
-rw-r--r--src/OutputCommands.cxx5
-rw-r--r--src/OutputControl.cxx (renamed from src/output_control.c)12
-rw-r--r--src/OutputControl.hxx (renamed from src/output_control.h)7
-rw-r--r--src/OutputError.hxx (renamed from src/output_error.h)6
-rw-r--r--src/OutputFinish.cxx (renamed from src/output_finish.c)5
-rw-r--r--src/OutputInit.cxx (renamed from src/output_init.c)15
-rw-r--r--src/OutputList.cxx (renamed from src/output_list.c)4
-rw-r--r--src/OutputList.hxx (renamed from src/output_list.h)6
-rw-r--r--src/OutputPlugin.cxx (renamed from src/output_plugin.c)6
-rw-r--r--src/OutputThread.cxx (renamed from src/output_thread.c)31
-rw-r--r--src/OutputThread.hxx (renamed from src/output_thread.h)6
-rw-r--r--test/run_output.cxx (renamed from test/run_output.c)12
17 files changed, 99 insertions, 76 deletions
diff --git a/Makefile.am b/Makefile.am
index 12841d02..5ec3ec12 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,11 +52,7 @@ mpd_headers = \
src/audio_parser.h \
src/output_internal.h \
src/output_api.h \
- src/output_list.h \
src/output_all.h \
- src/output_thread.h \
- src/output_control.h \
- src/output_command.h \
src/filter_internal.h \
src/filter_config.h \
src/filter_plugin.h \
@@ -785,17 +781,17 @@ OUTPUT_LIBS = \
$(SHOUT_LIBS)
OUTPUT_API_SRC = \
- src/output_list.c \
- src/output_all.c \
- src/output_thread.c \
- src/output_error.h \
- src/output_control.c \
+ src/OutputList.cxx src/OutputList.hxx \
+ src/OutputAll.cxx \
+ src/OutputThread.cxx src/OutputThread.hxx \
+ src/OutputError.hxx \
+ src/OutputControl.cxx src/OutputControl.hxx \
src/OutputState.cxx src/OutputState.hxx \
src/OutputPrint.cxx src/OutputPrint.hxx \
- src/output_command.c \
- src/output_plugin.c src/output_plugin.h \
- src/output_finish.c \
- src/output_init.c
+ src/OutputCommand.cxx src/OutputCommand.hxx \
+ src/OutputPlugin.cxx src/output_plugin.h \
+ src/OutputFinish.cxx \
+ src/OutputInit.cxx
liboutput_plugins_a_SOURCES = \
src/output/null_output_plugin.h \
@@ -1265,7 +1261,7 @@ test_run_output_LDADD = $(MPD_LIBS) \
$(FILTER_LIBS) \
libutil.a \
$(GLIB_LIBS)
-test_run_output_SOURCES = test/run_output.c \
+test_run_output_SOURCES = test/run_output.cxx \
test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \
src/io_thread.c src/io_thread.h \
@@ -1278,8 +1274,8 @@ test_run_output_SOURCES = test/run_output.c \
src/page.c \
src/socket_util.c \
src/resolver.c \
- src/output_init.c src/output_finish.c src/output_list.c \
- src/output_plugin.c \
+ src/OutputInit.cxx src/OutputFinish.cxx src/OutputList.cxx \
+ src/OutputPlugin.cxx \
src/mixer_api.c \
src/mixer_control.c \
src/mixer_type.c \
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index a588ad5b..4d9d2ca9 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -29,7 +29,7 @@ extern "C" {
#include "decoder_list.h"
#include "decoder_plugin.h"
-#include "output_list.h"
+#include "OutputList.hxx"
#include "output_plugin.h"
#include "input_registry.h"
#include "input_plugin.h"
diff --git a/src/output_all.c b/src/OutputAll.cxx
index b2ef1561..ec716a41 100644
--- a/src/output_all.c
+++ b/src/OutputAll.cxx
@@ -18,17 +18,24 @@
*/
#include "config.h"
+
+extern "C" {
#include "output_all.h"
-#include "output_error.h"
#include "output_internal.h"
-#include "output_control.h"
-#include "chunk.h"
+}
+
+#include "OutputControl.hxx"
+#include "OutputError.hxx"
+#include "mpd_error.h"
+
+extern "C" {
+#include "player_control.h"
#include "conf.h"
+#include "chunk.h"
#include "pipe.h"
#include "buffer.h"
-#include "player_control.h"
-#include "mpd_error.h"
#include "notify.h"
+}
#ifndef NDEBUG
#include "chunk.h"
diff --git a/src/output_command.c b/src/OutputCommand.cxx
index 3988f350..ed4cd8e8 100644
--- a/src/output_command.c
+++ b/src/OutputCommand.cxx
@@ -25,13 +25,16 @@
*/
#include "config.h"
-#include "output_command.h"
+#include "OutputCommand.hxx"
+
+extern "C" {
#include "output_all.h"
#include "output_internal.h"
#include "output_plugin.h"
#include "mixer_control.h"
#include "player_control.h"
#include "idle.h"
+}
extern unsigned audio_output_state_version;
diff --git a/src/output_command.h b/src/OutputCommand.hxx
index eda30acc..74eaf8f1 100644
--- a/src/output_command.h
+++ b/src/OutputCommand.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -24,10 +24,8 @@
*
*/
-#ifndef OUTPUT_COMMAND_H
-#define OUTPUT_COMMAND_H
-
-#include <stdbool.h>
+#ifndef MPD_OUTPUT_COMMAND_HXX
+#define MPD_OUTPUT_COMMAND_HXX
/**
* Enables an audio output. Returns false if the specified output
diff --git a/src/OutputCommands.cxx b/src/OutputCommands.cxx
index 4dd689c4..7d626477 100644
--- a/src/OutputCommands.cxx
+++ b/src/OutputCommands.cxx
@@ -20,13 +20,10 @@
#include "config.h"
#include "OutputCommands.hxx"
#include "OutputPrint.hxx"
+#include "OutputCommand.hxx"
#include "protocol/Result.hxx"
#include "protocol/ArgParser.hxx"
-extern "C" {
-#include "output_command.h"
-}
-
#include <string.h>
enum command_return
diff --git a/src/output_control.c b/src/OutputControl.cxx
index 7b95be49..36e80a01 100644
--- a/src/output_control.c
+++ b/src/OutputControl.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,14 +18,18 @@
*/
#include "config.h"
-#include "output_control.h"
+#include "OutputControl.hxx"
+#include "OutputThread.hxx"
+
+extern "C" {
#include "output_api.h"
#include "output_internal.h"
-#include "output_thread.h"
#include "mixer_control.h"
#include "mixer_plugin.h"
-#include "filter_plugin.h"
#include "notify.h"
+}
+
+#include "filter_plugin.h"
#include <assert.h>
#include <stdlib.h>
diff --git a/src/output_control.h b/src/OutputControl.hxx
index 874a5351..90769180 100644
--- a/src/output_control.h
+++ b/src/OutputControl.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -17,13 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_OUTPUT_CONTROL_H
-#define MPD_OUTPUT_CONTROL_H
+#ifndef MPD_OUTPUT_CONTROL_HXX
+#define MPD_OUTPUT_CONTROL_HXX
#include <glib.h>
#include <stddef.h>
-#include <stdbool.h>
struct audio_output;
struct audio_format;
diff --git a/src/output_error.h b/src/OutputError.hxx
index ccc784f8..451df985 100644
--- a/src/output_error.h
+++ b/src/OutputError.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * 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
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_OUTPUT_ERROR_H
-#define MPD_OUTPUT_ERROR_H
+#ifndef MPD_OUTPUT_ERROR_HXX
+#define MPD_OUTPUT_ERROR_HXX
#include <glib.h>
diff --git a/src/output_finish.c b/src/OutputFinish.cxx
index e11b4367..ac6ad697 100644
--- a/src/output_finish.c
+++ b/src/OutputFinish.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,10 +18,13 @@
*/
#include "config.h"
+
+extern "C" {
#include "output_internal.h"
#include "output_plugin.h"
#include "mixer_control.h"
#include "filter_plugin.h"
+}
#include <assert.h>
diff --git a/src/output_init.c b/src/OutputInit.cxx
index a6d19192..5fc800d1 100644
--- a/src/output_init.c
+++ b/src/OutputInit.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,10 +18,12 @@
*/
#include "config.h"
-#include "output_control.h"
+#include "OutputControl.hxx"
+#include "OutputList.hxx"
+
+extern "C" {
#include "output_api.h"
#include "output_internal.h"
-#include "output_list.h"
#include "audio_parser.h"
#include "mixer_control.h"
#include "mixer_type.h"
@@ -33,6 +35,7 @@
#include "filter/chain_filter_plugin.h"
#include "filter/autoconvert_filter_plugin.h"
#include "filter/replay_gain_filter_plugin.h"
+}
#include <glib.h>
@@ -298,14 +301,14 @@ audio_output_new(const struct config_param *param,
if (p == NULL) {
g_set_error(error_r, audio_output_quark(), 0,
"Missing \"type\" configuration");
- return false;
+ return nullptr;
}
plugin = audio_output_plugin_get(p);
if (plugin == NULL) {
g_set_error(error_r, audio_output_quark(), 0,
"No such audio output plugin: %s", p);
- return false;
+ return nullptr;
}
} else {
g_warning("No \"%s\" defined in config file\n",
@@ -313,7 +316,7 @@ audio_output_new(const struct config_param *param,
plugin = audio_output_detect(error_r);
if (plugin == NULL)
- return false;
+ return nullptr;
g_message("Successfully detected a %s audio device",
plugin->name);
diff --git a/src/output_list.c b/src/OutputList.cxx
index 835c02bb..3e469385 100644
--- a/src/output_list.c
+++ b/src/OutputList.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include "output_list.h"
+#include "OutputList.hxx"
#include "output_api.h"
#include "output/alsa_output_plugin.h"
#include "output/ao_output_plugin.h"
diff --git a/src/output_list.h b/src/OutputList.hxx
index 185ada71..b7716c67 100644
--- a/src/output_list.h
+++ b/src/OutputList.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_OUTPUT_LIST_H
-#define MPD_OUTPUT_LIST_H
+#ifndef MPD_OUTPUT_LIST_HXX
+#define MPD_OUTPUT_LIST_HXX
extern const struct audio_output_plugin *const audio_output_plugins[];
diff --git a/src/output_plugin.c b/src/OutputPlugin.cxx
index 221570c1..9aa0f779 100644
--- a/src/output_plugin.c
+++ b/src/OutputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,7 +18,11 @@
*/
#include "config.h"
+
+extern "C" {
#include "output_plugin.h"
+}
+
#include "output_internal.h"
struct audio_output *
diff --git a/src/output_thread.c b/src/OutputThread.cxx
index cd1a8a87..75394703 100644
--- a/src/output_thread.c
+++ b/src/OutputThread.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,7 +18,9 @@
*/
#include "config.h"
-#include "output_thread.h"
+#include "OutputThread.hxx"
+
+extern "C" {
#include "output_api.h"
#include "output_internal.h"
#include "chunk.h"
@@ -28,8 +30,10 @@
#include "filter_plugin.h"
#include "filter/convert_filter_plugin.h"
#include "filter/replay_gain_filter_plugin.h"
-#include "mpd_error.h"
#include "notify.h"
+}
+
+#include "mpd_error.h"
#include "gcc.h"
#include <glib.h>
@@ -315,7 +319,7 @@ ao_wait(struct audio_output *ao)
}
}
-static const char *
+static const void *
ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
struct filter *replay_gain_filter,
unsigned *replay_gain_serial_p,
@@ -325,7 +329,7 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
assert(!music_chunk_is_empty(chunk));
assert(music_chunk_check_format(chunk, &ao->in_audio_format));
- const char *data = chunk->data;
+ const void *data = chunk->data;
size_t length = chunk->length;
(void)ao;
@@ -356,14 +360,14 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
return data;
}
-static const char *
+static const void *
ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
size_t *length_r)
{
GError *error = NULL;
size_t length;
- const char *data = ao_chunk_data(ao, chunk, ao->replay_gain_filter,
+ const void *data = ao_chunk_data(ao, chunk, ao->replay_gain_filter,
&ao->replay_gain_serial, &length);
if (data == NULL)
return NULL;
@@ -378,7 +382,7 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
if (chunk->other != NULL) {
size_t other_length;
- const char *other_data =
+ const void *other_data =
ao_chunk_data(ao, chunk->other,
ao->other_replay_gain_filter,
&ao->other_replay_gain_serial,
@@ -399,13 +403,14 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
if (length > other_length)
length = other_length;
- char *dest = pcm_buffer_get(&ao->cross_fade_buffer,
+ void *dest = pcm_buffer_get(&ao->cross_fade_buffer,
other_length);
memcpy(dest, other_data, other_length);
- if (!pcm_mix(dest, data, length, ao->in_audio_format.format,
+ if (!pcm_mix(dest, data, length,
+ sample_format(ao->in_audio_format.format),
1.0 - chunk->mix_ratio)) {
g_warning("Cannot cross-fade format %s",
- sample_format_to_string(ao->in_audio_format.format));
+ sample_format_to_string(sample_format(ao->in_audio_format.format)));
return NULL;
}
@@ -446,7 +451,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
/* workaround -Wmaybe-uninitialized false positive */
size = 0;
#endif
- const char *data = ao_filter_chunk(ao, chunk, &size);
+ const char *data = (const char *)ao_filter_chunk(ao, chunk, &size);
if (data == NULL) {
ao_close(ao, false);
@@ -578,7 +583,7 @@ static void ao_pause(struct audio_output *ao)
static gpointer audio_output_task(gpointer arg)
{
- struct audio_output *ao = arg;
+ struct audio_output *ao = (struct audio_output *)arg;
g_mutex_lock(ao->mutex);
diff --git a/src/output_thread.h b/src/OutputThread.hxx
index 5ad9a752..1a793216 100644
--- a/src/output_thread.h
+++ b/src/OutputThread.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_OUTPUT_THREAD_H
-#define MPD_OUTPUT_THREAD_H
+#ifndef MPD_OUTPUT_THREAD_HXX
+#define MPD_OUTPUT_THREAD_HXX
struct audio_output;
diff --git a/test/run_output.c b/test/run_output.cxx
index bbb1be7d..2b0fdd5f 100644
--- a/test/run_output.c
+++ b/test/run_output.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * 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
@@ -18,16 +18,20 @@
*/
#include "config.h"
-#include "io_thread.h"
+#include "OutputControl.hxx"
+
+extern "C" {
#include "output_plugin.h"
#include "output_internal.h"
-#include "output_control.h"
+#include "io_thread.h"
#include "conf.h"
#include "audio_parser.h"
#include "filter_registry.h"
#include "pcm_convert.h"
#include "event_pipe.h"
#include "idle.h"
+}
+
#include "playlist.h"
#include "player_control.h"
#include "stdbin.h"
@@ -103,7 +107,7 @@ load_audio_output(const char *name)
param = find_named_config_block(CONF_AUDIO_OUTPUT, name);
if (param == NULL) {
g_printerr("No such configured audio output: %s\n", name);
- return false;
+ return nullptr;
}
static struct player_control dummy_player_control;