AudioOutput: pass plugin to constructor
Make it "const".
This commit is contained in:
parent
8a8d023f90
commit
bf803e241f
@ -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 ¶m, 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);
|
||||
|
@ -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 ¶m,
|
||||
|
||||
bool
|
||||
ao_base_init(AudioOutput *ao,
|
||||
const AudioOutputPlugin *plugin,
|
||||
const config_param ¶m, Error &error);
|
||||
|
||||
void
|
||||
|
@ -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 ¶m, Error &error) {
|
||||
return ao_base_init(&base, &alsa_output_plugin,
|
||||
param, error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,9 +42,11 @@ struct AoOutput {
|
||||
ao_option *options;
|
||||
ao_device *device;
|
||||
|
||||
AoOutput()
|
||||
:base(ao_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return ao_base_init(&base, &ao_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
@ -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 ¶m, Error &error) {
|
||||
return ao_base_init(&base, &fifo_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
bool Create(Error &error);
|
||||
|
@ -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 ¶m, Error &error)
|
||||
inline bool
|
||||
HttpdOutput::Init(const config_param ¶m, Error &error)
|
||||
{
|
||||
return ao_base_init(&base, &httpd_output_plugin, param, error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
|
@ -79,9 +79,11 @@ struct JackOutput {
|
||||
*/
|
||||
bool pause;
|
||||
|
||||
JackOutput()
|
||||
:base(jack_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return ao_base_init(&base, &jack_output_plugin, param,
|
||||
error_r);
|
||||
return ao_base_init(&base, param, error_r);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -29,9 +29,11 @@ struct NullOutput {
|
||||
|
||||
Timer *timer;
|
||||
|
||||
NullOutput()
|
||||
:base(null_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return ao_base_init(&base, &null_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 ¶m, 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;
|
||||
}
|
||||
|
@ -48,9 +48,11 @@ struct OpenALOutput {
|
||||
ALenum format;
|
||||
ALuint frequency;
|
||||
|
||||
OpenALOutput()
|
||||
:base(openal_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return ao_base_init(&base, &openal_output_plugin, param,
|
||||
error_r);
|
||||
return ao_base_init(&base, param, error_r);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 ¶m, Error &error_r) {
|
||||
return ao_base_init(&base, &oss_output_plugin, param,
|
||||
error_r);
|
||||
return ao_base_init(&base, param, error_r);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -34,9 +34,11 @@ struct PipeOutput {
|
||||
std::string cmd;
|
||||
FILE *fh;
|
||||
|
||||
PipeOutput()
|
||||
:base(pipe_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return ao_base_init(&base, &pipe_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
@ -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 ¶m, 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;
|
||||
}
|
||||
|
@ -57,9 +57,11 @@ struct RecorderOutput {
|
||||
*/
|
||||
char buffer[32768];
|
||||
|
||||
RecorderOutput()
|
||||
:base(recorder_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, 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 ¶m, Error &error);
|
||||
|
@ -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 ¶m, Error &error) {
|
||||
return ao_base_init(&base, &roar_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
void Configure(const config_param ¶m);
|
||||
|
@ -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 ¶m, Error &error) {
|
||||
return ao_base_init(&base, &shout_output_plugin, param,
|
||||
error);
|
||||
return ao_base_init(&base, param, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
@ -57,9 +57,11 @@ struct SolarisOutput {
|
||||
|
||||
int fd;
|
||||
|
||||
SolarisOutput()
|
||||
:base(solaris_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return ao_base_init(&base, &solaris_output_plugin, param,
|
||||
error_r);
|
||||
return ao_base_init(&base, param, error_r);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 ¶m, 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user