Commit de0ab43b authored by Max Kellermann's avatar Max Kellermann

output_*: convert to C++

parent e12cc01a
...@@ -52,11 +52,7 @@ mpd_headers = \ ...@@ -52,11 +52,7 @@ mpd_headers = \
src/audio_parser.h \ src/audio_parser.h \
src/output_internal.h \ src/output_internal.h \
src/output_api.h \ src/output_api.h \
src/output_list.h \
src/output_all.h \ src/output_all.h \
src/output_thread.h \
src/output_control.h \
src/output_command.h \
src/filter_internal.h \ src/filter_internal.h \
src/filter_config.h \ src/filter_config.h \
src/filter_plugin.h \ src/filter_plugin.h \
...@@ -785,17 +781,17 @@ OUTPUT_LIBS = \ ...@@ -785,17 +781,17 @@ OUTPUT_LIBS = \
$(SHOUT_LIBS) $(SHOUT_LIBS)
OUTPUT_API_SRC = \ OUTPUT_API_SRC = \
src/output_list.c \ src/OutputList.cxx src/OutputList.hxx \
src/output_all.c \ src/OutputAll.cxx \
src/output_thread.c \ src/OutputThread.cxx src/OutputThread.hxx \
src/output_error.h \ src/OutputError.hxx \
src/output_control.c \ src/OutputControl.cxx src/OutputControl.hxx \
src/OutputState.cxx src/OutputState.hxx \ src/OutputState.cxx src/OutputState.hxx \
src/OutputPrint.cxx src/OutputPrint.hxx \ src/OutputPrint.cxx src/OutputPrint.hxx \
src/output_command.c \ src/OutputCommand.cxx src/OutputCommand.hxx \
src/output_plugin.c src/output_plugin.h \ src/OutputPlugin.cxx src/output_plugin.h \
src/output_finish.c \ src/OutputFinish.cxx \
src/output_init.c src/OutputInit.cxx
liboutput_plugins_a_SOURCES = \ liboutput_plugins_a_SOURCES = \
src/output/null_output_plugin.h \ src/output/null_output_plugin.h \
...@@ -1265,7 +1261,7 @@ test_run_output_LDADD = $(MPD_LIBS) \ ...@@ -1265,7 +1261,7 @@ test_run_output_LDADD = $(MPD_LIBS) \
$(FILTER_LIBS) \ $(FILTER_LIBS) \
libutil.a \ libutil.a \
$(GLIB_LIBS) $(GLIB_LIBS)
test_run_output_SOURCES = test/run_output.c \ test_run_output_SOURCES = test/run_output.cxx \
test/stdbin.h \ test/stdbin.h \
src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \ src/conf.c src/tokenizer.c src/utils.c src/string_util.c src/log.c \
src/io_thread.c src/io_thread.h \ src/io_thread.c src/io_thread.h \
...@@ -1278,8 +1274,8 @@ test_run_output_SOURCES = test/run_output.c \ ...@@ -1278,8 +1274,8 @@ test_run_output_SOURCES = test/run_output.c \
src/page.c \ src/page.c \
src/socket_util.c \ src/socket_util.c \
src/resolver.c \ src/resolver.c \
src/output_init.c src/output_finish.c src/output_list.c \ src/OutputInit.cxx src/OutputFinish.cxx src/OutputList.cxx \
src/output_plugin.c \ src/OutputPlugin.cxx \
src/mixer_api.c \ src/mixer_api.c \
src/mixer_control.c \ src/mixer_control.c \
src/mixer_type.c \ src/mixer_type.c \
......
...@@ -29,7 +29,7 @@ extern "C" { ...@@ -29,7 +29,7 @@ extern "C" {
#include "decoder_list.h" #include "decoder_list.h"
#include "decoder_plugin.h" #include "decoder_plugin.h"
#include "output_list.h" #include "OutputList.hxx"
#include "output_plugin.h" #include "output_plugin.h"
#include "input_registry.h" #include "input_registry.h"
#include "input_plugin.h" #include "input_plugin.h"
......
...@@ -18,17 +18,24 @@ ...@@ -18,17 +18,24 @@
*/ */
#include "config.h" #include "config.h"
extern "C" {
#include "output_all.h" #include "output_all.h"
#include "output_error.h"
#include "output_internal.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 "conf.h"
#include "chunk.h"
#include "pipe.h" #include "pipe.h"
#include "buffer.h" #include "buffer.h"
#include "player_control.h"
#include "mpd_error.h"
#include "notify.h" #include "notify.h"
}
#ifndef NDEBUG #ifndef NDEBUG
#include "chunk.h" #include "chunk.h"
......
...@@ -25,13 +25,16 @@ ...@@ -25,13 +25,16 @@
*/ */
#include "config.h" #include "config.h"
#include "output_command.h" #include "OutputCommand.hxx"
extern "C" {
#include "output_all.h" #include "output_all.h"
#include "output_internal.h" #include "output_internal.h"
#include "output_plugin.h" #include "output_plugin.h"
#include "mixer_control.h" #include "mixer_control.h"
#include "player_control.h" #include "player_control.h"
#include "idle.h" #include "idle.h"
}
extern unsigned audio_output_state_version; extern unsigned audio_output_state_version;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -24,10 +24,8 @@ ...@@ -24,10 +24,8 @@
* *
*/ */
#ifndef OUTPUT_COMMAND_H #ifndef MPD_OUTPUT_COMMAND_HXX
#define OUTPUT_COMMAND_H #define MPD_OUTPUT_COMMAND_HXX
#include <stdbool.h>
/** /**
* Enables an audio output. Returns false if the specified output * Enables an audio output. Returns false if the specified output
......
...@@ -20,13 +20,10 @@ ...@@ -20,13 +20,10 @@
#include "config.h" #include "config.h"
#include "OutputCommands.hxx" #include "OutputCommands.hxx"
#include "OutputPrint.hxx" #include "OutputPrint.hxx"
#include "OutputCommand.hxx"
#include "protocol/Result.hxx" #include "protocol/Result.hxx"
#include "protocol/ArgParser.hxx" #include "protocol/ArgParser.hxx"
extern "C" {
#include "output_command.h"
}
#include <string.h> #include <string.h>
enum command_return enum command_return
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,14 +18,18 @@ ...@@ -18,14 +18,18 @@
*/ */
#include "config.h" #include "config.h"
#include "output_control.h" #include "OutputControl.hxx"
#include "OutputThread.hxx"
extern "C" {
#include "output_api.h" #include "output_api.h"
#include "output_internal.h" #include "output_internal.h"
#include "output_thread.h"
#include "mixer_control.h" #include "mixer_control.h"
#include "mixer_plugin.h" #include "mixer_plugin.h"
#include "filter_plugin.h"
#include "notify.h" #include "notify.h"
}
#include "filter_plugin.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,13 +17,12 @@ ...@@ -17,13 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_OUTPUT_CONTROL_H #ifndef MPD_OUTPUT_CONTROL_HXX
#define MPD_OUTPUT_CONTROL_H #define MPD_OUTPUT_CONTROL_HXX
#include <glib.h> #include <glib.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h>
struct audio_output; struct audio_output;
struct audio_format; struct audio_format;
......
/* /*
* Copyright (C) 2003-2012 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_OUTPUT_ERROR_H #ifndef MPD_OUTPUT_ERROR_HXX
#define MPD_OUTPUT_ERROR_H #define MPD_OUTPUT_ERROR_HXX
#include <glib.h> #include <glib.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
*/ */
#include "config.h" #include "config.h"
extern "C" {
#include "output_internal.h" #include "output_internal.h"
#include "output_plugin.h" #include "output_plugin.h"
#include "mixer_control.h" #include "mixer_control.h"
#include "filter_plugin.h" #include "filter_plugin.h"
}
#include <assert.h> #include <assert.h>
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
*/ */
#include "config.h" #include "config.h"
#include "output_control.h" #include "OutputControl.hxx"
#include "OutputList.hxx"
extern "C" {
#include "output_api.h" #include "output_api.h"
#include "output_internal.h" #include "output_internal.h"
#include "output_list.h"
#include "audio_parser.h" #include "audio_parser.h"
#include "mixer_control.h" #include "mixer_control.h"
#include "mixer_type.h" #include "mixer_type.h"
...@@ -33,6 +35,7 @@ ...@@ -33,6 +35,7 @@
#include "filter/chain_filter_plugin.h" #include "filter/chain_filter_plugin.h"
#include "filter/autoconvert_filter_plugin.h" #include "filter/autoconvert_filter_plugin.h"
#include "filter/replay_gain_filter_plugin.h" #include "filter/replay_gain_filter_plugin.h"
}
#include <glib.h> #include <glib.h>
...@@ -298,14 +301,14 @@ audio_output_new(const struct config_param *param, ...@@ -298,14 +301,14 @@ audio_output_new(const struct config_param *param,
if (p == NULL) { if (p == NULL) {
g_set_error(error_r, audio_output_quark(), 0, g_set_error(error_r, audio_output_quark(), 0,
"Missing \"type\" configuration"); "Missing \"type\" configuration");
return false; return nullptr;
} }
plugin = audio_output_plugin_get(p); plugin = audio_output_plugin_get(p);
if (plugin == NULL) { if (plugin == NULL) {
g_set_error(error_r, audio_output_quark(), 0, g_set_error(error_r, audio_output_quark(), 0,
"No such audio output plugin: %s", p); "No such audio output plugin: %s", p);
return false; return nullptr;
} }
} else { } else {
g_warning("No \"%s\" defined in config file\n", g_warning("No \"%s\" defined in config file\n",
...@@ -313,7 +316,7 @@ audio_output_new(const struct config_param *param, ...@@ -313,7 +316,7 @@ audio_output_new(const struct config_param *param,
plugin = audio_output_detect(error_r); plugin = audio_output_detect(error_r);
if (plugin == NULL) if (plugin == NULL)
return false; return nullptr;
g_message("Successfully detected a %s audio device", g_message("Successfully detected a %s audio device",
plugin->name); plugin->name);
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "config.h" #include "config.h"
#include "output_list.h" #include "OutputList.hxx"
#include "output_api.h" #include "output_api.h"
#include "output/alsa_output_plugin.h" #include "output/alsa_output_plugin.h"
#include "output/ao_output_plugin.h" #include "output/ao_output_plugin.h"
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_OUTPUT_LIST_H #ifndef MPD_OUTPUT_LIST_HXX
#define MPD_OUTPUT_LIST_H #define MPD_OUTPUT_LIST_HXX
extern const struct audio_output_plugin *const audio_output_plugins[]; extern const struct audio_output_plugin *const audio_output_plugins[];
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
*/ */
#include "config.h" #include "config.h"
extern "C" {
#include "output_plugin.h" #include "output_plugin.h"
}
#include "output_internal.h" #include "output_internal.h"
struct audio_output * struct audio_output *
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
*/ */
#include "config.h" #include "config.h"
#include "output_thread.h" #include "OutputThread.hxx"
extern "C" {
#include "output_api.h" #include "output_api.h"
#include "output_internal.h" #include "output_internal.h"
#include "chunk.h" #include "chunk.h"
...@@ -28,8 +30,10 @@ ...@@ -28,8 +30,10 @@
#include "filter_plugin.h" #include "filter_plugin.h"
#include "filter/convert_filter_plugin.h" #include "filter/convert_filter_plugin.h"
#include "filter/replay_gain_filter_plugin.h" #include "filter/replay_gain_filter_plugin.h"
#include "mpd_error.h"
#include "notify.h" #include "notify.h"
}
#include "mpd_error.h"
#include "gcc.h" #include "gcc.h"
#include <glib.h> #include <glib.h>
...@@ -315,7 +319,7 @@ ao_wait(struct audio_output *ao) ...@@ -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, ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
struct filter *replay_gain_filter, struct filter *replay_gain_filter,
unsigned *replay_gain_serial_p, unsigned *replay_gain_serial_p,
...@@ -325,7 +329,7 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk, ...@@ -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_is_empty(chunk));
assert(music_chunk_check_format(chunk, &ao->in_audio_format)); 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; size_t length = chunk->length;
(void)ao; (void)ao;
...@@ -356,14 +360,14 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk, ...@@ -356,14 +360,14 @@ ao_chunk_data(struct audio_output *ao, const struct music_chunk *chunk,
return data; return data;
} }
static const char * static const void *
ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk, ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
size_t *length_r) size_t *length_r)
{ {
GError *error = NULL; GError *error = NULL;
size_t length; 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); &ao->replay_gain_serial, &length);
if (data == NULL) if (data == NULL)
return NULL; return NULL;
...@@ -378,7 +382,7 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk, ...@@ -378,7 +382,7 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
if (chunk->other != NULL) { if (chunk->other != NULL) {
size_t other_length; size_t other_length;
const char *other_data = const void *other_data =
ao_chunk_data(ao, chunk->other, ao_chunk_data(ao, chunk->other,
ao->other_replay_gain_filter, ao->other_replay_gain_filter,
&ao->other_replay_gain_serial, &ao->other_replay_gain_serial,
...@@ -399,13 +403,14 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk, ...@@ -399,13 +403,14 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
if (length > other_length) if (length > other_length)
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); other_length);
memcpy(dest, other_data, 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)) { 1.0 - chunk->mix_ratio)) {
g_warning("Cannot cross-fade format %s", 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; return NULL;
} }
...@@ -446,7 +451,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk) ...@@ -446,7 +451,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
/* workaround -Wmaybe-uninitialized false positive */ /* workaround -Wmaybe-uninitialized false positive */
size = 0; size = 0;
#endif #endif
const char *data = ao_filter_chunk(ao, chunk, &size); const char *data = (const char *)ao_filter_chunk(ao, chunk, &size);
if (data == NULL) { if (data == NULL) {
ao_close(ao, false); ao_close(ao, false);
...@@ -578,7 +583,7 @@ static void ao_pause(struct audio_output *ao) ...@@ -578,7 +583,7 @@ static void ao_pause(struct audio_output *ao)
static gpointer audio_output_task(gpointer arg) 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); g_mutex_lock(ao->mutex);
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_OUTPUT_THREAD_H #ifndef MPD_OUTPUT_THREAD_HXX
#define MPD_OUTPUT_THREAD_H #define MPD_OUTPUT_THREAD_HXX
struct audio_output; struct audio_output;
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,16 +18,20 @@ ...@@ -18,16 +18,20 @@
*/ */
#include "config.h" #include "config.h"
#include "io_thread.h" #include "OutputControl.hxx"
extern "C" {
#include "output_plugin.h" #include "output_plugin.h"
#include "output_internal.h" #include "output_internal.h"
#include "output_control.h" #include "io_thread.h"
#include "conf.h" #include "conf.h"
#include "audio_parser.h" #include "audio_parser.h"
#include "filter_registry.h" #include "filter_registry.h"
#include "pcm_convert.h" #include "pcm_convert.h"
#include "event_pipe.h" #include "event_pipe.h"
#include "idle.h" #include "idle.h"
}
#include "playlist.h" #include "playlist.h"
#include "player_control.h" #include "player_control.h"
#include "stdbin.h" #include "stdbin.h"
...@@ -103,7 +107,7 @@ load_audio_output(const char *name) ...@@ -103,7 +107,7 @@ load_audio_output(const char *name)
param = find_named_config_block(CONF_AUDIO_OUTPUT, name); param = find_named_config_block(CONF_AUDIO_OUTPUT, name);
if (param == NULL) { if (param == NULL) {
g_printerr("No such configured audio output: %s\n", name); g_printerr("No such configured audio output: %s\n", name);
return false; return nullptr;
} }
static struct player_control dummy_player_control; static struct player_control dummy_player_control;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment