output/Init: convert audio_output_setup() to method
This commit is contained in:
parent
a0393e9ddf
commit
982d1bf662
@ -204,10 +204,9 @@ AudioOutput::Configure(const ConfigBlock &block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
inline void
|
||||||
audio_output_setup(EventLoop &event_loop,
|
AudioOutput::Setup(EventLoop &event_loop,
|
||||||
const ReplayGainConfig &replay_gain_config,
|
const ReplayGainConfig &replay_gain_config,
|
||||||
AudioOutput &ao,
|
|
||||||
MixerListener &mixer_listener,
|
MixerListener &mixer_listener,
|
||||||
const ConfigBlock &block)
|
const ConfigBlock &block)
|
||||||
{
|
{
|
||||||
@ -218,42 +217,42 @@ audio_output_setup(EventLoop &event_loop,
|
|||||||
block.GetBlockValue("replay_gain_handler", "software");
|
block.GetBlockValue("replay_gain_handler", "software");
|
||||||
|
|
||||||
if (strcmp(replay_gain_handler, "none") != 0) {
|
if (strcmp(replay_gain_handler, "none") != 0) {
|
||||||
ao.prepared_replay_gain_filter =
|
prepared_replay_gain_filter =
|
||||||
NewReplayGainFilter(replay_gain_config);
|
NewReplayGainFilter(replay_gain_config);
|
||||||
assert(ao.prepared_replay_gain_filter != nullptr);
|
assert(prepared_replay_gain_filter != nullptr);
|
||||||
|
|
||||||
ao.prepared_other_replay_gain_filter =
|
prepared_other_replay_gain_filter =
|
||||||
NewReplayGainFilter(replay_gain_config);
|
NewReplayGainFilter(replay_gain_config);
|
||||||
assert(ao.prepared_other_replay_gain_filter != nullptr);
|
assert(prepared_other_replay_gain_filter != nullptr);
|
||||||
} else {
|
} else {
|
||||||
ao.prepared_replay_gain_filter = nullptr;
|
prepared_replay_gain_filter = nullptr;
|
||||||
ao.prepared_other_replay_gain_filter = nullptr;
|
prepared_other_replay_gain_filter = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up the mixer */
|
/* set up the mixer */
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ao.mixer = audio_output_load_mixer(event_loop, ao, block,
|
mixer = audio_output_load_mixer(event_loop, *this, block,
|
||||||
ao.plugin.mixer_plugin,
|
plugin.mixer_plugin,
|
||||||
*ao.prepared_filter,
|
*prepared_filter,
|
||||||
mixer_listener);
|
mixer_listener);
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
FormatError(e,
|
FormatError(e,
|
||||||
"Failed to initialize hardware mixer for '%s'",
|
"Failed to initialize hardware mixer for '%s'",
|
||||||
ao.name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use the hardware mixer for replay gain? */
|
/* use the hardware mixer for replay gain? */
|
||||||
|
|
||||||
if (strcmp(replay_gain_handler, "mixer") == 0) {
|
if (strcmp(replay_gain_handler, "mixer") == 0) {
|
||||||
if (ao.mixer != nullptr)
|
if (mixer != nullptr)
|
||||||
replay_gain_filter_set_mixer(*ao.prepared_replay_gain_filter,
|
replay_gain_filter_set_mixer(*prepared_replay_gain_filter,
|
||||||
ao.mixer, 100);
|
mixer, 100);
|
||||||
else
|
else
|
||||||
FormatError(output_domain,
|
FormatError(output_domain,
|
||||||
"No such mixer for output '%s'", ao.name);
|
"No such mixer for output '%s'", name);
|
||||||
} else if (strcmp(replay_gain_handler, "software") != 0 &&
|
} else if (strcmp(replay_gain_handler, "software") != 0 &&
|
||||||
ao.prepared_replay_gain_filter != nullptr) {
|
prepared_replay_gain_filter != nullptr) {
|
||||||
throw std::runtime_error("Invalid \"replay_gain_handler\" value");
|
throw std::runtime_error("Invalid \"replay_gain_handler\" value");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,8 +261,8 @@ audio_output_setup(EventLoop &event_loop,
|
|||||||
auto *f = filter_new(&convert_filter_plugin, ConfigBlock());
|
auto *f = filter_new(&convert_filter_plugin, ConfigBlock());
|
||||||
assert(f != nullptr);
|
assert(f != nullptr);
|
||||||
|
|
||||||
filter_chain_append(*ao.prepared_filter, "convert",
|
filter_chain_append(*prepared_filter, "convert",
|
||||||
ao.convert_filter.Set(f));
|
convert_filter.Set(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioOutput *
|
AudioOutput *
|
||||||
@ -300,8 +299,8 @@ audio_output_new(EventLoop &event_loop,
|
|||||||
assert(ao != nullptr);
|
assert(ao != nullptr);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
audio_output_setup(event_loop, replay_gain_config,
|
ao->Setup(event_loop, replay_gain_config,
|
||||||
*ao, mixer_listener, block);
|
mixer_listener, block);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
ao_plugin_finish(ao);
|
ao_plugin_finish(ao);
|
||||||
throw;
|
throw;
|
||||||
|
@ -277,6 +277,11 @@ private:
|
|||||||
void Configure(const ConfigBlock &block);
|
void Configure(const ConfigBlock &block);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void Setup(EventLoop &event_loop,
|
||||||
|
const ReplayGainConfig &replay_gain_config,
|
||||||
|
MixerListener &mixer_listener,
|
||||||
|
const ConfigBlock &block);
|
||||||
|
|
||||||
void StartThread();
|
void StartThread();
|
||||||
void StopThread();
|
void StopThread();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user