Merge branch 'null-always-off' of https://github.com/nomis/MPD

This commit is contained in:
Max Kellermann 2023-05-25 10:42:08 +02:00
commit 45f81cde6d
5 changed files with 25 additions and 1 deletions

1
NEWS
View File

@ -33,6 +33,7 @@ ver 0.24 (not yet released)
* tags * tags
- new tags "TitleSort", "Mood" - new tags "TitleSort", "Mood"
* output * output
- add option "always_off"
- alsa: require alsa-lib 1.1 or later - alsa: require alsa-lib 1.1 or later
- pipewire: map tags "Date" and "Comment" - pipewire: map tags "Date" and "Comment"
* switch to C++20 * switch to C++20

View File

@ -517,6 +517,11 @@ The following table lists the audio_output options valid for all plugins:
- If set to no, then :program:`MPD` will not send tags to this output. This is only useful for output plugins that can receive tags, for example the httpd output plugin. - If set to no, then :program:`MPD` will not send tags to this output. This is only useful for output plugins that can receive tags, for example the httpd output plugin.
* - **always_on yes|no** * - **always_on yes|no**
- If set to yes, then :program:`MPD` attempts to keep this audio output always open. This may be useful for streaming servers, when you don't want to disconnect all listeners even when playback is accidentally stopped. - If set to yes, then :program:`MPD` attempts to keep this audio output always open. This may be useful for streaming servers, when you don't want to disconnect all listeners even when playback is accidentally stopped.
* - **always_off yes|no**
- If set to yes, then :program:`MPD` never uses this audio output for
playback even if it's enabled. This can be used with the null output
plugin to create placeholder outputs for other software to react to
the enabled state without affecting playback.
* - **mixer_type hardware|software|null|none** * - **mixer_type hardware|software|null|none**
- Specifies which mixer should be used for this audio output: the - Specifies which mixer should be used for this audio output: the
hardware mixer (available for ALSA :ref:`alsa_plugin`, OSS hardware mixer (available for ALSA :ref:`alsa_plugin`, OSS

View File

@ -25,6 +25,7 @@ AudioOutputControl::AudioOutputControl(std::unique_ptr<FilteredAudioOutput> _out
thread(BIND_THIS_METHOD(Task)), thread(BIND_THIS_METHOD(Task)),
tags(block.GetBlockValue("tags", true)), tags(block.GetBlockValue("tags", true)),
always_on(block.GetBlockValue("always_on", false)), always_on(block.GetBlockValue("always_on", false)),
always_off(block.GetBlockValue("always_off", false)),
enabled(block.GetBlockValue("enabled", true)) enabled(block.GetBlockValue("enabled", true))
{ {
} }
@ -36,7 +37,8 @@ AudioOutputControl::AudioOutputControl(AudioOutputControl &&src,
client(_client), client(_client),
thread(BIND_THIS_METHOD(Task)), thread(BIND_THIS_METHOD(Task)),
tags(src.tags), tags(src.tags),
always_on(src.always_on) always_on(src.always_on),
always_off(src.always_off)
{ {
} }
@ -176,6 +178,9 @@ AudioOutputControl::EnableAsync()
if (!output) if (!output)
return; return;
if (always_off)
return;
if (!thread.IsDefined()) { if (!thread.IsDefined()) {
if (!output->SupportsEnableDisable()) { if (!output->SupportsEnableDisable()) {
/* don't bother to start the thread now if the /* don't bother to start the thread now if the

View File

@ -143,6 +143,11 @@ class AudioOutputControl {
*/ */
const bool always_on; const bool always_on;
/**
* Should this output never play anything, even when enabled?
*/
const bool always_off;
/** /**
* Has the user enabled this device? * Has the user enabled this device?
*/ */
@ -274,6 +279,10 @@ public:
return !output; return !output;
} }
bool AlwaysOff() const noexcept {
return always_off;
}
/** /**
* Caller must lock the mutex. * Caller must lock the mutex.
*/ */

View File

@ -215,6 +215,10 @@ MultipleOutputs::Open(const AudioFormat audio_format)
for (const auto &ao : outputs) { for (const auto &ao : outputs) {
const std::scoped_lock<Mutex> lock(ao->mutex); const std::scoped_lock<Mutex> lock(ao->mutex);
/* can't play on this device even if it's enabled */
if (ao->AlwaysOff())
continue;
if (ao->IsEnabled()) if (ao->IsEnabled())
enabled = true; enabled = true;