Switching audio system to platform-agnostic primitives.

This commit is contained in:
Ben Vanik
2015-07-14 23:13:56 -07:00
parent 345fe60da0
commit a6012b73f4
13 changed files with 150 additions and 165 deletions

View File

@@ -14,11 +14,10 @@
#include <mutex>
#include <queue>
#include "xenia/base/threading.h"
#include "xenia/emulator.h"
#include "xenia/xbox.h"
typedef void* HANDLE;
namespace xe {
namespace kernel {
class XHostThread;
@@ -48,7 +47,15 @@ class AudioSystem {
void UnregisterClient(size_t index);
void SubmitFrame(size_t index, uint32_t samples_ptr);
virtual X_STATUS CreateDriver(size_t index, HANDLE semaphore,
protected:
AudioSystem(Emulator* emulator);
virtual void Initialize();
void WorkerThreadMain();
virtual X_STATUS CreateDriver(size_t index,
xe::threading::Semaphore* semaphore,
AudioDriver** out_driver) = 0;
virtual void DestroyDriver(AudioDriver* driver) = 0;
@@ -56,15 +63,6 @@ class AudioSystem {
// XAUDIO2_MAX_QUEUED_BUFFERS))
static const size_t kMaximumQueuedFrames = 64;
protected:
virtual void Initialize();
private:
void WorkerThreadMain();
protected:
AudioSystem(Emulator* emulator);
Emulator* emulator_;
Memory* memory_;
cpu::Processor* processor_;
@@ -83,9 +81,11 @@ class AudioSystem {
uint32_t wrapped_callback_arg;
} clients_[kMaximumClientCount];
HANDLE client_semaphores_[kMaximumClientCount];
HANDLE shutdown_event_; // Event is always there in case we have no clients.
HANDLE wait_handles_[kMaximumClientCount + 1];
std::unique_ptr<xe::threading::Semaphore>
client_semaphores_[kMaximumClientCount];
// Event is always there in case we have no clients.
std::unique_ptr<xe::threading::Event> shutdown_event_;
xe::threading::WaitHandle* wait_handles_[kMaximumClientCount + 1];
std::queue<size_t> unused_clients_;
};