output/Internal: add various trivial getter methods
This commit is contained in:
parent
61a151c803
commit
4484411a77
@ -45,7 +45,7 @@ output_mixer_get_volume(const AudioOutput &ao)
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e,
|
||||
"Failed to read mixer for '%s'",
|
||||
ao.name);
|
||||
ao.GetName());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ output_mixer_set_volume(AudioOutput &ao, unsigned volume)
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e,
|
||||
"Failed to set mixer for '%s'",
|
||||
ao.name);
|
||||
ao.GetName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ AudioOutput::~AudioOutput()
|
||||
void
|
||||
audio_output_free(AudioOutput *ao)
|
||||
{
|
||||
assert(!ao->open);
|
||||
assert(!ao->IsOpen());
|
||||
assert(!ao->fail_timer.IsDefined());
|
||||
assert(!ao->thread.IsDefined());
|
||||
|
||||
|
@ -288,14 +288,38 @@ public:
|
||||
void BeginDestroy();
|
||||
void FinishDestroy();
|
||||
|
||||
const char *GetName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caller must lock the mutex.
|
||||
*/
|
||||
bool IsEnabled() const {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caller must lock the mutex.
|
||||
*/
|
||||
bool IsOpen() const {
|
||||
return open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caller must lock the mutex.
|
||||
*/
|
||||
bool IsCommandFinished() const {
|
||||
return command == Command::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caller must lock the mutex.
|
||||
*/
|
||||
const std::exception_ptr &GetLastError() const {
|
||||
return last_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for command completion.
|
||||
*
|
||||
|
@ -76,9 +76,9 @@ MultipleOutputs::Configure(EventLoop &event_loop,
|
||||
auto output = LoadOutput(event_loop, replay_gain_config,
|
||||
mixer_listener,
|
||||
client, *param);
|
||||
if (FindByName(output->name) != nullptr)
|
||||
if (FindByName(output->GetName()) != nullptr)
|
||||
throw FormatRuntimeError("output devices with identical "
|
||||
"names: %s", output->name);
|
||||
"names: %s", output->GetName());
|
||||
|
||||
outputs.push_back(output);
|
||||
}
|
||||
@ -97,7 +97,7 @@ AudioOutput *
|
||||
MultipleOutputs::FindByName(const char *name) const
|
||||
{
|
||||
for (auto i : outputs)
|
||||
if (strcmp(i->name, name) == 0)
|
||||
if (strcmp(i->GetName(), name) == 0)
|
||||
return i;
|
||||
|
||||
return nullptr;
|
||||
@ -217,13 +217,13 @@ MultipleOutputs::Open(const AudioFormat audio_format,
|
||||
for (auto ao : outputs) {
|
||||
const ScopeLock lock(ao->mutex);
|
||||
|
||||
if (ao->enabled)
|
||||
if (ao->IsEnabled())
|
||||
enabled = true;
|
||||
|
||||
if (ao->open)
|
||||
if (ao->IsOpen())
|
||||
ret = true;
|
||||
else if (ao->last_error && !first_error)
|
||||
first_error = ao->last_error;
|
||||
else if (!first_error)
|
||||
first_error = ao->GetLastError();
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
@ -265,7 +265,7 @@ MultipleOutputs::ClearTailChunk(const MusicChunk *chunk,
|
||||
/* this mutex will be unlocked by the caller when it's
|
||||
ready */
|
||||
ao->mutex.lock();
|
||||
locked[i] = ao->open;
|
||||
locked[i] = ao->IsOpen();
|
||||
|
||||
if (!locked[i]) {
|
||||
ao->mutex.unlock();
|
||||
|
@ -37,6 +37,6 @@ printAudioDevices(Response &r, const MultipleOutputs &outputs)
|
||||
r.Format("outputid: %i\n"
|
||||
"outputname: %s\n"
|
||||
"outputenabled: %i\n",
|
||||
i, ao.name, ao.enabled);
|
||||
i, ao.GetName(), ao.IsEnabled());
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ audio_output_state_save(BufferedOutputStream &os,
|
||||
const AudioOutput &ao = outputs.Get(i);
|
||||
const ScopeLock lock(ao.mutex);
|
||||
|
||||
os.Format(AUDIO_DEVICE_STATE "%d:%s\n", ao.enabled, ao.name);
|
||||
os.Format(AUDIO_DEVICE_STATE "%d:%s\n",
|
||||
ao.IsEnabled(), ao.GetName());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user