output/Filtered: add method NeedFullyDefinedAudioFormat()

Avoid accessing FilteredAudioFormat attributes directly.
This commit is contained in:
Max Kellermann 2017-08-08 18:27:07 +02:00
parent ccc0fcb5b7
commit e11229494e
3 changed files with 15 additions and 3 deletions

View File

@ -125,6 +125,13 @@ public:
~FilteredAudioOutput(); ~FilteredAudioOutput();
/**
* Plugins shall call this method if they require an
* "audio_format" setting which evaluates
* AudioFormat::IsFullyDefined().
*/
void NeedFullyDefinedAudioFormat();
private: private:
void Configure(const ConfigBlock &block); void Configure(const ConfigBlock &block);

View File

@ -62,6 +62,13 @@ FilteredAudioOutput::FilteredAudioOutput(const AudioOutputPlugin &_plugin,
Configure(block); Configure(block);
} }
void
FilteredAudioOutput::NeedFullyDefinedAudioFormat()
{
if (!config_audio_format.IsFullyDefined())
throw std::runtime_error("Need full audio format specification");
}
static const AudioOutputPlugin * static const AudioOutputPlugin *
audio_output_detect() audio_output_detect()
{ {

View File

@ -117,9 +117,7 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
shout_conn(shout_new()), shout_conn(shout_new()),
shout_meta(shout_metadata_new()) shout_meta(shout_metadata_new())
{ {
const AudioFormat audio_format = base.config_audio_format; base.NeedFullyDefinedAudioFormat();
if (!audio_format.IsFullyDefined())
throw std::runtime_error("Need full audio format specification");
const char *host = require_block_string(block, "host"); const char *host = require_block_string(block, "host");
const char *mount = require_block_string(block, "mount"); const char *mount = require_block_string(block, "mount");