diff options
author | Max Kellermann <max@musicpd.org> | 2017-08-08 18:27:07 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-08-08 18:57:59 +0200 |
commit | e11229494ed03e48af20ef9bdffcd0e8798a689a (patch) | |
tree | 0f6beeb5e81c096ebd6f5ef4d1668f361530fb2e /src | |
parent | ccc0fcb5b79349456b702663cc674069c826b6ce (diff) |
output/Filtered: add method NeedFullyDefinedAudioFormat()
Avoid accessing FilteredAudioFormat attributes directly.
Diffstat (limited to 'src')
-rw-r--r-- | src/output/Filtered.hxx | 7 | ||||
-rw-r--r-- | src/output/Init.cxx | 7 | ||||
-rw-r--r-- | 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"); |