summaryrefslogtreecommitdiff
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-05 23:20:33 +0100
committerMax Kellermann <max@duempel.org>2014-02-19 21:40:14 +0100
commit8d6fedf8177d0d2ced81e6d93d35c368b2ac69db (patch)
tree17890432eb5d7f6cbdf5feb32a0105dc6f9d8974 /src/output
parentf4f8fa7c947af10235d1cdd70b294a3b8810c6f4 (diff)
Mixer: add class MixerListener
Use a listener interface instead of GlobalEvents.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/Init.cxx14
-rw-r--r--src/output/Internal.hxx5
-rw-r--r--src/output/MultipleOutputs.cxx18
-rw-r--r--src/output/MultipleOutputs.hxx5
4 files changed, 31 insertions, 11 deletions
diff --git a/src/output/Init.cxx b/src/output/Init.cxx
index 69ee12b35..eafcec432 100644
--- a/src/output/Init.cxx
+++ b/src/output/Init.cxx
@@ -116,6 +116,7 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
const config_param &param,
const MixerPlugin *plugin,
Filter &filter_chain,
+ MixerListener &listener,
Error &error)
{
Mixer *mixer;
@@ -129,10 +130,12 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
if (plugin == nullptr)
return nullptr;
- return mixer_new(event_loop, *plugin, ao, param, error);
+ return mixer_new(event_loop, *plugin, ao, listener,
+ param, error);
case MIXER_TYPE_SOFTWARE:
mixer = mixer_new(event_loop, software_mixer_plugin, ao,
+ listener,
config_param(),
IgnoreError());
assert(mixer != nullptr);
@@ -212,6 +215,7 @@ AudioOutput::Configure(const config_param &param, Error &error)
static bool
audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
+ MixerListener &mixer_listener,
const config_param &param,
Error &error)
{
@@ -244,7 +248,9 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
Error mixer_error;
ao.mixer = audio_output_load_mixer(event_loop, ao, param,
ao.plugin.mixer_plugin,
- *ao.filter, mixer_error);
+ *ao.filter,
+ mixer_listener,
+ mixer_error);
if (ao.mixer == nullptr && mixer_error.IsDefined())
FormatError(mixer_error,
"Failed to initialize hardware mixer for '%s'",
@@ -279,6 +285,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
AudioOutput *
audio_output_new(EventLoop &event_loop, const config_param &param,
+ MixerListener &mixer_listener,
PlayerControl &pc,
Error &error)
{
@@ -317,7 +324,8 @@ audio_output_new(EventLoop &event_loop, const config_param &param,
if (ao == nullptr)
return nullptr;
- if (!audio_output_setup(event_loop, *ao, param, error)) {
+ if (!audio_output_setup(event_loop, *ao, mixer_listener,
+ param, error)) {
ao_plugin_finish(ao);
return nullptr;
}
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index 9b08a9228..266930448 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -33,6 +33,8 @@ class Error;
class Filter;
class MusicPipe;
class EventLoop;
+class Mixer;
+class MixerListener;
struct music_chunk;
struct config_param;
struct PlayerControl;
@@ -79,7 +81,7 @@ struct AudioOutput {
* May be nullptr if none is available, or if software volume is
* configured.
*/
- class Mixer *mixer;
+ Mixer *mixer;
/**
* Will this output receive tags from the decoder? The
@@ -424,6 +426,7 @@ extern struct notify audio_output_client_notify;
AudioOutput *
audio_output_new(EventLoop &event_loop, const config_param &param,
+ MixerListener &mixer_listener,
PlayerControl &pc,
Error &error);
diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx
index a65fb73c0..10e3e3bd5 100644
--- a/src/output/MultipleOutputs.cxx
+++ b/src/output/MultipleOutputs.cxx
@@ -35,8 +35,9 @@
#include <assert.h>
#include <string.h>
-MultipleOutputs::MultipleOutputs()
- :buffer(nullptr), pipe(nullptr),
+MultipleOutputs::MultipleOutputs(MixerListener &_mixer_listener)
+ :mixer_listener(_mixer_listener),
+ buffer(nullptr), pipe(nullptr),
elapsed_time(-1)
{
}
@@ -50,10 +51,13 @@ MultipleOutputs::~MultipleOutputs()
}
static AudioOutput *
-LoadOutput(EventLoop &event_loop, PlayerControl &pc, const config_param &param)
+LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
+ PlayerControl &pc, const config_param &param)
{
Error error;
- AudioOutput *output = audio_output_new(event_loop, param, pc, error);
+ AudioOutput *output = audio_output_new(event_loop, param,
+ mixer_listener,
+ pc, error);
if (output == nullptr) {
if (param.line > 0)
FormatFatalError("line %i: %s",
@@ -72,7 +76,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
const config_param *param = nullptr;
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT,
param)) != nullptr) {
- auto output = LoadOutput(event_loop, pc, *param);
+ auto output = LoadOutput(event_loop, mixer_listener,
+ pc, *param);
if (FindByName(output->name) != nullptr)
FormatFatalError("output devices with identical "
"names: %s", output->name);
@@ -83,7 +88,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
if (outputs.empty()) {
/* auto-detect device */
const config_param empty;
- auto output = LoadOutput(event_loop, pc, empty);
+ auto output = LoadOutput(event_loop, mixer_listener,
+ pc, empty);
outputs.push_back(output);
}
}
diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx
index 4fe1aa4f1..296b9815e 100644
--- a/src/output/MultipleOutputs.hxx
+++ b/src/output/MultipleOutputs.hxx
@@ -38,12 +38,15 @@ struct AudioFormat;
class MusicBuffer;
class MusicPipe;
class EventLoop;
+class MixerListener;
struct music_chunk;
struct PlayerControl;
struct AudioOutput;
class Error;
class MultipleOutputs {
+ MixerListener &mixer_listener;
+
std::vector<AudioOutput *> outputs;
AudioFormat input_audio_format;
@@ -70,7 +73,7 @@ public:
* Load audio outputs from the configuration file and
* initialize them.
*/
- MultipleOutputs();
+ MultipleOutputs(MixerListener &_mixer_listener);
~MultipleOutputs();
void Configure(EventLoop &event_loop, PlayerControl &pc);