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_OUTPUT_FORMAT "format"
|
||||||
#define AUDIO_FILTERS "filters"
|
#define AUDIO_FILTERS "filters"
|
||||||
|
|
||||||
AudioOutput::AudioOutput()
|
AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
|
||||||
:enabled(true), really_enabled(false),
|
:plugin(&_plugin),
|
||||||
|
enabled(true), really_enabled(false),
|
||||||
open(false),
|
open(false),
|
||||||
pause(false),
|
pause(false),
|
||||||
allow_play(true),
|
allow_play(true),
|
||||||
@ -58,6 +59,10 @@ AudioOutput::AudioOutput()
|
|||||||
other_replay_gain_filter(nullptr),
|
other_replay_gain_filter(nullptr),
|
||||||
command(AO_COMMAND_NONE)
|
command(AO_COMMAND_NONE)
|
||||||
{
|
{
|
||||||
|
assert(plugin->finish != nullptr);
|
||||||
|
assert(plugin->open != nullptr);
|
||||||
|
assert(plugin->close != nullptr);
|
||||||
|
assert(plugin->play != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AudioOutputPlugin *
|
static const AudioOutputPlugin *
|
||||||
@ -143,15 +148,9 @@ audio_output_load_mixer(AudioOutput *ao,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ao_base_init(AudioOutput *ao,
|
ao_base_init(AudioOutput *ao,
|
||||||
const AudioOutputPlugin *plugin,
|
|
||||||
const config_param ¶m, Error &error)
|
const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
assert(ao != nullptr);
|
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()) {
|
if (!param.IsNull()) {
|
||||||
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
||||||
@ -176,7 +175,6 @@ ao_base_init(AudioOutput *ao,
|
|||||||
ao->config_audio_format.Clear();
|
ao->config_audio_format.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ao->plugin = plugin;
|
|
||||||
ao->tags = param.GetBlockValue("tags", true);
|
ao->tags = param.GetBlockValue("tags", true);
|
||||||
ao->always_on = param.GetBlockValue("always_on", false);
|
ao->always_on = param.GetBlockValue("always_on", false);
|
||||||
ao->enabled = param.GetBlockValue("enabled", true);
|
ao->enabled = param.GetBlockValue("enabled", true);
|
||||||
|
@ -69,7 +69,7 @@ struct AudioOutput {
|
|||||||
/**
|
/**
|
||||||
* The plugin which implements this output device.
|
* The plugin which implements this output device.
|
||||||
*/
|
*/
|
||||||
const AudioOutputPlugin *plugin;
|
const AudioOutputPlugin *const plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The #mixer object associated with this audio output device.
|
* The #mixer object associated with this audio output device.
|
||||||
@ -264,7 +264,7 @@ struct AudioOutput {
|
|||||||
*/
|
*/
|
||||||
bool chunk_finished;
|
bool chunk_finished;
|
||||||
|
|
||||||
AudioOutput();
|
AudioOutput(const AudioOutputPlugin &_plugin);
|
||||||
~AudioOutput();
|
~AudioOutput();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -293,7 +293,6 @@ audio_output_new(const config_param ¶m,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ao_base_init(AudioOutput *ao,
|
ao_base_init(AudioOutput *ao,
|
||||||
const AudioOutputPlugin *plugin,
|
|
||||||
const config_param ¶m, Error &error);
|
const config_param ¶m, Error &error);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -119,12 +119,13 @@ struct AlsaOutput {
|
|||||||
*/
|
*/
|
||||||
uint8_t *silence;
|
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) {
|
bool Init(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &alsa_output_plugin,
|
return ao_base_init(&base, param, error);
|
||||||
param, error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,9 +42,11 @@ struct AoOutput {
|
|||||||
ao_option *options;
|
ao_option *options;
|
||||||
ao_device *device;
|
ao_device *device;
|
||||||
|
|
||||||
|
AoOutput()
|
||||||
|
:base(ao_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &ao_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param ¶m, Error &error);
|
bool Configure(const config_param ¶m, Error &error);
|
||||||
|
@ -47,12 +47,12 @@ struct FifoOutput {
|
|||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
FifoOutput()
|
FifoOutput()
|
||||||
:path(AllocatedPath::Null()), input(-1), output(-1),
|
:base(fifo_output_plugin),
|
||||||
|
path(AllocatedPath::Null()), input(-1), output(-1),
|
||||||
created(false) {}
|
created(false) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &fifo_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(Error &error);
|
bool Create(Error &error);
|
||||||
|
@ -51,6 +51,7 @@ const Domain httpd_output_domain("httpd_output");
|
|||||||
inline
|
inline
|
||||||
HttpdOutput::HttpdOutput(EventLoop &_loop)
|
HttpdOutput::HttpdOutput(EventLoop &_loop)
|
||||||
:ServerSocket(_loop), DeferredMonitor(_loop),
|
:ServerSocket(_loop), DeferredMonitor(_loop),
|
||||||
|
base(httpd_output_plugin),
|
||||||
encoder(nullptr), unflushed_input(0),
|
encoder(nullptr), unflushed_input(0),
|
||||||
metadata(nullptr)
|
metadata(nullptr)
|
||||||
{
|
{
|
||||||
@ -136,7 +137,7 @@ HttpdOutput::Configure(const config_param ¶m, Error &error)
|
|||||||
inline bool
|
inline bool
|
||||||
HttpdOutput::Init(const config_param ¶m, Error &error)
|
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 *
|
static AudioOutput *
|
||||||
|
@ -79,9 +79,11 @@ struct JackOutput {
|
|||||||
*/
|
*/
|
||||||
bool pause;
|
bool pause;
|
||||||
|
|
||||||
|
JackOutput()
|
||||||
|
:base(jack_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||||
return ao_base_init(&base, &jack_output_plugin, param,
|
return ao_base_init(&base, param, error_r);
|
||||||
error_r);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,9 +29,11 @@ struct NullOutput {
|
|||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
|
NullOutput()
|
||||||
|
:base(null_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &null_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +45,9 @@ struct OSXOutput {
|
|||||||
Cond condition;
|
Cond condition;
|
||||||
|
|
||||||
DynamicFifoBuffer<uint8_t> *buffer;
|
DynamicFifoBuffer<uint8_t> *buffer;
|
||||||
|
|
||||||
|
OSXOutput()
|
||||||
|
:base(osx_output_plugin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain osx_output_domain("osx_output");
|
static constexpr Domain osx_output_domain("osx_output");
|
||||||
@ -81,7 +84,7 @@ static AudioOutput *
|
|||||||
osx_output_init(const config_param ¶m, Error &error)
|
osx_output_init(const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
OSXOutput *oo = new OSXOutput();
|
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;
|
delete oo;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,11 @@ struct OpenALOutput {
|
|||||||
ALenum format;
|
ALenum format;
|
||||||
ALuint frequency;
|
ALuint frequency;
|
||||||
|
|
||||||
|
OpenALOutput()
|
||||||
|
:base(openal_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||||
return ao_base_init(&base, &openal_output_plugin, param,
|
return ao_base_init(&base, param, error_r);
|
||||||
error_r);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,11 +78,12 @@ struct OssOutput {
|
|||||||
*/
|
*/
|
||||||
int oss_format;
|
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) {
|
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||||
return ao_base_init(&base, &oss_output_plugin, param,
|
return ao_base_init(&base, param, error_r);
|
||||||
error_r);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,9 +34,11 @@ struct PipeOutput {
|
|||||||
std::string cmd;
|
std::string cmd;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
|
|
||||||
|
PipeOutput()
|
||||||
|
:base(pipe_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &pipe_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param ¶m, Error &error);
|
bool Configure(const config_param ¶m, Error &error);
|
||||||
|
@ -55,6 +55,9 @@ struct PulseOutput {
|
|||||||
struct pa_stream *stream;
|
struct pa_stream *stream;
|
||||||
|
|
||||||
size_t writable;
|
size_t writable;
|
||||||
|
|
||||||
|
PulseOutput()
|
||||||
|
:base(pulse_output_plugin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain pulse_output_domain("pulse_output");
|
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);
|
g_setenv("PULSE_PROP_media.role", "music", true);
|
||||||
|
|
||||||
po = new PulseOutput();
|
po = new PulseOutput();
|
||||||
if (!ao_base_init(&po->base, &pulse_output_plugin, param, error)) {
|
if (!ao_base_init(&po->base, param, error)) {
|
||||||
delete po;
|
delete po;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,11 @@ struct RecorderOutput {
|
|||||||
*/
|
*/
|
||||||
char buffer[32768];
|
char buffer[32768];
|
||||||
|
|
||||||
|
RecorderOutput()
|
||||||
|
:base(recorder_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||||
return ao_base_init(&base, &recorder_output_plugin, param,
|
return ao_base_init(&base, param, error_r);
|
||||||
error_r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param ¶m, Error &error);
|
bool Configure(const config_param ¶m, Error &error);
|
||||||
|
@ -50,15 +50,15 @@ class RoarOutput {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RoarOutput()
|
RoarOutput()
|
||||||
:err(ROAR_ERROR_NONE) {}
|
:base(roar_output_plugin),
|
||||||
|
err(ROAR_ERROR_NONE) {}
|
||||||
|
|
||||||
operator AudioOutput *() {
|
operator AudioOutput *() {
|
||||||
return &base;
|
return &base;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &roar_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configure(const config_param ¶m);
|
void Configure(const config_param ¶m);
|
||||||
|
@ -54,7 +54,8 @@ struct ShoutOutput final {
|
|||||||
uint8_t buffer[32768];
|
uint8_t buffer[32768];
|
||||||
|
|
||||||
ShoutOutput()
|
ShoutOutput()
|
||||||
:shout_conn(shout_new()),
|
:base(shout_output_plugin),
|
||||||
|
shout_conn(shout_new()),
|
||||||
shout_meta(shout_metadata_new()),
|
shout_meta(shout_metadata_new()),
|
||||||
quality(-2.0),
|
quality(-2.0),
|
||||||
bitrate(-1),
|
bitrate(-1),
|
||||||
@ -68,8 +69,7 @@ struct ShoutOutput final {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error) {
|
bool Initialize(const config_param ¶m, Error &error) {
|
||||||
return ao_base_init(&base, &shout_output_plugin, param,
|
return ao_base_init(&base, param, error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param ¶m, Error &error);
|
bool Configure(const config_param ¶m, Error &error);
|
||||||
|
@ -57,9 +57,11 @@ struct SolarisOutput {
|
|||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
SolarisOutput()
|
||||||
|
:base(solaris_output_plugin) {}
|
||||||
|
|
||||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||||
return ao_base_init(&base, &solaris_output_plugin, param,
|
return ao_base_init(&base, param, error_r);
|
||||||
error_r);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ struct WinmmOutput {
|
|||||||
|
|
||||||
WinmmBuffer buffers[8];
|
WinmmBuffer buffers[8];
|
||||||
unsigned next_buffer;
|
unsigned next_buffer;
|
||||||
|
|
||||||
|
WinmmBuffer()
|
||||||
|
:base(winmm_output_plugin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain winmm_output_domain("winmm_output");
|
static constexpr Domain winmm_output_domain("winmm_output");
|
||||||
@ -112,7 +115,7 @@ static AudioOutput *
|
|||||||
winmm_output_init(const config_param ¶m, Error &error)
|
winmm_output_init(const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
WinmmOutput *wo = new WinmmOutput();
|
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;
|
delete wo;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user