Starting work on audio.
This commit is contained in:
@@ -25,9 +25,12 @@ AudioSystem::AudioSystem(Emulator* emulator) :
|
||||
// Create the run loop used for any windows/etc.
|
||||
// This must be done on the thread we create the driver.
|
||||
run_loop_ = xe_run_loop_create();
|
||||
|
||||
lock_ = xe_mutex_alloc();
|
||||
}
|
||||
|
||||
AudioSystem::~AudioSystem() {
|
||||
xe_mutex_free(lock_);
|
||||
}
|
||||
|
||||
X_STATUS AudioSystem::Setup() {
|
||||
@@ -61,6 +64,8 @@ void AudioSystem::ThreadStart() {
|
||||
Initialize();
|
||||
XEASSERTNOTNULL(driver_);
|
||||
|
||||
auto processor = emulator_->processor();
|
||||
|
||||
// Main run loop.
|
||||
while (running_) {
|
||||
// Peek main run loop.
|
||||
@@ -72,6 +77,14 @@ void AudioSystem::ThreadStart() {
|
||||
}
|
||||
|
||||
// Pump worker.
|
||||
// mehhh
|
||||
xe_mutex_lock(lock_);
|
||||
auto clients = clients_;
|
||||
xe_mutex_unlock(lock_);
|
||||
for (auto it = clients.begin(); it != clients.end(); ++it) {
|
||||
processor->ExecuteInterrupt(
|
||||
0, it->callback, it->wrapped_callback_arg, 0);
|
||||
}
|
||||
//worker_->Pump();
|
||||
Sleep(1000);
|
||||
|
||||
@@ -100,6 +113,16 @@ void AudioSystem::Shutdown() {
|
||||
xe_run_loop_release(run_loop_);
|
||||
}
|
||||
|
||||
void AudioSystem::RegisterClient(
|
||||
uint32_t callback, uint32_t callback_arg) {
|
||||
uint32_t ptr = (uint32_t)memory()->HeapAlloc(0, 0x4, 0);
|
||||
auto mem = memory()->membase();
|
||||
XESETUINT32BE(mem + ptr, callback_arg);
|
||||
xe_mutex_lock(lock_);
|
||||
clients_.push_back({ callback, callback_arg, ptr });
|
||||
xe_mutex_unlock(lock_);
|
||||
}
|
||||
|
||||
bool AudioSystem::HandlesRegister(uint64_t addr) {
|
||||
return (addr & 0xFFFF0000) == 0x7FEA0000;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
virtual X_STATUS Setup();
|
||||
virtual void Shutdown();
|
||||
|
||||
void RegisterClient(uint32_t callback, uint32_t callback_arg);
|
||||
//void UnregisterClient();
|
||||
|
||||
bool HandlesRegister(uint64_t addr);
|
||||
virtual uint64_t ReadRegister(uint64_t addr);
|
||||
virtual void WriteRegister(uint64_t addr, uint64_t value);
|
||||
@@ -70,6 +73,14 @@ protected:
|
||||
xe_run_loop_ref run_loop_;
|
||||
xe_thread_ref thread_;
|
||||
bool running_;
|
||||
xe_mutex_t* lock_;
|
||||
|
||||
typedef struct {
|
||||
uint32_t callback;
|
||||
uint32_t callback_arg;
|
||||
uint32_t wrapped_callback_arg;
|
||||
} RenderDriverClient;
|
||||
std::vector<RenderDriverClient> clients_;
|
||||
|
||||
AudioDriver* driver_;
|
||||
};
|
||||
|
||||
@@ -33,6 +33,7 @@ void NopAudioSystem::Initialize() {
|
||||
}
|
||||
|
||||
void NopAudioSystem::Pump() {
|
||||
//
|
||||
}
|
||||
|
||||
void NopAudioSystem::Shutdown() {
|
||||
|
||||
Reference in New Issue
Block a user