Partition, ...: use libfmt for logging

This commit is contained in:
Max Kellermann
2021-06-24 20:22:48 +02:00
parent 0185d58a2b
commit 6f539cfcd6
44 changed files with 320 additions and 296 deletions

View File

@@ -498,9 +498,9 @@ alsa_test_default_device()
int ret = snd_pcm_open(&handle, default_device,
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (ret) {
FormatError(alsa_output_domain,
"Error opening default ALSA device: %s",
snd_strerror(-ret));
FmtError(alsa_output_domain,
"Error opening default ALSA device: {}",
snd_strerror(-ret));
return false;
} else
snd_pcm_close(handle);
@@ -548,13 +548,13 @@ AlsaOutput::Setup(AudioFormat &audio_format,
buffer_time, period_time,
audio_format, params);
FormatDebug(alsa_output_domain, "format=%s (%s)",
snd_pcm_format_name(hw_result.format),
snd_pcm_format_description(hw_result.format));
FmtDebug(alsa_output_domain, "format={} ({})",
snd_pcm_format_name(hw_result.format),
snd_pcm_format_description(hw_result.format));
FormatDebug(alsa_output_domain, "buffer_size=%u period_size=%u",
(unsigned)hw_result.buffer_size,
(unsigned)hw_result.period_size);
FmtDebug(alsa_output_domain, "buffer_size={} period_size={}",
hw_result.buffer_size,
hw_result.period_size);
AlsaSetupSw(pcm, hw_result.buffer_size - hw_result.period_size,
hw_result.period_size);
@@ -708,9 +708,9 @@ AlsaOutput::Open(AudioFormat &audio_format)
throw FormatRuntimeError("Failed to open ALSA device \"%s\": %s",
GetDevice(), snd_strerror(err));
FormatDebug(alsa_output_domain, "opened %s type=%s",
snd_pcm_name(pcm),
snd_pcm_type_name(snd_pcm_type(pcm)));
FmtDebug(alsa_output_domain, "opened {} type={}",
snd_pcm_name(pcm),
snd_pcm_type_name(snd_pcm_type(pcm)));
PcmExport::Params params;
params.alsa_channel_order = true;
@@ -734,7 +734,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
#ifdef ENABLE_DSD
if (params.dsd_mode == PcmExport::DsdMode::DOP)
FormatDebug(alsa_output_domain, "DoP (DSD over PCM) enabled");
LogDebug(alsa_output_domain, "DoP (DSD over PCM) enabled");
#endif
pcm_export->Open(audio_format.format,
@@ -775,13 +775,13 @@ inline int
AlsaOutput::Recover(int err) noexcept
{
if (err == -EPIPE) {
FormatDebug(alsa_output_domain,
"Underrun on ALSA device \"%s\"",
GetDevice());
FmtDebug(alsa_output_domain,
"Underrun on ALSA device \"{}\"",
GetDevice());
} else if (err == -ESTRPIPE) {
FormatDebug(alsa_output_domain,
"ALSA device \"%s\" was suspended",
GetDevice());
FmtDebug(alsa_output_domain,
"ALSA device \"{}\" was suspended",
GetDevice());
}
switch (snd_pcm_state(pcm)) {
@@ -1158,7 +1158,7 @@ try {
}
if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5)))
FormatWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun");
LogWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun");
/* insert some silence if the buffer has not enough
data yet, to avoid ALSA xrun */

View File

@@ -60,8 +60,8 @@ sndio_test_default_device()
{
auto *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
if (!hdl) {
FormatError(sndio_output_domain,
"Error opening default sndio device");
LogError(sndio_output_domain,
"Error opening default sndio device");
return false;
}

View File

@@ -391,12 +391,12 @@ SlesOutput::Cancel() noexcept
SLresult result = play.SetPlayState(SL_PLAYSTATE_PAUSED);
if (result != SL_RESULT_SUCCESS)
FormatError(sles_domain, "Play.SetPlayState(PAUSED) failed");
LogError(sles_domain, "Play.SetPlayState(PAUSED) failed");
result = queue.Clear();
if (result != SL_RESULT_SUCCESS)
FormatWarning(sles_domain,
"AndroidSimpleBufferQueue.Clear() failed");
LogWarning(sles_domain,
"AndroidSimpleBufferQueue.Clear() failed");
const std::lock_guard<Mutex> protect(mutex);
n_queued = 0;

View File

@@ -422,7 +422,7 @@ inline void
WasapiOutputThread::Work() noexcept
try {
SetThreadName("Wasapi Output Worker");
FormatDebug(wasapi_output_domain, "Working thread started");
LogDebug(wasapi_output_domain, "Working thread started");
COM com;
AtScopeExit(this) {
@@ -448,8 +448,8 @@ try {
Status current_state = status.load();
switch (current_state) {
case Status::FINISH:
FormatDebug(wasapi_output_domain,
"Working thread stopped");
LogDebug(wasapi_output_domain,
"Working thread stopped");
return;
case Status::PAUSE:
@@ -589,8 +589,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
if (device_format.Format.wBitsPerSample == 24) {
params.pack24 = true;
}
FormatDebug(wasapi_output_domain, "Packing data: shift8=%d pack24=%d",
int(params.shift8), int(params.pack24));
FmtDebug(wasapi_output_domain, "Packing data: shift8={} pack24={}",
params.shift8, params.pack24);
pcm_export.emplace();
pcm_export->Open(audio_format.format, audio_format.channels, params);
}
@@ -608,11 +608,11 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
FAILED(result)) {
throw MakeHResultError(result, "Unable to get device period");
}
FormatDebug(wasapi_output_domain,
"Default device period: %lu ns, Minimum device period: "
"%lu ns",
(unsigned long)ns(hundred_ns(default_device_period)).count(),
(unsigned long)ns(hundred_ns(min_device_period)).count());
FmtDebug(wasapi_output_domain,
"Default device period: {} ns, Minimum device period: "
"{} ns",
ns(hundred_ns(default_device_period)).count(),
ns(hundred_ns(min_device_period)).count());
REFERENCE_TIME buffer_duration;
if (Exclusive()) {
@@ -621,8 +621,8 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
const REFERENCE_TIME align = hundred_ns(ms(50)).count();
buffer_duration = (align / default_device_period) * default_device_period;
}
FormatDebug(wasapi_output_domain, "Buffer duration: %lu ns",
(unsigned long)ns(hundred_ns(buffer_duration)).count());
FmtDebug(wasapi_output_domain, "Buffer duration: {} ns",
ns(hundred_ns(buffer_duration)).count());
if (Exclusive()) {
if (HRESULT result = client->Initialize(
@@ -639,10 +639,9 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
std::ceil(double(buffer_size_in_frames *
hundred_ns(s(1)).count()) /
SampleRate());
FormatDebug(
wasapi_output_domain,
"Aligned buffer duration: %lu ns",
(unsigned long)ns(hundred_ns(buffer_duration)).count());
FmtDebug(wasapi_output_domain,
"Aligned buffer duration: {} ns",
ns(hundred_ns(buffer_duration)).count());
client.reset();
client = Activate<IAudioClient>(*device);
result = client->Initialize(
@@ -687,8 +686,7 @@ WasapiOutput::Close() noexcept
try {
thread->CheckException();
} catch (...) {
FormatError(std::current_exception(),
"exception while stopping");
LogError(wasapi_output_domain, "exception while stopping");
}
thread->Finish();
com_worker->Async([&]() {
@@ -1029,8 +1027,8 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator)
if (name == nullptr)
continue;
FormatNotice(wasapi_output_domain,
"Device \"%u\" \"%s\"", i, name.c_str());
FmtNotice(wasapi_output_domain,
"Device \"{}\" \"{}\"", i, name);
}
}