decoder/mad, ...: more libfmt logging

This commit is contained in:
Max Kellermann
2021-06-25 17:26:41 +02:00
parent f60a42e0b6
commit b29a43b4d7
42 changed files with 245 additions and 251 deletions

View File

@@ -123,8 +123,8 @@ AoOutput::AoOutput(const ConfigBlock &block)
if (ai == nullptr)
throw std::runtime_error("problems getting driver info");
FormatDebug(ao_output_domain, "using ao driver \"%s\" for \"%s\"\n",
ai->short_name, block.GetBlockValue("name", nullptr));
FmtDebug(ao_output_domain, "using ao driver \"{}\" for \"{}\"\n",
ai->short_name, block.GetBlockValue("name", nullptr));
value = block.GetBlockValue("options", nullptr);
if (value != nullptr) {

View File

@@ -90,8 +90,8 @@ FifoOutput::FifoOutput(const ConfigBlock &block)
inline void
FifoOutput::Delete()
{
FormatDebug(fifo_output_domain,
"Removing FIFO \"%s\"", path_utf8.c_str());
FmtDebug(fifo_output_domain,
"Removing FIFO \"{}\"", path_utf8);
try {
RemoveFile(path);

View File

@@ -96,7 +96,7 @@ initialize_application()
// TODO: actually Run() it and handle B_QUIT_REQUESTED
// TODO: use some locking?
if (be_app == NULL) {
FormatDebug(haiku_output_domain, "creating be_app\n");
LogDebug(haiku_output_domain, "creating be_app");
new BApplication("application/x-vnd.MusicPD");
}
}
@@ -107,7 +107,7 @@ finalize_application()
// TODO: use some locking?
delete be_app;
be_app = NULL;
FormatDebug(haiku_output_domain, "deleting be_app\n");
LogDebug(haiku_output_domain, "deleting be_app");
}
static bool
@@ -163,19 +163,18 @@ HaikuOutput::FillBuffer(void* _buffer, size_t size,
release_sem(new_buffer);
acquire_sem(buffer_done);
bigtime_t w = system_time() - start;
if (w > 5000LL) {
FormatDebug(haiku_output_domain,
"haiku:fill_buffer waited %Ldus\n", w);
FmtDebug(haiku_output_domain,
"haiku:fill_buffer waited {}us", w);
}
if (buffer_filled < buffer_size) {
memset(buffer + buffer_filled, 0,
buffer_size - buffer_filled);
FormatDebug(haiku_output_domain,
"haiku:fill_buffer filled %d size %d clearing remainder\n",
(int)buffer_filled, (int)buffer_size);
FmtDebug(haiku_output_domain,
"haiku:fill_buffer filled {} size {} clearing remainder",
buffer_filled, buffer_size);
}
}
@@ -222,12 +221,12 @@ HaikuOutput::Open(AudioFormat &audio_format)
format.channel_count, format.format,
format.frame_rate, B_UNKNOWN_BUS) * 2;
FormatDebug(haiku_output_domain,
"using haiku driver ad: bs: %d ws: %d "
"channels %d rate %f fmt %08lx bs %d\n",
(int)buffer_size, (int)write_size,
(int)format.channel_count, format.frame_rate,
format.format, (int)format.buffer_size);
FmtDebug(haiku_output_domain,
"using haiku driver ad: bs: {} ws: {} "
"channels {} rate {} fmt {:08x} bs {}",
buffer_size, write_size,
format.channel_count, format.frame_rate,
format.format, format.buffer_size);
sound_player = new BSoundPlayer(&format, "MPD Output",
HaikuOutput::_FillBuffer, NULL, this);
@@ -247,8 +246,7 @@ HaikuOutput::Open(AudioFormat &audio_format)
buffer_delay *= 1000 / format.frame_rate;
// half of the total buffer play time
buffer_delay /= 2;
FormatDebug(haiku_output_domain,
"buffer delay: %d ms\n", buffer_delay);
FmtDebug(haiku_output_domain, "buffer delay: {} ms", buffer_delay);
new_buffer = create_sem(0, "New buffer request");
buffer_done = create_sem(0, "Buffer done");
@@ -303,8 +301,8 @@ HaikuOutput::Delay() const noexcept
{
unsigned delay = buffer_filled ? 0 : buffer_delay;
//FormatDebug(haiku_output_domain,
// "delay=%d\n", delay / 2);
//FmtDebug(haiku_output_domain,
// "delay={}", delay / 2);
// XXX: doesn't work
//return (delay / 2) ? 1 : 0;
(void)delay;
@@ -393,8 +391,9 @@ HaikuOutput::SendTag(const Tag &tag)
case TAG_MUSICBRAINZ_ALBUMARTISTID:
case TAG_MUSICBRAINZ_TRACKID:
default:
FormatDebug(haiku_output_domain,
"tag item: type %d value '%s'\n", item.type, item.value);
FmtDebug(haiku_output_domain,
"tag item: type {} value '{}'\n",
item.type, item.value);
break;
}
}

View File

@@ -242,9 +242,9 @@ JackOutput::JackOutput(const ConfigBlock &block)
/* compatibility with MPD < 0.16 */
value = block.GetBlockValue("ports", nullptr);
if (value != nullptr)
FormatWarning(jack_output_domain,
"deprecated option 'ports' in line %d",
block.line);
FmtWarning(jack_output_domain,
"deprecated option 'ports' in line {}",
block.line);
}
if (value != nullptr) {
@@ -258,11 +258,11 @@ JackOutput::JackOutput(const ConfigBlock &block)
if (num_destination_ports > 0 &&
num_destination_ports != num_source_ports)
FormatWarning(jack_output_domain,
"number of source ports (%u) mismatches the "
"number of destination ports (%u) in line %d",
num_source_ports, num_destination_ports,
block.line);
FmtWarning(jack_output_domain,
"number of source ports ({}) mismatches the "
"number of destination ports ({}) in line {}",
num_source_ports, num_destination_ports,
block.line);
ringbuffer_size = block.GetPositiveValue("ringbuffer_size", 32768U);
}
@@ -543,10 +543,9 @@ JackOutput::Start()
for (num_dports = 0; num_dports < MAX_PORTS &&
jports[num_dports] != nullptr;
++num_dports) {
FormatDebug(jack_output_domain,
"destination_port[%u] = '%s'\n",
num_dports,
jports[num_dports]);
FmtDebug(jack_output_domain,
"destination_port[{}] = '{}'\n",
num_dports, jports[num_dports]);
dports[num_dports] = jports[num_dports];
}
} else {

View File

@@ -258,9 +258,10 @@ osx_output_parse_channel_map(const char *device_name,
channel_map_str = endptr;
want_number = false;
FormatDebug(osx_output_domain,
"%s: channel_map[%u] = %d",
device_name, inserted_channels, channel_map[inserted_channels]);
FmtDebug(osx_output_domain,
"{}: channel_map[{}] = {}",
device_name, inserted_channels,
channel_map[inserted_channels]);
++inserted_channels;
continue;
}
@@ -421,10 +422,10 @@ osx_output_set_device_format(AudioDeviceID dev_id,
// print all (linear pcm) formats and their rating
if (score > 0.0f)
FormatDebug(osx_output_domain,
"Format: %s rated %f",
StreamDescriptionToString(format_desc).c_str(),
(double)score);
FmtDebug(osx_output_domain,
"Format: {} rated {}",
StreamDescriptionToString(format_desc).c_str(),
score);
if (score > output_score) {
output_score = score;
@@ -498,14 +499,14 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
if (hog) {
if (hog_pid != -1) {
FormatDebug(osx_output_domain,
"Device is already hogged.");
LogDebug(osx_output_domain,
"Device is already hogged");
return;
}
} else {
if (hog_pid != getpid()) {
FormatDebug(osx_output_domain,
"Device is not owned by this process.");
FmtDebug(osx_output_domain,
"Device is not owned by this process");
return;
}
}
@@ -520,9 +521,8 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
size,
&hog_pid);
if (err != noErr) {
FormatDebug(osx_output_domain,
"Cannot hog the device: %d",
err);
FmtDebug(osx_output_domain,
"Cannot hog the device: {}", err);
} else {
LogDebug(osx_output_domain,
hog_pid == -1
@@ -585,16 +585,16 @@ osx_output_set_device(OSXOutput *oo)
const auto id = FindAudioDeviceByName(oo->device_name);
FormatDebug(osx_output_domain,
"found matching device: ID=%u, name=%s",
(unsigned)id, oo->device_name);
FmtDebug(osx_output_domain,
"found matching device: ID={}, name={}",
id, oo->device_name);
AudioUnitSetCurrentDevice(oo->au, id);
oo->dev_id = id;
FormatDebug(osx_output_domain,
"set OS X audio output device ID=%u, name=%s",
(unsigned)id, oo->device_name);
FmtDebug(osx_output_domain,
"set OS X audio output device ID={}, name={}",
id, oo->device_name);
if (oo->channel_map)
osx_output_set_channel_map(oo);

View File

@@ -200,16 +200,16 @@ oss_open_default()
/* never reached */
break;
case OSS_STAT_DOESN_T_EXIST:
FormatWarning(oss_output_domain,
"%s not found", dev);
FmtWarning(oss_output_domain,
"{} not found", dev);
break;
case OSS_STAT_NOT_CHAR_DEV:
FormatWarning(oss_output_domain,
"%s is not a character device", dev);
FmtWarning(oss_output_domain,
"{} is not a character device", dev);
break;
case OSS_STAT_NO_PERMS:
FormatWarning(oss_output_domain,
"%s: permission denied", dev);
FmtWarning(oss_output_domain,
"{}: permission denied", dev);
break;
case OSS_STAT_OTHER:
FormatErrno(oss_output_domain, err[i],

View File

@@ -19,6 +19,7 @@
#include "RecorderOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "tag/Format.hxx"
#include "encoder/ToOutputStream.hxx"
#include "encoder/EncoderInterface.hxx"
@@ -276,8 +277,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path)
path = std::move(new_path);
file = new_file;
FormatDebug(recorder_domain, "Recording to \"%s\"",
path.ToUTF8().c_str());
FmtDebug(recorder_domain, "Recording to \"{}\"", path);
}
void

View File

@@ -282,9 +282,9 @@ ShoutOutput::Close() noexcept
if (shout_get_connected(shout_conn) != SHOUTERR_UNCONNECTED &&
shout_close(shout_conn) != SHOUTERR_SUCCESS) {
FormatWarning(shout_output_domain,
"problem closing connection to shout server: %s",
shout_get_error(shout_conn));
FmtWarning(shout_output_domain,
"problem closing connection to shout server: {}",
shout_get_error(shout_conn));
}
}

View File

@@ -171,9 +171,9 @@ HttpdClient::SendResponse() noexcept
ssize_t nbytes = GetSocket().Write(response, strlen(response));
if (gcc_unlikely(nbytes < 0)) {
const SocketErrorMessage msg;
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
LockClose();
return false;
}
@@ -284,9 +284,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
@@ -311,9 +311,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
@@ -334,9 +334,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
@@ -370,8 +370,8 @@ HttpdClient::PushPage(PagePtr page) noexcept
return;
if (queue_size > 256 * 1024) {
FormatDebug(httpd_output_domain,
"client is too slow, flushing its queue");
LogDebug(httpd_output_domain,
"client is too slow, flushing its queue");
ClearQueue();
}

View File

@@ -26,6 +26,7 @@
#include "PropertyStore.hxx"
#include "output/OutputAPI.hxx"
#include "lib/icu/Win32.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "mixer/MixerList.hxx"
#include "output/Error.hxx"
#include "pcm/Export.hxx"
@@ -824,13 +825,12 @@ WasapiOutput::TryFormatExclusive(const AudioFormat &audio_format)
HRESULT result = client->IsFormatSupported(
AUDCLNT_SHAREMODE_EXCLUSIVE,
reinterpret_cast<WAVEFORMATEX *>(&test_format), nullptr);
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain, "Trying %s %lu %u-%u (exclusive) -> %s",
format_string.c_str(), test_format.Format.nSamplesPerSec,
test_format.Format.wBitsPerSample,
test_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain, "Trying {} {} {}-{} (exclusive) -> {}",
audio_format, test_format.Format.nSamplesPerSec,
test_format.Format.wBitsPerSample,
test_format.Samples.wValidBitsPerSample,
result_string);
if (SUCCEEDED(result)) {
device_format = test_format;
return true;
@@ -922,13 +922,12 @@ WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format)
reinterpret_cast<WAVEFORMATEX *>(&device_format),
closest_format.AddressCast<WAVEFORMATEX>());
{
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain, "Trying %s %lu %u-%u (shared) -> %s",
format_string.c_str(), device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain, "Trying {} {} {}-{} (shared) -> {}",
audio_format, device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string);
}
if (FAILED(result) && result != AUDCLNT_E_UNSUPPORTED_FORMAT) {
@@ -950,15 +949,14 @@ WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format)
reinterpret_cast<WAVEFORMATEX *>(&device_format),
closest_format.AddressCast<WAVEFORMATEX>());
{
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain,
"Trying %s %lu %u-%u (shared) -> %s",
format_string.c_str(),
device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain,
"Trying {} {} {}-{} (shared) -> {}",
audio_format,
device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string);
}
if (FAILED(result)) {
throw MakeHResultError(result, "Format is not supported");