@@ -22,7 +22,7 @@ bool PulseAudio::Init()
m_stereo = !SConfig::GetInstance().ShouldUseDPL2Decoder();
m_channels = m_stereo ? 2 : 6; // will tell PA we use a Stereo or 5.0 channel setup

NOTICE_LOG(AUDIO, "PulseAudio backend using %d channels", m_channels);
NOTICE_LOG_FMT(AUDIO, "PulseAudio backend using {} channels", m_channels);

m_run_thread.Set();
m_thread = std::thread(&PulseAudio::SoundLoop, this);
@@ -47,7 +47,7 @@ void PulseAudio::SoundLoop()
m_pa_error = pa_mainloop_iterate(m_pa_ml, 1, nullptr);

if (m_pa_error < 0)
ERROR_LOG(AUDIO, "PulseAudio error: %s", pa_strerror(m_pa_error));
ERROR_LOG_FMT(AUDIO, "PulseAudio error: {}", pa_strerror(m_pa_error));

PulseShutdown();
}
@@ -73,7 +73,7 @@ bool PulseAudio::PulseInit()

if (m_pa_connected == 2 || m_pa_error < 0)
{
ERROR_LOG(AUDIO, "PulseAudio failed to initialize: %s", pa_strerror(m_pa_error));
ERROR_LOG_FMT(AUDIO, "PulseAudio failed to initialize: {}", pa_strerror(m_pa_error));
return false;
}

@@ -123,11 +123,11 @@ bool PulseAudio::PulseInit()
m_pa_error = pa_stream_connect_playback(m_pa_s, nullptr, &m_pa_ba, flags, nullptr, nullptr);
if (m_pa_error < 0)
{
ERROR_LOG(AUDIO, "PulseAudio failed to initialize: %s", pa_strerror(m_pa_error));
ERROR_LOG_FMT(AUDIO, "PulseAudio failed to initialize: {}", pa_strerror(m_pa_error));
return false;
}

INFO_LOG(AUDIO, "Pulse successfully initialized");
INFO_LOG_FMT(AUDIO, "Pulse successfully initialized");
return true;
}

@@ -161,7 +161,7 @@ void PulseAudio::UnderflowCallback(pa_stream* s)
pa_operation* op = pa_stream_set_buffer_attr(s, &m_pa_ba, nullptr, nullptr);
pa_operation_unref(op);

WARN_LOG(AUDIO, "pulseaudio underflow, new latency: %d bytes", m_pa_ba.tlength);
WARN_LOG_FMT(AUDIO, "pulseaudio underflow, new latency: {} bytes", m_pa_ba.tlength);
}

void PulseAudio::WriteCallback(pa_stream* s, size_t length)
@@ -190,7 +190,7 @@ void PulseAudio::WriteCallback(pa_stream* s, size_t length)
}
else
{
ERROR_LOG(AUDIO, "Unsupported number of PA channels requested: %d", (int)m_channels);
ERROR_LOG_FMT(AUDIO, "Unsupported number of PA channels requested: {}", m_channels);
return;
}
}
@@ -60,12 +60,12 @@ bool WASAPIStream::isValid()
return true;
}

static bool HandleWinAPI(std::string message, HRESULT result)
static bool HandleWinAPI(std::string_view message, HRESULT result)
{
if (result != S_OK)
{
_com_error err(result);
std::string error = TStrToUTF8(err.ErrorMessage()).c_str();
std::string error = TStrToUTF8(err.ErrorMessage());

switch (result)
{
@@ -74,7 +74,7 @@ static bool HandleWinAPI(std::string message, HRESULT result)
break;
}

ERROR_LOG(AUDIO, "WASAPI: %s: %s", message.c_str(), error.c_str());
ERROR_LOG_FMT(AUDIO, "WASAPI: {}: {}", message, error);
}

return result == S_OK;
@@ -236,8 +236,8 @@ bool WASAPIStream::SetRunning(bool running)

if (!device)
{
ERROR_LOG(AUDIO, "Can't find device '%s', falling back to default",
SConfig::GetInstance().sWASAPIDevice.c_str());
ERROR_LOG_FMT(AUDIO, "Can't find device '{}', falling back to default",
SConfig::GetInstance().sWASAPIDevice);
result = m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
}
}
@@ -261,7 +261,7 @@ bool WASAPIStream::SetRunning(bool running)

device_properties->GetValue(PKEY_Device_FriendlyName, &device_name);

INFO_LOG(AUDIO, "Using audio endpoint '%s'", TStrToUTF8(device_name.pwszVal).c_str());
INFO_LOG_FMT(AUDIO, "Using audio endpoint '{}'", TStrToUTF8(device_name.pwszVal));

PropVariantClear(&device_name);

@@ -280,7 +280,7 @@ bool WASAPIStream::SetRunning(bool running)
result = m_audio_client->GetDevicePeriod(nullptr, &device_period);

device_period += SConfig::GetInstance().iLatency * (10000 / m_format.Format.nChannels);
INFO_LOG(AUDIO, "Audio period set to %d", device_period);
INFO_LOG_FMT(AUDIO, "Audio period set to {}", device_period);

if (!HandleWinAPI("Failed to obtain device period", result))
{
@@ -384,7 +384,7 @@ bool WASAPIStream::SetRunning(bool running)

device->Release();

INFO_LOG(AUDIO, "WASAPI: Successfully initialized!");
INFO_LOG_FMT(AUDIO, "WASAPI: Successfully initialized!");

m_running = true;
m_thread = std::thread([this] { SoundLoop(); });