Removing xe_thread_t.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <xenia/apu/audio_system.h>
|
||||
#include <xenia/apu/audio_driver.h>
|
||||
|
||||
#include <poly/threading.h>
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/cpu/processor.h>
|
||||
#include <xenia/cpu/xenon_thread_state.h>
|
||||
@@ -22,7 +23,7 @@ using namespace xe::cpu;
|
||||
|
||||
AudioSystem::AudioSystem(Emulator* emulator) :
|
||||
emulator_(emulator), memory_(emulator->memory()),
|
||||
thread_(0), running_(false) {
|
||||
running_(false) {
|
||||
memset(clients_, 0, sizeof(clients_));
|
||||
for (size_t i = 0; i < maximum_client_count_; ++i) {
|
||||
client_wait_handles_[i] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
@@ -61,15 +62,15 @@ X_STATUS AudioSystem::Setup() {
|
||||
// Init needs to happen there so that any thread-local stuff
|
||||
// is created on the right thread.
|
||||
running_ = true;
|
||||
thread_ = xe_thread_create(
|
||||
"AudioSystem",
|
||||
(xe_thread_callback)ThreadStartThunk, this);
|
||||
xe_thread_start(thread_);
|
||||
thread_ = std::thread(std::bind(&AudioSystem::ThreadStart, this));
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void AudioSystem::ThreadStart() {
|
||||
poly::threading::set_name("AudioSystemThread");
|
||||
xe::Profiler::ThreadEnter("AudioSystemThread");
|
||||
|
||||
// Initialize driver and ringbuffer.
|
||||
Initialize();
|
||||
|
||||
@@ -113,6 +114,8 @@ void AudioSystem::ThreadStart() {
|
||||
running_ = false;
|
||||
|
||||
// TODO(benvanik): call module API to kill?
|
||||
|
||||
xe::Profiler::ThreadExit();
|
||||
}
|
||||
|
||||
void AudioSystem::Initialize() {
|
||||
@@ -120,8 +123,7 @@ void AudioSystem::Initialize() {
|
||||
|
||||
void AudioSystem::Shutdown() {
|
||||
running_ = false;
|
||||
xe_thread_join(thread_);
|
||||
xe_thread_release(thread_);
|
||||
thread_.join();
|
||||
|
||||
delete thread_state_;
|
||||
memory()->HeapFree(thread_block_, 0);
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#ifndef XENIA_APU_AUDIO_SYSTEM_H_
|
||||
#define XENIA_APU_AUDIO_SYSTEM_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
|
||||
#include <xenia/core.h>
|
||||
#include <xenia/xbox.h>
|
||||
@@ -50,9 +52,6 @@ protected:
|
||||
virtual void Initialize();
|
||||
|
||||
private:
|
||||
static void ThreadStartThunk(AudioSystem* this_ptr) {
|
||||
this_ptr->ThreadStart();
|
||||
}
|
||||
void ThreadStart();
|
||||
|
||||
static uint64_t MMIOReadRegisterThunk(AudioSystem* as, uint64_t addr) {
|
||||
@@ -70,10 +69,10 @@ protected:
|
||||
Memory* memory_;
|
||||
cpu::Processor* processor_;
|
||||
|
||||
xe_thread_ref thread_;
|
||||
std::thread thread_;
|
||||
cpu::XenonThreadState* thread_state_;
|
||||
uint32_t thread_block_;
|
||||
bool running_;
|
||||
std::atomic<bool> running_;
|
||||
|
||||
std::mutex lock_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user