From e11229494ed03e48af20ef9bdffcd0e8798a689a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 8 Aug 2017 18:27:07 +0200 Subject: [PATCH] output/Filtered: add method NeedFullyDefinedAudioFormat() Avoid accessing FilteredAudioFormat attributes directly. --- src/output/Filtered.hxx | 7 +++++++ src/output/Init.cxx | 7 +++++++ src/output/plugins/ShoutOutputPlugin.cxx | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/output/Filtered.hxx b/src/output/Filtered.hxx index 901bcd68a..ed1f6ccb7 100644 --- a/src/output/Filtered.hxx +++ b/src/output/Filtered.hxx @@ -125,6 +125,13 @@ public: ~FilteredAudioOutput(); + /** + * Plugins shall call this method if they require an + * "audio_format" setting which evaluates + * AudioFormat::IsFullyDefined(). + */ + void NeedFullyDefinedAudioFormat(); + private: void Configure(const ConfigBlock &block); diff --git a/src/output/Init.cxx b/src/output/Init.cxx index b33d3914c..3d042ae9c 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -62,6 +62,13 @@ FilteredAudioOutput::FilteredAudioOutput(const AudioOutputPlugin &_plugin, Configure(block); } +void +FilteredAudioOutput::NeedFullyDefinedAudioFormat() +{ + if (!config_audio_format.IsFullyDefined()) + throw std::runtime_error("Need full audio format specification"); +} + static const AudioOutputPlugin * audio_output_detect() { diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 4b99662e4..de8722982 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -117,9 +117,7 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block) shout_conn(shout_new()), shout_meta(shout_metadata_new()) { - const AudioFormat audio_format = base.config_audio_format; - if (!audio_format.IsFullyDefined()) - throw std::runtime_error("Need full audio format specification"); + base.NeedFullyDefinedAudioFormat(); const char *host = require_block_string(block, "host"); const char *mount = require_block_string(block, "mount");