output/Filtered: add attribute "log_name"
This commit is contained in:
parent
47c9d6ac64
commit
5431fca99b
|
@ -59,6 +59,12 @@ AudioOutputControl::GetName() const noexcept
|
|||
return output->GetName();
|
||||
}
|
||||
|
||||
const char *
|
||||
AudioOutputControl::GetLogName() const noexcept
|
||||
{
|
||||
return output->GetLogName();
|
||||
}
|
||||
|
||||
Mixer *
|
||||
AudioOutputControl::GetMixer() const noexcept
|
||||
{
|
||||
|
|
|
@ -232,6 +232,9 @@ public:
|
|||
gcc_pure
|
||||
const char *GetName() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
const char *GetLogName() const noexcept;
|
||||
|
||||
AudioOutputClient &GetClient() noexcept {
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ FilteredAudioOutput::Enable()
|
|||
try {
|
||||
ao_plugin_enable(*this);
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to enable output \"%s\" [%s]",
|
||||
name, plugin.name));
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to enable output %s",
|
||||
GetLogName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ FilteredAudioOutput::ConfigureConvertFilter()
|
|||
try {
|
||||
convert_filter_set(convert_filter.Get(), out_audio_format);
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
|
||||
name, plugin.name));
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to convert for %s",
|
||||
GetLogName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,13 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
|
|||
try {
|
||||
ao_plugin_open(*this, out_audio_format);
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to open \"%s\" [%s]",
|
||||
name, plugin.name));
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to open %s",
|
||||
GetLogName()));
|
||||
}
|
||||
|
||||
FormatDebug(output_domain,
|
||||
"opened plugin=%s name=\"%s\" audio_format=%s",
|
||||
plugin.name, name,
|
||||
"opened %s audio_format=%s",
|
||||
GetLogName(),
|
||||
ToString(out_audio_format).c_str());
|
||||
|
||||
try {
|
||||
|
@ -128,8 +128,7 @@ FilteredAudioOutput::Close(bool drain) noexcept
|
|||
CloseOutput(drain);
|
||||
CloseSoftwareMixer();
|
||||
|
||||
FormatDebug(output_domain, "closed plugin=%s name=\"%s\"",
|
||||
plugin.name, name);
|
||||
FormatDebug(output_domain, "closed %s", GetLogName());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -144,8 +143,8 @@ FilteredAudioOutput::IteratePause() noexcept
|
|||
try {
|
||||
return ao_plugin_pause(*this);
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e, "\"%s\" [%s] failed to pause",
|
||||
name, plugin.name);
|
||||
FormatError(e, "Failed to pause %s",
|
||||
GetLogName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "AudioFormat.hxx"
|
||||
#include "filter/Observer.hxx"
|
||||
|
||||
#include <string>
|
||||
|
||||
class PreparedFilter;
|
||||
class MusicPipe;
|
||||
class EventLoop;
|
||||
|
@ -39,6 +41,14 @@ struct FilteredAudioOutput {
|
|||
*/
|
||||
const char *name;
|
||||
|
||||
private:
|
||||
/**
|
||||
* A string describing this devicee in log messages. It is
|
||||
* usually in the form "NAME (PLUGIN)".
|
||||
*/
|
||||
std::string log_name;
|
||||
|
||||
public:
|
||||
/**
|
||||
* The plugin which implements this output device.
|
||||
*/
|
||||
|
@ -129,6 +139,10 @@ public:
|
|||
return name;
|
||||
}
|
||||
|
||||
const char *GetLogName() const noexcept {
|
||||
return log_name.c_str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws #std::runtime_error on error.
|
||||
*/
|
||||
|
|
|
@ -166,6 +166,13 @@ FilteredAudioOutput::Configure(const ConfigBlock &block)
|
|||
config_audio_format.Clear();
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "\"%s\" (%s)",
|
||||
name, plugin.name);
|
||||
log_name = buffer;
|
||||
}
|
||||
|
||||
/* set up the filter chain */
|
||||
|
||||
prepared_filter = filter_chain_new();
|
||||
|
|
|
@ -151,8 +151,8 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
|
|||
output->prepared_other_replay_gain_filter,
|
||||
output->prepared_filter);
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to open filter for \"%s\" [%s]",
|
||||
GetName(), output->plugin.name));
|
||||
std::throw_with_nested(FormatRuntimeError("Failed to open filter for %s",
|
||||
GetLogName()));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -233,8 +233,7 @@ AudioOutputControl::FillSourceOrClose()
|
|||
try {
|
||||
return source.Fill(mutex);
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e, "Failed to filter for output \"%s\" [%s]",
|
||||
GetName(), output->plugin.name);
|
||||
FormatError(e, "Failed to filter for %s", GetLogName());
|
||||
|
||||
InternalClose(false);
|
||||
|
||||
|
@ -254,8 +253,8 @@ AudioOutputControl::PlayChunk() noexcept
|
|||
try {
|
||||
ao_plugin_send_tag(*output, *tag);
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e, "Failed to send tag to \"%s\" [%s]",
|
||||
GetName(), output->plugin.name);
|
||||
FormatError(e, "Failed to send tag to %s",
|
||||
GetLogName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,9 +276,7 @@ AudioOutputControl::PlayChunk() noexcept
|
|||
nbytes = ao_plugin_play(*output, data.data, data.size);
|
||||
assert(nbytes <= data.size);
|
||||
} catch (const std::runtime_error &e) {
|
||||
FormatError(e, "\"%s\" [%s] failed to play",
|
||||
GetName(), output->plugin.name);
|
||||
|
||||
FormatError(e, "Failed to play on %s", GetLogName());
|
||||
nbytes = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue