output/Interface: add "attributes" map
These attributes are printed in the "outputs" response, and the new command "outputset" allows setting new values. No attributes are currently implemented.
This commit is contained in:
@@ -76,6 +76,18 @@ AudioOutputControl::GetMixer() const noexcept
|
||||
return output->mixer;
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string>
|
||||
AudioOutputControl::GetAttributes() const noexcept
|
||||
{
|
||||
return output->GetAttributes();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::SetAttribute(std::string &&name, std::string &&value)
|
||||
{
|
||||
output->SetAttribute(std::move(name), std::move(value));
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
||||
{
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <assert.h>
|
||||
@@ -324,6 +326,9 @@ public:
|
||||
void BeginDestroy() noexcept;
|
||||
void FinishDestroy() noexcept;
|
||||
|
||||
const std::map<std::string, std::string> GetAttributes() const noexcept;
|
||||
void SetAttribute(std::string &&name, std::string &&value);
|
||||
|
||||
/**
|
||||
* Enables the device, but don't wait for completion.
|
||||
*
|
||||
|
||||
@@ -40,6 +40,18 @@ FilteredAudioOutput::SupportsPause() const noexcept
|
||||
return output->SupportsPause();
|
||||
}
|
||||
|
||||
const std::map<std::string, std::string>
|
||||
FilteredAudioOutput::GetAttributes() const noexcept
|
||||
{
|
||||
return output->GetAttributes();
|
||||
}
|
||||
|
||||
void
|
||||
FilteredAudioOutput::SetAttribute(std::string &&_name, std::string &&_value)
|
||||
{
|
||||
output->SetAttribute(std::move(_name), std::move(_value));
|
||||
}
|
||||
|
||||
void
|
||||
FilteredAudioOutput::Enable()
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
|
||||
class PreparedFilter;
|
||||
@@ -167,6 +168,9 @@ public:
|
||||
gcc_pure
|
||||
bool SupportsPause() const noexcept;
|
||||
|
||||
const std::map<std::string, std::string> GetAttributes() const noexcept;
|
||||
void SetAttribute(std::string &&name, std::string &&value);
|
||||
|
||||
/**
|
||||
* Throws #std::runtime_error on error.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2003-2017 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "Interface.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
void
|
||||
AudioOutput::SetAttribute(gcc_unused std::string &&name,
|
||||
gcc_unused std::string &&value)
|
||||
{
|
||||
throw std::invalid_argument("Unsupported attribute");
|
||||
}
|
||||
@@ -20,7 +20,10 @@
|
||||
#ifndef MPD_AUDIO_OUTPUT_INTERFACE_HXX
|
||||
#define MPD_AUDIO_OUTPUT_INTERFACE_HXX
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <stdexcept>
|
||||
|
||||
struct AudioFormat;
|
||||
struct Tag;
|
||||
@@ -57,6 +60,22 @@ public:
|
||||
return flags & FLAG_NEED_FULLY_DEFINED_AUDIO_FORMAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of runtime attributes.
|
||||
*
|
||||
* This method must be thread-safe.
|
||||
*/
|
||||
virtual const std::map<std::string, std::string> GetAttributes() const noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulate a runtime attribute on client request.
|
||||
*
|
||||
* This method must be thread-safe.
|
||||
*/
|
||||
virtual void SetAttribute(std::string &&name, std::string &&value);
|
||||
|
||||
/**
|
||||
* Enable the device. This may allocate resources, preparing
|
||||
* for the device to be opened.
|
||||
|
||||
@@ -41,5 +41,9 @@ printAudioDevices(Response &r, const MultipleOutputs &outputs)
|
||||
i,
|
||||
ao.GetName(), ao.GetPluginName(),
|
||||
ao.IsEnabled());
|
||||
|
||||
for (const auto &a : ao.GetAttributes())
|
||||
r.Format("attribute: %s=%s\n",
|
||||
a.first.c_str(), a.second.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user