[XMA] Fix dedicated thread stalls by blocking guest audio thread
Includes various other thread safety and timing related adjustments
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/memory.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
@@ -212,11 +213,28 @@ class XmaContext {
|
||||
|
||||
uint32_t id() { return id_; }
|
||||
uint32_t guest_ptr() { return guest_ptr_; }
|
||||
bool is_allocated() { return is_allocated_; }
|
||||
bool is_enabled() { return is_enabled_; }
|
||||
bool is_allocated() { return is_allocated_.load(std::memory_order_acquire); }
|
||||
bool is_enabled() { return is_enabled_.load(std::memory_order_acquire); }
|
||||
|
||||
void set_is_allocated(bool is_allocated) { is_allocated_ = is_allocated; }
|
||||
void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; }
|
||||
void set_is_allocated(bool is_allocated) {
|
||||
is_allocated_.store(is_allocated, std::memory_order_release);
|
||||
}
|
||||
void set_is_enabled(bool is_enabled) {
|
||||
is_enabled_.store(is_enabled, std::memory_order_release);
|
||||
}
|
||||
|
||||
// Signals that the worker has finished processing this context after a kick.
|
||||
void SignalWorkDone() {
|
||||
if (work_completion_event_) {
|
||||
work_completion_event_->Set();
|
||||
}
|
||||
}
|
||||
// Blocks until the worker has finished processing this context.
|
||||
void WaitForWorkDone() {
|
||||
if (work_completion_event_) {
|
||||
xe::threading::Wait(work_completion_event_.get(), false);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
static void DumpRaw(AVFrame* frame, int id);
|
||||
@@ -229,8 +247,9 @@ class XmaContext {
|
||||
uint32_t id_ = 0;
|
||||
uint32_t guest_ptr_ = 0;
|
||||
xe_mutex lock_;
|
||||
volatile bool is_allocated_ = false;
|
||||
volatile bool is_enabled_ = false;
|
||||
std::atomic<bool> is_allocated_ = false;
|
||||
std::atomic<bool> is_enabled_ = false;
|
||||
std::unique_ptr<xe::threading::Event> work_completion_event_;
|
||||
|
||||
// ffmpeg structures
|
||||
AVPacket* av_packet_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user