aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-28 23:39:48 +0100
committerMax Kellermann <max@duempel.org>2014-01-29 08:10:18 +0100
commitbf803e241f4f1210e7ed1e71895a561de81d7a94 (patch)
treed9894df2da6ad9478d5459f7a2af0974bf5a4979
parent8a8d023f90e057ae9b70377a132f4259b173d436 (diff)
downloadmpd-bf803e241f4f1210e7ed1e71895a561de81d7a94.tar.gz
mpd-bf803e241f4f1210e7ed1e71895a561de81d7a94.tar.xz
mpd-bf803e241f4f1210e7ed1e71895a561de81d7a94.zip
AudioOutput: pass plugin to constructor
Make it "const".
-rw-r--r--src/output/Init.cxx16
-rw-r--r--src/output/Internal.hxx5
-rw-r--r--src/output/plugins/AlsaOutputPlugin.cxx7
-rw-r--r--src/output/plugins/AoOutputPlugin.cxx6
-rw-r--r--src/output/plugins/FifoOutputPlugin.cxx6
-rw-r--r--src/output/plugins/HttpdOutputPlugin.cxx3
-rw-r--r--src/output/plugins/JackOutputPlugin.cxx6
-rw-r--r--src/output/plugins/NullOutputPlugin.cxx6
-rw-r--r--src/output/plugins/OSXOutputPlugin.cxx5
-rw-r--r--src/output/plugins/OpenALOutputPlugin.cxx6
-rw-r--r--src/output/plugins/OssOutputPlugin.cxx7
-rw-r--r--src/output/plugins/PipeOutputPlugin.cxx6
-rw-r--r--src/output/plugins/PulseOutputPlugin.cxx5
-rw-r--r--src/output/plugins/RecorderOutputPlugin.cxx6
-rw-r--r--src/output/plugins/RoarOutputPlugin.cxx6
-rw-r--r--src/output/plugins/ShoutOutputPlugin.cxx6
-rw-r--r--src/output/plugins/SolarisOutputPlugin.cxx6
-rw-r--r--src/output/plugins/WinmmOutputPlugin.cxx5
18 files changed, 68 insertions, 45 deletions
diff --git a/src/output/Init.cxx b/src/output/Init.cxx
index 52ff14b58..a4a22e33a 100644
--- a/src/output/Init.cxx
+++ b/src/output/Init.cxx
@@ -46,8 +46,9 @@
#define AUDIO_OUTPUT_FORMAT "format"
#define AUDIO_FILTERS "filters"
-AudioOutput::AudioOutput()
- :enabled(true), really_enabled(false),
+AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
+ :plugin(&_plugin),
+ enabled(true), really_enabled(false),
open(false),
pause(false),
allow_play(true),
@@ -58,6 +59,10 @@ AudioOutput::AudioOutput()
other_replay_gain_filter(nullptr),
command(AO_COMMAND_NONE)
{
+ assert(plugin->finish != nullptr);
+ assert(plugin->open != nullptr);
+ assert(plugin->close != nullptr);
+ assert(plugin->play != nullptr);
}
static const AudioOutputPlugin *
@@ -143,15 +148,9 @@ audio_output_load_mixer(AudioOutput *ao,
bool
ao_base_init(AudioOutput *ao,
- const AudioOutputPlugin *plugin,
const config_param &param, Error &error)
{
assert(ao != nullptr);
- assert(plugin != nullptr);
- assert(plugin->finish != nullptr);
- assert(plugin->open != nullptr);
- assert(plugin->close != nullptr);
- assert(plugin->play != nullptr);
if (!param.IsNull()) {
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
@@ -176,7 +175,6 @@ ao_base_init(AudioOutput *ao,
ao->config_audio_format.Clear();
}
- ao->plugin = plugin;
ao->tags = param.GetBlockValue("tags", true);
ao->always_on = param.GetBlockValue("always_on", false);
ao->enabled = param.GetBlockValue("enabled", true);
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index cb6904d68..a8a37358e 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -69,7 +69,7 @@ struct AudioOutput {
/**
* The plugin which implements this output device.
*/
- const AudioOutputPlugin *plugin;
+ const AudioOutputPlugin *const plugin;
/**
* The #mixer object associated with this audio output device.
@@ -264,7 +264,7 @@ struct AudioOutput {
*/
bool chunk_finished;
- AudioOutput();
+ AudioOutput(const AudioOutputPlugin &_plugin);
~AudioOutput();
};
@@ -293,7 +293,6 @@ audio_output_new(const config_param &param,
bool
ao_base_init(AudioOutput *ao,
- const AudioOutputPlugin *plugin,
const config_param &param, Error &error);
void
diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx
index 0c1bd37c3..7b4156803 100644
--- a/src/output/plugins/AlsaOutputPlugin.cxx
+++ b/src/output/plugins/AlsaOutputPlugin.cxx
@@ -119,12 +119,13 @@ struct AlsaOutput {
*/
uint8_t *silence;
- AlsaOutput():mode(0), writei(snd_pcm_writei) {
+ AlsaOutput()
+ :base(alsa_output_plugin),
+ mode(0), writei(snd_pcm_writei) {
}
bool Init(const config_param &param, Error &error) {
- return ao_base_init(&base, &alsa_output_plugin,
- param, error);
+ return ao_base_init(&base, param, error);
}
};
diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx
index 62902fd0c..d0020229f 100644
--- a/src/output/plugins/AoOutputPlugin.cxx
+++ b/src/output/plugins/AoOutputPlugin.cxx
@@ -42,9 +42,11 @@ struct AoOutput {
ao_option *options;
ao_device *device;
+ AoOutput()
+ :base(ao_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &ao_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
bool Configure(const config_param &param, Error &error);
diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx
index b4e649130..2c5151519 100644
--- a/src/output/plugins/FifoOutputPlugin.cxx
+++ b/src/output/plugins/FifoOutputPlugin.cxx
@@ -47,12 +47,12 @@ struct FifoOutput {
Timer *timer;
FifoOutput()
- :path(AllocatedPath::Null()), input(-1), output(-1),
+ :base(fifo_output_plugin),
+ path(AllocatedPath::Null()), input(-1), output(-1),
created(false) {}
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &fifo_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
bool Create(Error &error);
diff --git a/src/output/plugins/HttpdOutputPlugin.cxx b/src/output/plugins/HttpdOutputPlugin.cxx
index 30bf607d9..dc9e7e0b4 100644
--- a/src/output/plugins/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/HttpdOutputPlugin.cxx
@@ -51,6 +51,7 @@ const Domain httpd_output_domain("httpd_output");
inline
HttpdOutput::HttpdOutput(EventLoop &_loop)
:ServerSocket(_loop), DeferredMonitor(_loop),
+ base(httpd_output_plugin),
encoder(nullptr), unflushed_input(0),
metadata(nullptr)
{
@@ -136,7 +137,7 @@ HttpdOutput::Configure(const config_param &param, Error &error)
inline bool
HttpdOutput::Init(const config_param &param, Error &error)
{
- return ao_base_init(&base, &httpd_output_plugin, param, error);
+ return ao_base_init(&base, param, error);
}
static AudioOutput *
diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx
index c3a96741c..42179e813 100644
--- a/src/output/plugins/JackOutputPlugin.cxx
+++ b/src/output/plugins/JackOutputPlugin.cxx
@@ -79,9 +79,11 @@ struct JackOutput {
*/
bool pause;
+ JackOutput()
+ :base(jack_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error_r) {
- return ao_base_init(&base, &jack_output_plugin, param,
- error_r);
+ return ao_base_init(&base, param, error_r);
}
};
diff --git a/src/output/plugins/NullOutputPlugin.cxx b/src/output/plugins/NullOutputPlugin.cxx
index 7babce042..3c13e700d 100644
--- a/src/output/plugins/NullOutputPlugin.cxx
+++ b/src/output/plugins/NullOutputPlugin.cxx
@@ -29,9 +29,11 @@ struct NullOutput {
Timer *timer;
+ NullOutput()
+ :base(null_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &null_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
};
diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx
index 249f61144..6918b3378 100644
--- a/src/output/plugins/OSXOutputPlugin.cxx
+++ b/src/output/plugins/OSXOutputPlugin.cxx
@@ -45,6 +45,9 @@ struct OSXOutput {
Cond condition;
DynamicFifoBuffer<uint8_t> *buffer;
+
+ OSXOutput()
+ :base(osx_output_plugin) {}
};
static constexpr Domain osx_output_domain("osx_output");
@@ -81,7 +84,7 @@ static AudioOutput *
osx_output_init(const config_param &param, Error &error)
{
OSXOutput *oo = new OSXOutput();
- if (!ao_base_init(&oo->base, &osx_output_plugin, param, error)) {
+ if (!ao_base_init(&oo->base, param, error)) {
delete oo;
return NULL;
}
diff --git a/src/output/plugins/OpenALOutputPlugin.cxx b/src/output/plugins/OpenALOutputPlugin.cxx
index d40d0737e..b0f863374 100644
--- a/src/output/plugins/OpenALOutputPlugin.cxx
+++ b/src/output/plugins/OpenALOutputPlugin.cxx
@@ -48,9 +48,11 @@ struct OpenALOutput {
ALenum format;
ALuint frequency;
+ OpenALOutput()
+ :base(openal_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error_r) {
- return ao_base_init(&base, &openal_output_plugin, param,
- error_r);
+ return ao_base_init(&base, param, error_r);
}
};
diff --git a/src/output/plugins/OssOutputPlugin.cxx b/src/output/plugins/OssOutputPlugin.cxx
index 4924661bb..69018e723 100644
--- a/src/output/plugins/OssOutputPlugin.cxx
+++ b/src/output/plugins/OssOutputPlugin.cxx
@@ -78,11 +78,12 @@ struct OssOutput {
*/
int oss_format;
- OssOutput():fd(-1), device(nullptr) {}
+ OssOutput()
+ :base(oss_output_plugin),
+ fd(-1), device(nullptr) {}
bool Initialize(const config_param &param, Error &error_r) {
- return ao_base_init(&base, &oss_output_plugin, param,
- error_r);
+ return ao_base_init(&base, param, error_r);
}
};
diff --git a/src/output/plugins/PipeOutputPlugin.cxx b/src/output/plugins/PipeOutputPlugin.cxx
index 7bdc61051..36ad0aa48 100644
--- a/src/output/plugins/PipeOutputPlugin.cxx
+++ b/src/output/plugins/PipeOutputPlugin.cxx
@@ -34,9 +34,11 @@ struct PipeOutput {
std::string cmd;
FILE *fh;
+ PipeOutput()
+ :base(pipe_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &pipe_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
bool Configure(const config_param &param, Error &error);
diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx
index e83083372..dc1fc23b8 100644
--- a/src/output/plugins/PulseOutputPlugin.cxx
+++ b/src/output/plugins/PulseOutputPlugin.cxx
@@ -55,6 +55,9 @@ struct PulseOutput {
struct pa_stream *stream;
size_t writable;
+
+ PulseOutput()
+ :base(pulse_output_plugin) {}
};
static constexpr Domain pulse_output_domain("pulse_output");
@@ -331,7 +334,7 @@ pulse_output_init(const config_param &param, Error &error)
g_setenv("PULSE_PROP_media.role", "music", true);
po = new PulseOutput();
- if (!ao_base_init(&po->base, &pulse_output_plugin, param, error)) {
+ if (!ao_base_init(&po->base, param, error)) {
delete po;
return nullptr;
}
diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx
index ea208622a..0ef693d84 100644
--- a/src/output/plugins/RecorderOutputPlugin.cxx
+++ b/src/output/plugins/RecorderOutputPlugin.cxx
@@ -57,9 +57,11 @@ struct RecorderOutput {
*/
char buffer[32768];
+ RecorderOutput()
+ :base(recorder_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error_r) {
- return ao_base_init(&base, &recorder_output_plugin, param,
- error_r);
+ return ao_base_init(&base, param, error_r);
}
bool Configure(const config_param &param, Error &error);
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx
index 98cede62c..0fabecb31 100644
--- a/src/output/plugins/RoarOutputPlugin.cxx
+++ b/src/output/plugins/RoarOutputPlugin.cxx
@@ -50,15 +50,15 @@ class RoarOutput {
public:
RoarOutput()
- :err(ROAR_ERROR_NONE) {}
+ :base(roar_output_plugin),
+ err(ROAR_ERROR_NONE) {}
operator AudioOutput *() {
return &base;
}
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &roar_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
void Configure(const config_param &param);
diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx
index 1f60f72a1..91dfd2477 100644
--- a/src/output/plugins/ShoutOutputPlugin.cxx
+++ b/src/output/plugins/ShoutOutputPlugin.cxx
@@ -54,7 +54,8 @@ struct ShoutOutput final {
uint8_t buffer[32768];
ShoutOutput()
- :shout_conn(shout_new()),
+ :base(shout_output_plugin),
+ shout_conn(shout_new()),
shout_meta(shout_metadata_new()),
quality(-2.0),
bitrate(-1),
@@ -68,8 +69,7 @@ struct ShoutOutput final {
}
bool Initialize(const config_param &param, Error &error) {
- return ao_base_init(&base, &shout_output_plugin, param,
- error);
+ return ao_base_init(&base, param, error);
}
bool Configure(const config_param &param, Error &error);
diff --git a/src/output/plugins/SolarisOutputPlugin.cxx b/src/output/plugins/SolarisOutputPlugin.cxx
index 781aff2e3..a7cab2e1f 100644
--- a/src/output/plugins/SolarisOutputPlugin.cxx
+++ b/src/output/plugins/SolarisOutputPlugin.cxx
@@ -57,9 +57,11 @@ struct SolarisOutput {
int fd;
+ SolarisOutput()
+ :base(solaris_output_plugin) {}
+
bool Initialize(const config_param &param, Error &error_r) {
- return ao_base_init(&base, &solaris_output_plugin, param,
- error_r);
+ return ao_base_init(&base, param, error_r);
}
};
diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx
index 16ba7a4f7..b09d2e081 100644
--- a/src/output/plugins/WinmmOutputPlugin.cxx
+++ b/src/output/plugins/WinmmOutputPlugin.cxx
@@ -51,6 +51,9 @@ struct WinmmOutput {
WinmmBuffer buffers[8];
unsigned next_buffer;
+
+ WinmmBuffer()
+ :base(winmm_output_plugin) {}
};
static constexpr Domain winmm_output_domain("winmm_output");
@@ -112,7 +115,7 @@ static AudioOutput *
winmm_output_init(const config_param &param, Error &error)
{
WinmmOutput *wo = new WinmmOutput();
- if (!ao_base_init(&wo->base, &winmm_output_plugin, param, error)) {
+ if (!ao_base_init(&wo->base, param, error)) {
delete wo;
return nullptr;
}