aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_output.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/run_output.cxx')
-rw-r--r--test/run_output.cxx110
1 files changed, 48 insertions, 62 deletions
diff --git a/test/run_output.cxx b/test/run_output.cxx
index 7982bd7de..e6c11669d 100644
--- a/test/run_output.cxx
+++ b/test/run_output.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,38 +18,33 @@
*/
#include "config.h"
-#include "OutputControl.hxx"
-#include "OutputInternal.hxx"
-#include "OutputPlugin.hxx"
-#include "ConfigData.hxx"
-#include "ConfigGlobal.hxx"
-#include "ConfigOption.hxx"
+#include "output/Internal.hxx"
+#include "output/OutputPlugin.hxx"
+#include "config/ConfigData.hxx"
+#include "config/ConfigGlobal.hxx"
+#include "config/ConfigOption.hxx"
#include "Idle.hxx"
#include "Main.hxx"
#include "event/Loop.hxx"
-#include "GlobalEvents.hxx"
#include "IOThread.hxx"
#include "fs/Path.hxx"
#include "AudioParser.hxx"
#include "pcm/PcmConvert.hxx"
-#include "FilterRegistry.hxx"
+#include "filter/FilterRegistry.hxx"
#include "PlayerControl.hxx"
#include "stdbin.h"
#include "util/Error.hxx"
+#include "Log.hxx"
+#ifdef HAVE_GLIB
#include <glib.h>
+#endif
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
-
-EventLoop *main_loop;
-
-void
-GlobalEvents::Emit(gcc_unused Event event)
-{
-}
+#include <stdio.h>
const struct filter_plugin *
filter_plugin_by_name(gcc_unused const char *name)
@@ -58,68 +53,61 @@ filter_plugin_by_name(gcc_unused const char *name)
return NULL;
}
-static const struct config_param *
-find_named_config_block(ConfigOption option, const char *name)
-{
- const struct config_param *param = NULL;
-
- while ((param = config_get_next_param(option, param)) != NULL) {
- const char *current_name = param->GetBlockValue("name");
- if (current_name != NULL && strcmp(current_name, name) == 0)
- return param;
- }
-
- return NULL;
-}
-
-PlayerControl::PlayerControl(gcc_unused unsigned _buffer_chunks,
- gcc_unused unsigned _buffered_before_play) {}
+PlayerControl::PlayerControl(PlayerListener &_listener,
+ MultipleOutputs &_outputs,
+ unsigned _buffer_chunks,
+ unsigned _buffered_before_play)
+ :listener(_listener), outputs(_outputs),
+ buffer_chunks(_buffer_chunks),
+ buffered_before_play(_buffered_before_play) {}
PlayerControl::~PlayerControl() {}
-static struct audio_output *
-load_audio_output(const char *name)
+static AudioOutput *
+load_audio_output(EventLoop &event_loop, const char *name)
{
- const struct config_param *param;
-
- param = find_named_config_block(CONF_AUDIO_OUTPUT, name);
+ const config_param *param =
+ config_find_block(CONF_AUDIO_OUTPUT, "name", name);
if (param == NULL) {
- g_printerr("No such configured audio output: %s\n", name);
+ fprintf(stderr, "No such configured audio output: %s\n", name);
return nullptr;
}
- static struct PlayerControl dummy_player_control(32, 4);
+ static struct PlayerControl dummy_player_control(*(PlayerListener *)nullptr,
+ *(MultipleOutputs *)nullptr,
+ 32, 4);
Error error;
- struct audio_output *ao =
- audio_output_new(*param, dummy_player_control, error);
+ AudioOutput *ao =
+ audio_output_new(event_loop, *param,
+ *(MixerListener *)nullptr,
+ dummy_player_control,
+ error);
if (ao == nullptr)
- g_printerr("%s\n", error.GetMessage());
+ LogError(error);
return ao;
}
static bool
-run_output(struct audio_output *ao, AudioFormat audio_format)
+run_output(AudioOutput *ao, AudioFormat audio_format)
{
/* open the audio output */
Error error;
if (!ao_plugin_enable(ao, error)) {
- g_printerr("Failed to enable audio output: %s\n",
- error.GetMessage());
+ LogError(error, "Failed to enable audio output");
return false;
}
if (!ao_plugin_open(ao, audio_format, error)) {
ao_plugin_disable(ao);
- g_printerr("Failed to open audio output: %s\n",
- error.GetMessage());
+ LogError(error, "Failed to open audio output");
return false;
}
struct audio_format_string af_string;
- g_printerr("audio_format=%s\n",
- audio_format_to_string(audio_format, &af_string));
+ fprintf(stderr, "audio_format=%s\n",
+ audio_format_to_string(audio_format, &af_string));
size_t frame_size = audio_format.GetFrameSize();
@@ -145,8 +133,7 @@ run_output(struct audio_output *ao, AudioFormat audio_format)
if (consumed == 0) {
ao_plugin_close(ao);
ao_plugin_disable(ao);
- g_printerr("Failed to play: %s\n",
- error.GetMessage());
+ LogError(error, "Failed to play");
return false;
}
@@ -168,34 +155,36 @@ int main(int argc, char **argv)
Error error;
if (argc < 3 || argc > 4) {
- g_printerr("Usage: run_output CONFIG NAME [FORMAT] <IN\n");
- return 1;
+ fprintf(stderr, "Usage: run_output CONFIG NAME [FORMAT] <IN\n");
+ return EXIT_FAILURE;
}
const Path config_path = Path::FromFS(argv[1]);
AudioFormat audio_format(44100, SampleFormat::S16, 2);
+#ifdef HAVE_GLIB
#if !GLIB_CHECK_VERSION(2,32,0)
g_thread_init(NULL);
#endif
+#endif
/* read configuration file (mpd.conf) */
config_global_init();
if (!ReadConfigFile(config_path, error)) {
- g_printerr("%s\n", error.GetMessage());
- return 1;
+ LogError(error);
+ return EXIT_FAILURE;
}
- main_loop = new EventLoop(EventLoop::Default());
+ EventLoop event_loop;
io_thread_init();
io_thread_start();
/* initialize the audio output */
- struct audio_output *ao = load_audio_output(argv[2]);
+ AudioOutput *ao = load_audio_output(event_loop, argv[2]);
if (ao == NULL)
return 1;
@@ -203,9 +192,8 @@ int main(int argc, char **argv)
if (argc > 3) {
if (!audio_format_parse(audio_format, argv[3], false, error)) {
- g_printerr("Failed to parse audio format: %s\n",
- error.GetMessage());
- return 1;
+ LogError(error, "Failed to parse audio format");
+ return EXIT_FAILURE;
}
}
@@ -219,8 +207,6 @@ int main(int argc, char **argv)
io_thread_deinit();
- delete main_loop;
-
config_global_finish();
return success ? EXIT_SUCCESS : EXIT_FAILURE;