1
0
mirror of https://github.com/citra-emu/citra.git synced 2024-12-21 07:00:08 +00:00

Merge pull request from daniellimws/audio-core-fmt

audio_core: Migrate logging macros
This commit is contained in:
Weiyi Wang 2018-03-27 13:55:24 +03:00 committed by GitHub
commit 4bdf2e1eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 67 deletions

View File

@ -84,21 +84,21 @@ std::vector<u8> DspHle::Impl::PipeRead(DspPipe pipe_number, u32 length) {
const size_t pipe_index = static_cast<size_t>(pipe_number);
if (pipe_index >= num_dsp_pipe) {
LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index);
NGLOG_ERROR(Audio_DSP, "pipe_number = {} invalid", pipe_index);
return {};
}
if (length > UINT16_MAX) { // Can only read at most UINT16_MAX from the pipe
LOG_ERROR(Audio_DSP, "length of %u greater than max of %u", length, UINT16_MAX);
NGLOG_ERROR(Audio_DSP, "length of {} greater than max of {}", length, UINT16_MAX);
return {};
}
std::vector<u8>& data = pipe_data[pipe_index];
if (length > data.size()) {
LOG_WARNING(
NGLOG_WARNING(
Audio_DSP,
"pipe_number = %zu is out of data, application requested read of %u but %zu remain",
"pipe_number = {} is out of data, application requested read of {} but {} remain",
pipe_index, length, data.size());
length = static_cast<u32>(data.size());
}
@ -115,7 +115,7 @@ size_t DspHle::Impl::GetPipeReadableSize(DspPipe pipe_number) const {
const size_t pipe_index = static_cast<size_t>(pipe_number);
if (pipe_index >= num_dsp_pipe) {
LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index);
NGLOG_ERROR(Audio_DSP, "pipe_number = {} invalid", pipe_index);
return 0;
}
@ -126,7 +126,7 @@ void DspHle::Impl::PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer)
switch (pipe_number) {
case DspPipe::Audio: {
if (buffer.size() != 4) {
LOG_ERROR(Audio_DSP, "DspPipe::Audio: Unexpected buffer length %zu was written",
NGLOG_ERROR(Audio_DSP, "DspPipe::Audio: Unexpected buffer length {} was written",
buffer.size());
return;
}
@ -146,29 +146,29 @@ void DspHle::Impl::PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer)
switch (static_cast<StateChange>(buffer[0])) {
case StateChange::Initialize:
LOG_INFO(Audio_DSP, "Application has requested initialization of DSP hardware");
NGLOG_INFO(Audio_DSP, "Application has requested initialization of DSP hardware");
ResetPipes();
AudioPipeWriteStructAddresses();
dsp_state = DspState::On;
break;
case StateChange::Shutdown:
LOG_INFO(Audio_DSP, "Application has requested shutdown of DSP hardware");
NGLOG_INFO(Audio_DSP, "Application has requested shutdown of DSP hardware");
dsp_state = DspState::Off;
break;
case StateChange::Wakeup:
LOG_INFO(Audio_DSP, "Application has requested wakeup of DSP hardware");
NGLOG_INFO(Audio_DSP, "Application has requested wakeup of DSP hardware");
ResetPipes();
AudioPipeWriteStructAddresses();
dsp_state = DspState::On;
break;
case StateChange::Sleep:
LOG_INFO(Audio_DSP, "Application has requested sleep of DSP hardware");
NGLOG_INFO(Audio_DSP, "Application has requested sleep of DSP hardware");
UNIMPLEMENTED();
dsp_state = DspState::Sleeping;
break;
default:
LOG_ERROR(Audio_DSP,
"Application has requested unknown state transition of DSP hardware %hhu",
NGLOG_ERROR(Audio_DSP,
"Application has requested unknown state transition of DSP hardware {}",
buffer[0]);
dsp_state = DspState::Off;
break;
@ -177,7 +177,7 @@ void DspHle::Impl::PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer)
return;
}
default:
LOG_CRITICAL(Audio_DSP, "pipe_number = %zu unimplemented",
NGLOG_CRITICAL(Audio_DSP, "pipe_number = {} unimplemented",
static_cast<size_t>(pipe_number));
UNIMPLEMENTED();
return;

View File

@ -38,37 +38,37 @@ void Mixers::ParseConfig(DspConfiguration& config) {
if (config.mixer1_enabled_dirty) {
config.mixer1_enabled_dirty.Assign(0);
state.mixer1_enabled = config.mixer1_enabled != 0;
LOG_TRACE(Audio_DSP, "mixers mixer1_enabled = %hu", config.mixer1_enabled);
NGLOG_TRACE(Audio_DSP, "mixers mixer1_enabled = {}", config.mixer1_enabled);
}
if (config.mixer2_enabled_dirty) {
config.mixer2_enabled_dirty.Assign(0);
state.mixer2_enabled = config.mixer2_enabled != 0;
LOG_TRACE(Audio_DSP, "mixers mixer2_enabled = %hu", config.mixer2_enabled);
NGLOG_TRACE(Audio_DSP, "mixers mixer2_enabled = {}", config.mixer2_enabled);
}
if (config.volume_0_dirty) {
config.volume_0_dirty.Assign(0);
state.intermediate_mixer_volume[0] = config.volume[0];
LOG_TRACE(Audio_DSP, "mixers volume[0] = %f", config.volume[0]);
NGLOG_TRACE(Audio_DSP, "mixers volume[0] = {}", config.volume[0]);
}
if (config.volume_1_dirty) {
config.volume_1_dirty.Assign(0);
state.intermediate_mixer_volume[1] = config.volume[1];
LOG_TRACE(Audio_DSP, "mixers volume[1] = %f", config.volume[1]);
NGLOG_TRACE(Audio_DSP, "mixers volume[1] = {}", config.volume[1]);
}
if (config.volume_2_dirty) {
config.volume_2_dirty.Assign(0);
state.intermediate_mixer_volume[2] = config.volume[2];
LOG_TRACE(Audio_DSP, "mixers volume[2] = %f", config.volume[2]);
NGLOG_TRACE(Audio_DSP, "mixers volume[2] = {}", config.volume[2]);
}
if (config.output_format_dirty) {
config.output_format_dirty.Assign(0);
state.output_format = config.output_format;
LOG_TRACE(Audio_DSP, "mixers output_format = %zu",
NGLOG_TRACE(Audio_DSP, "mixers output_format = {}",
static_cast<size_t>(config.output_format));
}
@ -76,11 +76,11 @@ void Mixers::ParseConfig(DspConfiguration& config) {
config.headphones_connected_dirty.Assign(0);
// Do nothing. (Note: Whether headphones are connected does affect coefficients used for
// surround sound.)
LOG_TRACE(Audio_DSP, "mixers headphones_connected=%hu", config.headphones_connected);
NGLOG_TRACE(Audio_DSP, "mixers headphones_connected={}", config.headphones_connected);
}
if (config.dirty_raw) {
LOG_DEBUG(Audio_DSP, "mixers remaining_dirty=%x", config.dirty_raw);
NGLOG_DEBUG(Audio_DSP, "mixers remaining_dirty={:x}", config.dirty_raw);
}
config.dirty_raw = 0;
@ -132,7 +132,7 @@ void Mixers::DownmixAndMixIntoCurrentFrame(float gain, const QuadFrame32& sample
return;
}
UNREACHABLE_MSG("Invalid output_format %zu", static_cast<size_t>(state.output_format));
UNREACHABLE_MSG("Invalid output_format {}", static_cast<size_t>(state.output_format));
}
void Mixers::AuxReturn(const IntermediateMixSamples& read_samples) {

View File

@ -54,34 +54,34 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
if (config.reset_flag) {
config.reset_flag.Assign(0);
Reset();
LOG_TRACE(Audio_DSP, "source_id=%zu reset", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} reset", source_id);
}
if (config.partial_reset_flag) {
config.partial_reset_flag.Assign(0);
state.input_queue = std::priority_queue<Buffer, std::vector<Buffer>, BufferOrder>{};
LOG_TRACE(Audio_DSP, "source_id=%zu partial_reset", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} partial_reset", source_id);
}
if (config.enable_dirty) {
config.enable_dirty.Assign(0);
state.enabled = config.enable != 0;
LOG_TRACE(Audio_DSP, "source_id=%zu enable=%d", source_id, state.enabled);
NGLOG_TRACE(Audio_DSP, "source_id={} enable={}", source_id, state.enabled);
}
if (config.sync_dirty) {
config.sync_dirty.Assign(0);
state.sync = config.sync;
LOG_TRACE(Audio_DSP, "source_id=%zu sync=%u", source_id, state.sync);
NGLOG_TRACE(Audio_DSP, "source_id={} sync={}", source_id, state.sync);
}
if (config.rate_multiplier_dirty) {
config.rate_multiplier_dirty.Assign(0);
state.rate_multiplier = config.rate_multiplier;
LOG_TRACE(Audio_DSP, "source_id=%zu rate=%f", source_id, state.rate_multiplier);
NGLOG_TRACE(Audio_DSP, "source_id={} rate={}", source_id, state.rate_multiplier);
if (state.rate_multiplier <= 0) {
LOG_ERROR(Audio_DSP, "Was given an invalid rate multiplier: source_id=%zu rate=%f",
NGLOG_ERROR(Audio_DSP, "Was given an invalid rate multiplier: source_id={} rate={}",
source_id, state.rate_multiplier);
state.rate_multiplier = 1.0f;
// Note: Actual firmware starts producing garbage if this occurs.
@ -93,68 +93,68 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
std::transform(adpcm_coeffs, adpcm_coeffs + state.adpcm_coeffs.size(),
state.adpcm_coeffs.begin(),
[](const auto& coeff) { return static_cast<s16>(coeff); });
LOG_TRACE(Audio_DSP, "source_id=%zu adpcm update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} adpcm update", source_id);
}
if (config.gain_0_dirty) {
config.gain_0_dirty.Assign(0);
std::transform(config.gain[0], config.gain[0] + state.gain[0].size(), state.gain[0].begin(),
[](const auto& coeff) { return static_cast<float>(coeff); });
LOG_TRACE(Audio_DSP, "source_id=%zu gain 0 update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} gain 0 update", source_id);
}
if (config.gain_1_dirty) {
config.gain_1_dirty.Assign(0);
std::transform(config.gain[1], config.gain[1] + state.gain[1].size(), state.gain[1].begin(),
[](const auto& coeff) { return static_cast<float>(coeff); });
LOG_TRACE(Audio_DSP, "source_id=%zu gain 1 update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} gain 1 update", source_id);
}
if (config.gain_2_dirty) {
config.gain_2_dirty.Assign(0);
std::transform(config.gain[2], config.gain[2] + state.gain[2].size(), state.gain[2].begin(),
[](const auto& coeff) { return static_cast<float>(coeff); });
LOG_TRACE(Audio_DSP, "source_id=%zu gain 2 update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} gain 2 update", source_id);
}
if (config.filters_enabled_dirty) {
config.filters_enabled_dirty.Assign(0);
state.filters.Enable(config.simple_filter_enabled.ToBool(),
config.biquad_filter_enabled.ToBool());
LOG_TRACE(Audio_DSP, "source_id=%zu enable_simple=%hu enable_biquad=%hu", source_id,
NGLOG_TRACE(Audio_DSP, "source_id={} enable_simple={} enable_biquad={}", source_id,
config.simple_filter_enabled.Value(), config.biquad_filter_enabled.Value());
}
if (config.simple_filter_dirty) {
config.simple_filter_dirty.Assign(0);
state.filters.Configure(config.simple_filter);
LOG_TRACE(Audio_DSP, "source_id=%zu simple filter update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} simple filter update", source_id);
}
if (config.biquad_filter_dirty) {
config.biquad_filter_dirty.Assign(0);
state.filters.Configure(config.biquad_filter);
LOG_TRACE(Audio_DSP, "source_id=%zu biquad filter update", source_id);
NGLOG_TRACE(Audio_DSP, "source_id={} biquad filter update", source_id);
}
if (config.interpolation_dirty) {
config.interpolation_dirty.Assign(0);
state.interpolation_mode = config.interpolation_mode;
LOG_TRACE(Audio_DSP, "source_id=%zu interpolation_mode=%zu", source_id,
NGLOG_TRACE(Audio_DSP, "source_id={} interpolation_mode={}", source_id,
static_cast<size_t>(state.interpolation_mode));
}
if (config.format_dirty || config.embedded_buffer_dirty) {
config.format_dirty.Assign(0);
state.format = config.format;
LOG_TRACE(Audio_DSP, "source_id=%zu format=%zu", source_id,
NGLOG_TRACE(Audio_DSP, "source_id={} format={}", source_id,
static_cast<size_t>(state.format));
}
if (config.mono_or_stereo_dirty || config.embedded_buffer_dirty) {
config.mono_or_stereo_dirty.Assign(0);
state.mono_or_stereo = config.mono_or_stereo;
LOG_TRACE(Audio_DSP, "source_id=%zu mono_or_stereo=%zu", source_id,
NGLOG_TRACE(Audio_DSP, "source_id={} mono_or_stereo={}", source_id,
static_cast<size_t>(state.mono_or_stereo));
}
@ -182,14 +182,14 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
play_position,
false,
});
LOG_TRACE(Audio_DSP, "enqueuing embedded addr=0x%08x len=%u id=%hu start=%u",
NGLOG_TRACE(Audio_DSP, "enqueuing embedded addr={:#010x} len={} id={} start={}",
config.physical_address, config.length, config.buffer_id,
static_cast<u32>(config.play_position));
}
if (config.loop_related_dirty && config.loop_related != 0) {
config.loop_related_dirty.Assign(0);
LOG_WARNING(Audio_DSP, "Unhandled complex loop with loop_related=0x%08x",
NGLOG_WARNING(Audio_DSP, "Unhandled complex loop with loop_related={:#010x}",
static_cast<u32>(config.loop_related));
}
@ -212,7 +212,7 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
{}, // 0 in u32_dsp
false,
});
LOG_TRACE(Audio_DSP, "enqueuing queued %zu addr=0x%08x len=%u id=%hu", i,
NGLOG_TRACE(Audio_DSP, "enqueuing queued {} addr={:#010x} len={} id={}", i,
b.physical_address, b.length, b.buffer_id);
}
}
@ -220,7 +220,7 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config,
}
if (config.dirty_raw) {
LOG_DEBUG(Audio_DSP, "source_id=%zu remaining_dirty=%x", source_id, config.dirty_raw);
NGLOG_DEBUG(Audio_DSP, "source_id={} remaining_dirty={:x}", source_id, config.dirty_raw);
}
config.dirty_raw = 0;
@ -255,7 +255,7 @@ void Source::GenerateFrame() {
break;
case InterpolationMode::Polyphase:
// TODO(merry): Implement polyphase interpolation
LOG_DEBUG(Audio_DSP, "Polyphase interpolation unimplemented; falling back to linear");
NGLOG_DEBUG(Audio_DSP, "Polyphase interpolation unimplemented; falling back to linear");
AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier,
current_frame, frame_position);
break;
@ -304,8 +304,8 @@ bool Source::DequeueBuffer() {
break;
}
} else {
LOG_WARNING(Audio_DSP,
"source_id=%zu buffer_id=%hu length=%u: Invalid physical address 0x%08X",
NGLOG_WARNING(Audio_DSP,
"source_id={} buffer_id={} length={}: Invalid physical address {:#010x}",
source_id, buf.buffer_id, buf.length, buf.physical_address);
state.current_buffer.clear();
return true;
@ -322,9 +322,8 @@ bool Source::DequeueBuffer() {
state.input_queue.push(buf);
}
LOG_TRACE(Audio_DSP, "source_id=%zu buffer_id=%hu from_queue=%s current_buffer.size()=%zu",
source_id, buf.buffer_id, buf.from_queue ? "true" : "false",
state.current_buffer.size());
NGLOG_TRACE(Audio_DSP, "source_id={} buffer_id={} from_queue={} current_buffer.size()={}",
source_id, buf.buffer_id, buf.from_queue, state.current_buffer.size());
return true;
}

View File

@ -25,7 +25,7 @@ struct SDL2Sink::Impl {
SDL2Sink::SDL2Sink() : impl(std::make_unique<Impl>()) {
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
LOG_CRITICAL(Audio_Sink, "SDL_Init(SDL_INIT_AUDIO) failed with: %s", SDL_GetError());
NGLOG_CRITICAL(Audio_Sink, "SDL_Init(SDL_INIT_AUDIO) failed with: {}", SDL_GetError());
impl->audio_device_id = 0;
return;
}
@ -58,8 +58,8 @@ SDL2Sink::SDL2Sink() : impl(std::make_unique<Impl>()) {
impl->audio_device_id = SDL_OpenAudioDevice(
device, false, &desired_audiospec, &obtained_audiospec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
if (impl->audio_device_id <= 0) {
LOG_CRITICAL(Audio_Sink, "SDL_OpenAudioDevice failed with code %d for device \"%s\"",
impl->audio_device_id, Settings::values.audio_device_id.c_str());
NGLOG_CRITICAL(Audio_Sink, "SDL_OpenAudioDevice failed with code {} for device \"{}\"",
impl->audio_device_id, Settings::values.audio_device_id);
return;
}

View File

@ -30,7 +30,7 @@ const SinkDetails& GetSinkDetails(std::string sink_id) {
if (sink_id == "auto" || iter == g_sink_details.end()) {
if (sink_id != "auto") {
LOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id %s", sink_id.c_str());
NGLOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id {}", sink_id);
}
// Auto-select.
// g_sink_details is ordered in terms of desirability, with the best choice at the front.

View File

@ -55,7 +55,7 @@ std::vector<s16> TimeStretcher::Process(size_t samples_in_queue) {
std::vector<s16> samples = GetSamples();
if (samples_in_queue >= DROP_FRAMES_SAMPLE_DELAY) {
samples.clear();
LOG_DEBUG(Audio, "Dropping frames!");
NGLOG_DEBUG(Audio, "Dropping frames!");
}
return samples;
}