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 { class AudioOutput {
const unsigned flags; const unsigned flags;
bool need_fully_defined_audio_format = false;
protected: protected:
static constexpr unsigned FLAG_ENABLE_DISABLE = 0x1; static constexpr unsigned FLAG_ENABLE_DISABLE = 0x1;
static constexpr unsigned FLAG_PAUSE = 0x2; 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: public:
explicit AudioOutput(unsigned _flags):flags(_flags) {} explicit AudioOutput(unsigned _flags):flags(_flags) {}
virtual ~AudioOutput() = default; virtual ~AudioOutput() = default;
@ -50,16 +54,7 @@ public:
} }
bool GetNeedFullyDefinedAudioFormat() const { bool GetNeedFullyDefinedAudioFormat() const {
return need_fully_defined_audio_format; return flags & FLAG_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;
} }
/** /**

View File

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