output/Interface: convert need_fully_defined_audio_format to flag

This commit is contained in:
Max Kellermann 2017-12-19 08:40:54 +01:00
parent 093ca5d492
commit 37c27fa606
2 changed files with 8 additions and 15 deletions

View File

@ -28,12 +28,16 @@ struct Tag;
class AudioOutput {
const unsigned flags;
bool need_fully_defined_audio_format = false;
protected:
static constexpr unsigned FLAG_ENABLE_DISABLE = 0x1;
static constexpr unsigned FLAG_PAUSE = 0x2;
/**
* This output requires an "audio_format" setting which
* evaluates AudioFormat::IsFullyDefined().
*/
static constexpr unsigned FLAG_NEED_FULLY_DEFINED_AUDIO_FORMAT = 0x4;
public:
explicit AudioOutput(unsigned _flags):flags(_flags) {}
virtual ~AudioOutput() = default;
@ -50,16 +54,7 @@ public:
}
bool GetNeedFullyDefinedAudioFormat() const {
return need_fully_defined_audio_format;
}
/**
* Plugins shall call this method if they require an
* "audio_format" setting which evaluates
* AudioFormat::IsFullyDefined().
*/
void NeedFullyDefinedAudioFormat() {
need_fully_defined_audio_format = true;
return flags & FLAG_NEED_FULLY_DEFINED_AUDIO_FORMAT;
}
/**

View File

@ -97,12 +97,10 @@ ShoutSetAudioInfo(shout_t *shout_conn, const AudioFormat &audio_format)
}
ShoutOutput::ShoutOutput(const ConfigBlock &block)
:AudioOutput(FLAG_PAUSE),
:AudioOutput(FLAG_PAUSE|FLAG_NEED_FULLY_DEFINED_AUDIO_FORMAT),
shout_conn(shout_new()),
prepared_encoder(CreateConfiguredEncoder(block, true))
{
NeedFullyDefinedAudioFormat();
const char *host = require_block_string(block, "host");
const char *mount = require_block_string(block, "mount");
unsigned port = block.GetBlockValue("port", 0u);