summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/output/Control.cxx6
-rw-r--r--src/output/Control.hxx3
-rw-r--r--src/output/Filtered.cxx23
-rw-r--r--src/output/Filtered.hxx14
-rw-r--r--src/output/Init.cxx7
-rw-r--r--src/output/Thread.cxx15
6 files changed, 47 insertions, 21 deletions
diff --git a/src/output/Control.cxx b/src/output/Control.cxx
index c42a1cb0a..3bab8195d 100644
--- a/src/output/Control.cxx
+++ b/src/output/Control.cxx
@@ -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
{
diff --git a/src/output/Control.hxx b/src/output/Control.hxx
index 46bad6898..5e1c39554 100644
--- a/src/output/Control.hxx
+++ b/src/output/Control.hxx
@@ -232,6 +232,9 @@ public:
gcc_pure
const char *GetName() const noexcept;
+ gcc_pure
+ const char *GetLogName() const noexcept;
+
AudioOutputClient &GetClient() noexcept {
return client;
}
diff --git a/src/output/Filtered.cxx b/src/output/Filtered.cxx
index db74a3ab5..2fa1321c2 100644
--- a/src/output/Filtered.cxx
+++ b/src/output/Filtered.cxx
@@ -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;
}
}
diff --git a/src/output/Filtered.hxx b/src/output/Filtered.hxx
index 2fb31ed49..385c67d00 100644
--- a/src/output/Filtered.hxx
+++ b/src/output/Filtered.hxx
@@ -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.
*/
diff --git a/src/output/Init.cxx b/src/output/Init.cxx
index 775e90184..b33d3914c 100644
--- a/src/output/Init.cxx
+++ b/src/output/Init.cxx
@@ -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();
diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx
index b3a6c567f..ba8440151 100644
--- a/src/output/Thread.cxx
+++ b/src/output/Thread.cxx
@@ -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;
}