Merge pull request #9176 from lioncash/audiofmt
AudioCommon: Migrate logging over to fmt
This commit is contained in:
commit
96ce3e5f49
|
@ -64,7 +64,7 @@ void AlsaSound::SoundLoop()
|
||||||
}
|
}
|
||||||
else if (rc < 0)
|
else if (rc < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "writei fail: %s", snd_strerror(rc));
|
ERROR_LOG_FMT(AUDIO, "writei fail: {}", snd_strerror(rc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_thread_status.load() == ALSAThreadStatus::PAUSED)
|
if (m_thread_status.load() == ALSAThreadStatus::PAUSED)
|
||||||
|
@ -107,7 +107,7 @@ bool AlsaSound::AlsaInit()
|
||||||
err = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
|
err = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Audio open error: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Audio open error: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,21 +116,21 @@ bool AlsaSound::AlsaInit()
|
||||||
err = snd_pcm_hw_params_any(handle, hwparams);
|
err = snd_pcm_hw_params_any(handle, hwparams);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Broken configuration for this PCM: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Broken configuration for this PCM: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
|
err = snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Access type not available: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Access type not available: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16_LE);
|
err = snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16_LE);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Sample format not available: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Sample format not available: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,14 +138,14 @@ bool AlsaSound::AlsaInit()
|
||||||
err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &sample_rate, &dir);
|
err = snd_pcm_hw_params_set_rate_near(handle, hwparams, &sample_rate, &dir);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Rate not available: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Rate not available: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_channels(handle, hwparams, CHANNEL_COUNT);
|
err = snd_pcm_hw_params_set_channels(handle, hwparams, CHANNEL_COUNT);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Channels count not available: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Channels count not available: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ bool AlsaSound::AlsaInit()
|
||||||
err = snd_pcm_hw_params_set_periods_max(handle, hwparams, &periods, &dir);
|
err = snd_pcm_hw_params_set_periods_max(handle, hwparams, &periods, &dir);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Cannot set maximum periods per buffer: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Cannot set maximum periods per buffer: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,28 +161,28 @@ bool AlsaSound::AlsaInit()
|
||||||
err = snd_pcm_hw_params_set_buffer_size_max(handle, hwparams, &buffer_size_max);
|
err = snd_pcm_hw_params_set_buffer_size_max(handle, hwparams, &buffer_size_max);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Cannot set maximum buffer size: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Cannot set maximum buffer size: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params(handle, hwparams);
|
err = snd_pcm_hw_params(handle, hwparams);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Unable to install hw params: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Unable to install hw params: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size);
|
err = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Cannot get buffer size: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Cannot get buffer size: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_get_periods_max(hwparams, &periods, &dir);
|
err = snd_pcm_hw_params_get_periods_max(hwparams, &periods, &dir);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Cannot get periods: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Cannot get periods: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,41 +195,41 @@ bool AlsaSound::AlsaInit()
|
||||||
// it is probably a bad idea to try to send more than one buffer of data
|
// it is probably a bad idea to try to send more than one buffer of data
|
||||||
if ((unsigned int)frames_to_deliver > buffer_size)
|
if ((unsigned int)frames_to_deliver > buffer_size)
|
||||||
frames_to_deliver = buffer_size;
|
frames_to_deliver = buffer_size;
|
||||||
NOTICE_LOG(AUDIO,
|
NOTICE_LOG_FMT(AUDIO,
|
||||||
"ALSA gave us a %ld sample \"hardware\" buffer with %d periods. Will send %d "
|
"ALSA gave us a {} sample \"hardware\" buffer with {} periods. Will send {} "
|
||||||
"samples per fragments.",
|
"samples per fragments.",
|
||||||
buffer_size, periods, frames_to_deliver);
|
buffer_size, periods, frames_to_deliver);
|
||||||
|
|
||||||
snd_pcm_sw_params_alloca(&swparams);
|
snd_pcm_sw_params_alloca(&swparams);
|
||||||
|
|
||||||
err = snd_pcm_sw_params_current(handle, swparams);
|
err = snd_pcm_sw_params_current(handle, swparams);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "cannot init sw params: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "cannot init sw params: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_sw_params_set_start_threshold(handle, swparams, 0U);
|
err = snd_pcm_sw_params_set_start_threshold(handle, swparams, 0U);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "cannot set start thresh: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "cannot set start thresh: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_sw_params(handle, swparams);
|
err = snd_pcm_sw_params(handle, swparams);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "cannot set sw params: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "cannot set sw params: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_prepare(handle);
|
err = snd_pcm_prepare(handle);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Unable to prepare: %s", snd_strerror(err));
|
ERROR_LOG_FMT(AUDIO, "Unable to prepare: {}", snd_strerror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NOTICE_LOG(AUDIO, "ALSA successfully initialized.");
|
NOTICE_LOG_FMT(AUDIO, "ALSA successfully initialized.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,16 +54,15 @@ void InitSoundStream()
|
||||||
|
|
||||||
if (!g_sound_stream)
|
if (!g_sound_stream)
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "Unknown backend %s, using %s instead.", backend.c_str(),
|
WARN_LOG_FMT(AUDIO, "Unknown backend {}, using {} instead.", backend, GetDefaultSoundBackend());
|
||||||
GetDefaultSoundBackend().c_str());
|
|
||||||
backend = GetDefaultSoundBackend();
|
backend = GetDefaultSoundBackend();
|
||||||
g_sound_stream = CreateSoundStreamForBackend(GetDefaultSoundBackend());
|
g_sound_stream = CreateSoundStreamForBackend(GetDefaultSoundBackend());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_sound_stream || !g_sound_stream->Init())
|
if (!g_sound_stream || !g_sound_stream->Init())
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "Could not initialize backend %s, using %s instead.", backend.c_str(),
|
WARN_LOG_FMT(AUDIO, "Could not initialize backend {}, using {} instead.", backend,
|
||||||
BACKEND_NULLSOUND);
|
BACKEND_NULLSOUND);
|
||||||
g_sound_stream = std::make_unique<NullSound>();
|
g_sound_stream = std::make_unique<NullSound>();
|
||||||
g_sound_stream->Init();
|
g_sound_stream->Init();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +82,7 @@ void InitSoundStream()
|
||||||
|
|
||||||
void ShutdownSoundStream()
|
void ShutdownSoundStream()
|
||||||
{
|
{
|
||||||
INFO_LOG(AUDIO, "Shutting down sound stream");
|
INFO_LOG_FMT(AUDIO, "Shutting down sound stream");
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_DumpAudio && s_audio_dump_start)
|
if (SConfig::GetInstance().m_DumpAudio && s_audio_dump_start)
|
||||||
StopAudioDump();
|
StopAudioDump();
|
||||||
|
@ -91,7 +90,7 @@ void ShutdownSoundStream()
|
||||||
SetSoundStreamRunning(false);
|
SetSoundStreamRunning(false);
|
||||||
g_sound_stream.reset();
|
g_sound_stream.reset();
|
||||||
|
|
||||||
INFO_LOG(AUDIO, "Done shutting down sound stream");
|
INFO_LOG_FMT(AUDIO, "Done shutting down sound stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetDefaultSoundBackend()
|
std::string GetDefaultSoundBackend()
|
||||||
|
@ -180,9 +179,9 @@ void SetSoundStreamRunning(bool running)
|
||||||
if (g_sound_stream->SetRunning(running))
|
if (g_sound_stream->SetRunning(running))
|
||||||
return;
|
return;
|
||||||
if (running)
|
if (running)
|
||||||
ERROR_LOG(AUDIO, "Error starting stream.");
|
ERROR_LOG_FMT(AUDIO, "Error starting stream.");
|
||||||
else
|
else
|
||||||
ERROR_LOG(AUDIO, "Error stopping stream.");
|
ERROR_LOG_FMT(AUDIO, "Error stopping stream.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendAIBuffer(const short* samples, unsigned int num_samples)
|
void SendAIBuffer(const short* samples, unsigned int num_samples)
|
||||||
|
|
|
@ -58,8 +58,8 @@ void AudioStretcher::ProcessSamples(const short* in, unsigned int num_in, unsign
|
||||||
m_stretch_ratio = std::max(m_stretch_ratio, 0.1);
|
m_stretch_ratio = std::max(m_stretch_ratio, 0.1);
|
||||||
m_sound_touch.setTempo(m_stretch_ratio);
|
m_sound_touch.setTempo(m_stretch_ratio);
|
||||||
|
|
||||||
DEBUG_LOG(AUDIO, "Audio stretching: samples:%u/%u ratio:%f backlog:%f gain: %f", num_in, num_out,
|
DEBUG_LOG_FMT(AUDIO, "Audio stretching: samples:{}/{} ratio:{} backlog:{} gain: {}", num_in,
|
||||||
m_stretch_ratio, backlog_fullness, lpf_gain);
|
num_out, m_stretch_ratio, backlog_fullness, lpf_gain);
|
||||||
|
|
||||||
m_sound_touch.putSamples(in, num_in);
|
m_sound_touch.putSamples(in, num_in);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ bool CubebStream::Init()
|
||||||
|
|
||||||
u32 minimum_latency = 0;
|
u32 minimum_latency = 0;
|
||||||
if (cubeb_get_min_latency(m_ctx.get(), ¶ms, &minimum_latency) != CUBEB_OK)
|
if (cubeb_get_min_latency(m_ctx.get(), ¶ms, &minimum_latency) != CUBEB_OK)
|
||||||
ERROR_LOG(AUDIO, "Error getting minimum latency");
|
ERROR_LOG_FMT(AUDIO, "Error getting minimum latency");
|
||||||
INFO_LOG(AUDIO, "Minimum latency: %i frames", minimum_latency);
|
INFO_LOG_FMT(AUDIO, "Minimum latency: {} frames", minimum_latency);
|
||||||
|
|
||||||
return cubeb_stream_init(m_ctx.get(), &m_stream, "Dolphin Audio Output", nullptr, nullptr,
|
return cubeb_stream_init(m_ctx.get(), &m_stream, "Dolphin Audio Output", nullptr, nullptr,
|
||||||
nullptr, ¶ms, std::max(BUFFER_SAMPLES, minimum_latency),
|
nullptr, ¶ms, std::max(BUFFER_SAMPLES, minimum_latency),
|
||||||
|
|
|
@ -38,7 +38,7 @@ static void DestroyContext(cubeb* ctx)
|
||||||
cubeb_destroy(ctx);
|
cubeb_destroy(ctx);
|
||||||
if (cubeb_set_log_callback(CUBEB_LOG_DISABLED, nullptr) != CUBEB_OK)
|
if (cubeb_set_log_callback(CUBEB_LOG_DISABLED, nullptr) != CUBEB_OK)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Error removing cubeb log callback");
|
ERROR_LOG_FMT(AUDIO, "Error removing cubeb log callback");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,16 +59,16 @@ std::shared_ptr<cubeb> CubebUtils::GetContext()
|
||||||
}
|
}
|
||||||
if (cubeb_set_log_callback(CUBEB_LOG_NORMAL, LogCallback) != CUBEB_OK)
|
if (cubeb_set_log_callback(CUBEB_LOG_NORMAL, LogCallback) != CUBEB_OK)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Error setting cubeb log callback");
|
ERROR_LOG_FMT(AUDIO, "Error setting cubeb log callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
cubeb* ctx;
|
cubeb* ctx;
|
||||||
if (cubeb_init(&ctx, "Dolphin", nullptr) != CUBEB_OK)
|
if (cubeb_init(&ctx, "Dolphin", nullptr) != CUBEB_OK)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Error initializing cubeb library");
|
ERROR_LOG_FMT(AUDIO, "Error initializing cubeb library");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
INFO_LOG(AUDIO, "Cubeb initialized using %s backend", cubeb_get_backend_id(ctx));
|
INFO_LOG_FMT(AUDIO, "Cubeb initialized using {} backend", cubeb_get_backend_id(ctx));
|
||||||
|
|
||||||
weak = shared = {ctx, DestroyContext};
|
weak = shared = {ctx, DestroyContext};
|
||||||
return shared;
|
return shared;
|
||||||
|
|
|
@ -36,7 +36,7 @@ Mixer::Mixer(unsigned int BackendSampleRate)
|
||||||
m_surround_decoder(BackendSampleRate,
|
m_surround_decoder(BackendSampleRate,
|
||||||
DPL2QualityToFrameBlockSize(Config::Get(Config::MAIN_DPL2_QUALITY)))
|
DPL2QualityToFrameBlockSize(Config::Get(Config::MAIN_DPL2_QUALITY)))
|
||||||
{
|
{
|
||||||
INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized");
|
INFO_LOG_FMT(AUDIO_INTERFACE, "Mixer is initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
Mixer::~Mixer()
|
Mixer::~Mixer()
|
||||||
|
@ -193,7 +193,7 @@ unsigned int Mixer::MixSurround(float* samples, unsigned int num_samples)
|
||||||
size_t available_frames = Mix(m_scratch_buffer.data(), static_cast<u32>(needed_frames));
|
size_t available_frames = Mix(m_scratch_buffer.data(), static_cast<u32>(needed_frames));
|
||||||
if (available_frames != needed_frames)
|
if (available_frames != needed_frames)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Error decoding surround frames.");
|
ERROR_LOG_FMT(AUDIO, "Error decoding surround frames.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,17 +296,17 @@ void Mixer::StartLogDTKAudio(const std::string& filename)
|
||||||
{
|
{
|
||||||
m_log_dtk_audio = true;
|
m_log_dtk_audio = true;
|
||||||
m_wave_writer_dtk.SetSkipSilence(false);
|
m_wave_writer_dtk.SetSkipSilence(false);
|
||||||
NOTICE_LOG(AUDIO, "Starting DTK Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Starting DTK Audio logging");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_wave_writer_dtk.Stop();
|
m_wave_writer_dtk.Stop();
|
||||||
NOTICE_LOG(AUDIO, "Unable to start DTK Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Unable to start DTK Audio logging");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "DTK Audio logging has already been started");
|
WARN_LOG_FMT(AUDIO, "DTK Audio logging has already been started");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,11 +316,11 @@ void Mixer::StopLogDTKAudio()
|
||||||
{
|
{
|
||||||
m_log_dtk_audio = false;
|
m_log_dtk_audio = false;
|
||||||
m_wave_writer_dtk.Stop();
|
m_wave_writer_dtk.Stop();
|
||||||
NOTICE_LOG(AUDIO, "Stopping DTK Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Stopping DTK Audio logging");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "DTK Audio logging has already been stopped");
|
WARN_LOG_FMT(AUDIO, "DTK Audio logging has already been stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,17 +333,17 @@ void Mixer::StartLogDSPAudio(const std::string& filename)
|
||||||
{
|
{
|
||||||
m_log_dsp_audio = true;
|
m_log_dsp_audio = true;
|
||||||
m_wave_writer_dsp.SetSkipSilence(false);
|
m_wave_writer_dsp.SetSkipSilence(false);
|
||||||
NOTICE_LOG(AUDIO, "Starting DSP Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Starting DSP Audio logging");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_wave_writer_dsp.Stop();
|
m_wave_writer_dsp.Stop();
|
||||||
NOTICE_LOG(AUDIO, "Unable to start DSP Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Unable to start DSP Audio logging");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "DSP Audio logging has already been started");
|
WARN_LOG_FMT(AUDIO, "DSP Audio logging has already been started");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,11 +353,11 @@ void Mixer::StopLogDSPAudio()
|
||||||
{
|
{
|
||||||
m_log_dsp_audio = false;
|
m_log_dsp_audio = false;
|
||||||
m_wave_writer_dsp.Stop();
|
m_wave_writer_dsp.Stop();
|
||||||
NOTICE_LOG(AUDIO, "Stopping DSP Audio logging");
|
NOTICE_LOG_FMT(AUDIO, "Stopping DSP Audio logging");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG(AUDIO, "DSP Audio logging has already been stopped");
|
WARN_LOG_FMT(AUDIO, "DSP Audio logging has already been stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool OpenALStream::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* default_device_dame = palcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
const char* default_device_dame = palcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||||
INFO_LOG(AUDIO, "Found OpenAL device %s", default_device_dame);
|
INFO_LOG_FMT(AUDIO, "Found OpenAL device {}", default_device_dame);
|
||||||
|
|
||||||
ALCdevice* device = palcOpenDevice(default_device_dame);
|
ALCdevice* device = palcOpenDevice(default_device_dame);
|
||||||
if (!device)
|
if (!device)
|
||||||
|
@ -204,7 +204,7 @@ static ALenum CheckALError(const char* desc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_LOG(AUDIO, "Error %s: %08x %s", desc, err, type.c_str());
|
ERROR_LOG_FMT(AUDIO, "Error {}: {:08x} {}", desc, err, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
@ -246,8 +246,8 @@ void OpenALStream::SoundLoop()
|
||||||
frames_per_buffer = OAL_MAX_FRAMES;
|
frames_per_buffer = OAL_MAX_FRAMES;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(AUDIO, "Using %d buffers, each with %d audio frames for a total of %d.", OAL_BUFFERS,
|
INFO_LOG_FMT(AUDIO, "Using {} buffers, each with {} audio frames for a total of {}.", OAL_BUFFERS,
|
||||||
frames_per_buffer, frames_per_buffer * OAL_BUFFERS);
|
frames_per_buffer, frames_per_buffer * OAL_BUFFERS);
|
||||||
|
|
||||||
// Should we make these larger just in case the mixer ever sends more samples
|
// Should we make these larger just in case the mixer ever sends more samples
|
||||||
// than what we request?
|
// than what we request?
|
||||||
|
@ -352,8 +352,8 @@ void OpenALStream::SoundLoop()
|
||||||
if (err == AL_INVALID_ENUM)
|
if (err == AL_INVALID_ENUM)
|
||||||
{
|
{
|
||||||
// 5.1 is not supported by the host, fallback to stereo
|
// 5.1 is not supported by the host, fallback to stereo
|
||||||
WARN_LOG(AUDIO,
|
WARN_LOG_FMT(
|
||||||
"Unable to set 5.1 surround mode. Updating OpenAL Soft might fix this issue.");
|
AUDIO, "Unable to set 5.1 surround mode. Updating OpenAL Soft might fix this issue.");
|
||||||
use_surround = false;
|
use_surround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ bool PulseAudio::Init()
|
||||||
m_stereo = !SConfig::GetInstance().ShouldUseDPL2Decoder();
|
m_stereo = !SConfig::GetInstance().ShouldUseDPL2Decoder();
|
||||||
m_channels = m_stereo ? 2 : 6; // will tell PA we use a Stereo or 5.0 channel setup
|
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_run_thread.Set();
|
||||||
m_thread = std::thread(&PulseAudio::SoundLoop, this);
|
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);
|
m_pa_error = pa_mainloop_iterate(m_pa_ml, 1, nullptr);
|
||||||
|
|
||||||
if (m_pa_error < 0)
|
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();
|
PulseShutdown();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ bool PulseAudio::PulseInit()
|
||||||
|
|
||||||
if (m_pa_connected == 2 || m_pa_error < 0)
|
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;
|
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);
|
m_pa_error = pa_stream_connect_playback(m_pa_s, nullptr, &m_pa_ba, flags, nullptr, nullptr);
|
||||||
if (m_pa_error < 0)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(AUDIO, "Pulse successfully initialized");
|
INFO_LOG_FMT(AUDIO, "Pulse successfully initialized");
|
||||||
return true;
|
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* op = pa_stream_set_buffer_attr(s, &m_pa_ba, nullptr, nullptr);
|
||||||
pa_operation_unref(op);
|
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)
|
void PulseAudio::WriteCallback(pa_stream* s, size_t length)
|
||||||
|
@ -190,7 +190,7 @@ void PulseAudio::WriteCallback(pa_stream* s, size_t length)
|
||||||
}
|
}
|
||||||
else
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,12 @@ bool WASAPIStream::isValid()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleWinAPI(std::string message, HRESULT result)
|
static bool HandleWinAPI(std::string_view message, HRESULT result)
|
||||||
{
|
{
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
_com_error err(result);
|
_com_error err(result);
|
||||||
std::string error = TStrToUTF8(err.ErrorMessage()).c_str();
|
std::string error = TStrToUTF8(err.ErrorMessage());
|
||||||
|
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ static bool HandleWinAPI(std::string message, HRESULT result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_LOG(AUDIO, "WASAPI: %s: %s", message.c_str(), error.c_str());
|
ERROR_LOG_FMT(AUDIO, "WASAPI: {}: {}", message, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result == S_OK;
|
return result == S_OK;
|
||||||
|
@ -236,8 +236,8 @@ bool WASAPIStream::SetRunning(bool running)
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
{
|
{
|
||||||
ERROR_LOG(AUDIO, "Can't find device '%s', falling back to default",
|
ERROR_LOG_FMT(AUDIO, "Can't find device '{}', falling back to default",
|
||||||
SConfig::GetInstance().sWASAPIDevice.c_str());
|
SConfig::GetInstance().sWASAPIDevice);
|
||||||
result = m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
|
result = m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ bool WASAPIStream::SetRunning(bool running)
|
||||||
|
|
||||||
device_properties->GetValue(PKEY_Device_FriendlyName, &device_name);
|
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);
|
PropVariantClear(&device_name);
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ bool WASAPIStream::SetRunning(bool running)
|
||||||
result = m_audio_client->GetDevicePeriod(nullptr, &device_period);
|
result = m_audio_client->GetDevicePeriod(nullptr, &device_period);
|
||||||
|
|
||||||
device_period += SConfig::GetInstance().iLatency * (10000 / m_format.Format.nChannels);
|
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))
|
if (!HandleWinAPI("Failed to obtain device period", result))
|
||||||
{
|
{
|
||||||
|
@ -384,7 +384,7 @@ bool WASAPIStream::SetRunning(bool running)
|
||||||
|
|
||||||
device->Release();
|
device->Release();
|
||||||
|
|
||||||
INFO_LOG(AUDIO, "WASAPI: Successfully initialized!");
|
INFO_LOG_FMT(AUDIO, "WASAPI: Successfully initialized!");
|
||||||
|
|
||||||
m_running = true;
|
m_running = true;
|
||||||
m_thread = std::thread([this] { SoundLoop(); });
|
m_thread = std::thread([this] { SoundLoop(); });
|
||||||
|
|
Loading…
Reference in New Issue