Inefficient, but pumping audio.
This commit is contained in:
parent
ab9d384813
commit
4f552da6c4
|
@ -23,7 +23,7 @@ using namespace xe::cpu;
|
||||||
AudioSystem::AudioSystem(Emulator* emulator) :
|
AudioSystem::AudioSystem(Emulator* emulator) :
|
||||||
emulator_(emulator), memory_(emulator->memory()),
|
emulator_(emulator), memory_(emulator->memory()),
|
||||||
thread_(0), running_(false), driver_(0),
|
thread_(0), running_(false), driver_(0),
|
||||||
client_({ 0 }) {
|
client_({ 0 }), can_submit_(false) {
|
||||||
// Create the run loop used for any windows/etc.
|
// Create the run loop used for any windows/etc.
|
||||||
// This must be done on the thread we create the driver.
|
// This must be done on the thread we create the driver.
|
||||||
run_loop_ = xe_run_loop_create();
|
run_loop_ = xe_run_loop_create();
|
||||||
|
@ -87,11 +87,13 @@ void AudioSystem::ThreadStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pump worker.
|
// Pump worker.
|
||||||
|
Pump();
|
||||||
|
|
||||||
xe_mutex_lock(lock_);
|
xe_mutex_lock(lock_);
|
||||||
uint32_t client_callback = client_.callback;
|
uint32_t client_callback = client_.callback;
|
||||||
uint32_t client_callback_arg = client_.wrapped_callback_arg;
|
uint32_t client_callback_arg = client_.wrapped_callback_arg;
|
||||||
xe_mutex_unlock(lock_);
|
xe_mutex_unlock(lock_);
|
||||||
if (client_callback) {
|
if (client_callback && can_submit_) {
|
||||||
processor->Execute(
|
processor->Execute(
|
||||||
thread_state_, client_callback, client_callback_arg, 0);
|
thread_state_, client_callback, client_callback_arg, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -84,6 +84,7 @@ protected:
|
||||||
uint32_t callback_arg;
|
uint32_t callback_arg;
|
||||||
uint32_t wrapped_callback_arg;
|
uint32_t wrapped_callback_arg;
|
||||||
} client_;
|
} client_;
|
||||||
|
bool can_submit_;
|
||||||
|
|
||||||
AudioDriver* driver_;
|
AudioDriver* driver_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,7 +67,14 @@ void XAudio2AudioSystem::Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XAudio2AudioSystem::Pump() {
|
void XAudio2AudioSystem::Pump() {
|
||||||
//
|
XAUDIO2_VOICE_STATE state;
|
||||||
|
pcm_voice_->GetState(&state);
|
||||||
|
auto n = state.BuffersQueued;
|
||||||
|
if (n > 30) {
|
||||||
|
can_submit_ = false;
|
||||||
|
} else {
|
||||||
|
can_submit_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XAudio2AudioSystem::SubmitFrame(uint32_t samples_ptr) {
|
void XAudio2AudioSystem::SubmitFrame(uint32_t samples_ptr) {
|
||||||
|
|
Loading…
Reference in New Issue