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