Minor audio tweeks + profiling.
This commit is contained in:
parent
db3d8fdc87
commit
a93325434a
|
@ -103,8 +103,6 @@ X_STATUS AudioSystem::Setup() {
|
||||||
}
|
}
|
||||||
registers_.next_context = 1;
|
registers_.next_context = 1;
|
||||||
|
|
||||||
// Threads
|
|
||||||
|
|
||||||
worker_running_ = true;
|
worker_running_ = true;
|
||||||
worker_thread_ =
|
worker_thread_ =
|
||||||
kernel::object_ref<kernel::XHostThread>(new kernel::XHostThread(
|
kernel::object_ref<kernel::XHostThread>(new kernel::XHostThread(
|
||||||
|
@ -366,10 +364,29 @@ void AudioSystem::ReleaseXmaContext(uint32_t guest_ptr) {
|
||||||
context.decoder->DiscardPacket();
|
context.decoder->DiscardPacket();
|
||||||
|
|
||||||
context.lock.unlock();
|
context.lock.unlock();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioSystem::BlockOnXmaContext(uint32_t guest_ptr, bool poll) {
|
||||||
|
std::lock_guard<xe::mutex> lock(lock_);
|
||||||
|
for (uint32_t n = 0; n < kXmaContextCount; n++) {
|
||||||
|
XMAContext& context = xma_context_array_[n];
|
||||||
|
if (context.guest_ptr == guest_ptr) {
|
||||||
|
if (!context.lock.try_lock()) {
|
||||||
|
if (poll) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
context.lock.lock();
|
||||||
|
}
|
||||||
|
context.lock.unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
X_STATUS AudioSystem::RegisterClient(uint32_t callback, uint32_t callback_arg,
|
X_STATUS AudioSystem::RegisterClient(uint32_t callback, uint32_t callback_arg,
|
||||||
size_t* out_index) {
|
size_t* out_index) {
|
||||||
assert_true(unused_clients_.size());
|
assert_true(unused_clients_.size());
|
||||||
|
@ -450,6 +467,8 @@ uint64_t AudioSystem::ReadRegister(uint32_t addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioSystem::WriteRegister(uint32_t addr, uint64_t value) {
|
void AudioSystem::WriteRegister(uint32_t addr, uint64_t value) {
|
||||||
|
SCOPE_profile_cpu_f("apu");
|
||||||
|
|
||||||
uint32_t r = addr & 0xFFFF;
|
uint32_t r = addr & 0xFFFF;
|
||||||
value = xe::byte_swap(uint32_t(value));
|
value = xe::byte_swap(uint32_t(value));
|
||||||
XELOGAPU("WriteRegister(%.4X, %.8X)", r, value);
|
XELOGAPU("WriteRegister(%.4X, %.8X)", r, value);
|
||||||
|
@ -486,12 +505,12 @@ void AudioSystem::WriteRegister(uint32_t addr, uint64_t value) {
|
||||||
|
|
||||||
data.Store(context_ptr);
|
data.Store(context_ptr);
|
||||||
context.lock.unlock();
|
context.lock.unlock();
|
||||||
|
|
||||||
// Signal the decoder thread
|
|
||||||
decoder_fence_.Signal();
|
|
||||||
}
|
}
|
||||||
value >>= 1;
|
value >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Signal the decoder thread to start processing.
|
||||||
|
decoder_fence_.Signal();
|
||||||
} else if (r >= 0x1A40 && r <= 0x1A40 + 9 * 4) {
|
} else if (r >= 0x1A40 && r <= 0x1A40 + 9 * 4) {
|
||||||
// Context lock command.
|
// Context lock command.
|
||||||
// This requests a lock by flagging the context.
|
// This requests a lock by flagging the context.
|
||||||
|
|
|
@ -126,6 +126,7 @@ class AudioSystem {
|
||||||
}
|
}
|
||||||
uint32_t AllocateXmaContext();
|
uint32_t AllocateXmaContext();
|
||||||
void ReleaseXmaContext(uint32_t guest_ptr);
|
void ReleaseXmaContext(uint32_t guest_ptr);
|
||||||
|
bool BlockOnXmaContext(uint32_t guest_ptr, bool poll);
|
||||||
|
|
||||||
X_STATUS RegisterClient(uint32_t callback, uint32_t callback_arg,
|
X_STATUS RegisterClient(uint32_t callback, uint32_t callback_arg,
|
||||||
size_t* out_index);
|
size_t* out_index);
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include "xenia/profiling.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
void CrashDump();
|
void CrashDump();
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
@ -61,6 +63,8 @@ WinMMIOHandler::~WinMMIOHandler() {
|
||||||
// addresses in our range and call into the registered handlers, if any.
|
// addresses in our range and call into the registered handlers, if any.
|
||||||
// If there are none, we continue.
|
// If there are none, we continue.
|
||||||
LONG CALLBACK MMIOExceptionHandler(PEXCEPTION_POINTERS ex_info) {
|
LONG CALLBACK MMIOExceptionHandler(PEXCEPTION_POINTERS ex_info) {
|
||||||
|
SCOPE_profile_cpu_i("cpu", "MMIOExceptionHandler");
|
||||||
|
|
||||||
// http://msdn.microsoft.com/en-us/library/ms679331(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/ms679331(v=vs.85).aspx
|
||||||
// http://msdn.microsoft.com/en-us/library/aa363082(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/aa363082(v=vs.85).aspx
|
||||||
auto code = ex_info->ExceptionRecord->ExceptionCode;
|
auto code = ex_info->ExceptionRecord->ExceptionCode;
|
||||||
|
|
|
@ -87,8 +87,7 @@ void StoreXmaContextIndexedRegister(KernelState* state, uint32_t base_reg,
|
||||||
XMAContextData::kSize;
|
XMAContextData::kSize;
|
||||||
uint32_t reg_num = base_reg + (hw_index >> 5) * 4;
|
uint32_t reg_num = base_reg + (hw_index >> 5) * 4;
|
||||||
uint32_t reg_value = 1 << (hw_index & 0x1F);
|
uint32_t reg_value = 1 << (hw_index & 0x1F);
|
||||||
xe::store<uint32_t>(state->memory()->TranslateVirtual(0x7FEA0000 + reg_num),
|
audio_system->WriteRegister(reg_num, xe::byte_swap(reg_value));
|
||||||
reg_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIM_CALL XMAInitializeContext_shim(PPCContext* ppc_state, KernelState* state) {
|
SHIM_CALL XMAInitializeContext_shim(PPCContext* ppc_state, KernelState* state) {
|
||||||
|
@ -372,7 +371,9 @@ SHIM_CALL XMADisableContext_shim(PPCContext* ppc_state, KernelState* state) {
|
||||||
|
|
||||||
X_HRESULT result = X_E_SUCCESS;
|
X_HRESULT result = X_E_SUCCESS;
|
||||||
StoreXmaContextIndexedRegister(state, 0x1A40, context_ptr);
|
StoreXmaContextIndexedRegister(state, 0x1A40, context_ptr);
|
||||||
XMAContextData context(SHIM_MEM_ADDR(context_ptr));
|
if (!state->emulator()->audio_system()->BlockOnXmaContext(context_ptr, !wait)) {
|
||||||
|
result = X_E_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
SHIM_SET_RETURN_32(result);
|
SHIM_SET_RETURN_32(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue