From 23ae1b6297bfc540504c944db263f30d4976d8ee Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Thu, 4 Jun 2015 02:10:56 -0500 Subject: [PATCH] Hookup libav logging --- src/xenia/apu/audio_system.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/xenia/apu/audio_system.cc b/src/xenia/apu/audio_system.cc index 2bcfcfbf0..ffd2d43c7 100644 --- a/src/xenia/apu/audio_system.cc +++ b/src/xenia/apu/audio_system.cc @@ -14,12 +14,17 @@ #include "xenia/base/logging.h" #include "xenia/base/math.h" #include "xenia/base/ring_buffer.h" +#include "xenia/base/string_buffer.h" #include "xenia/cpu/processor.h" #include "xenia/cpu/thread_state.h" #include "xenia/emulator.h" #include "xenia/kernel/objects/xthread.h" #include "xenia/profiling.h" +extern "C" { +#include "libavutil/log.h" +} + // As with normal Microsoft, there are like twelve different ways to access // the audio APIs. Early games use XMA*() methods almost exclusively to touch // decoders. Later games use XAudio*() and direct memory writes to the XMA @@ -76,6 +81,13 @@ AudioSystem::~AudioSystem() { } } +void av_log_callback(void *avcl, int level, const char *fmt, va_list va) { + StringBuffer buff; + buff.AppendVarargs(fmt, va); + + xe::log_line(__FILE__, __LINE__, 'i', "libav: %s", buff.GetString()); +} + X_STATUS AudioSystem::Setup() { processor_ = emulator_->processor(); @@ -107,6 +119,9 @@ X_STATUS AudioSystem::Setup() { } registers_.next_context = 1; + // Setup libav logging callback + av_log_set_callback(av_log_callback); + worker_running_ = true; worker_thread_ = kernel::object_ref(new kernel::XHostThread( @@ -569,7 +584,6 @@ void AudioSystem::WriteRegister(uint32_t addr, uint64_t value) { // Reset valid flags so our audio decoder knows to process this one. data.input_buffer_0_valid = data.input_buffer_0_ptr != 0; data.input_buffer_1_valid = data.input_buffer_1_ptr != 0; - //data.output_buffer_write_offset = 0; data.Store(context_ptr); @@ -614,7 +628,9 @@ void AudioSystem::WriteRegister(uint32_t addr, uint64_t value) { data.input_buffer_0_valid = 0; data.input_buffer_1_valid = 0; data.output_buffer_valid = 0; - data.output_buffer_read_offset = 31; + + data.output_buffer_read_offset = 0; + data.output_buffer_write_offset = 0; data.Store(context_ptr); context.lock.unlock();