mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
UWP crashfix - serialize accesses to each loader
This commit is contained in:
parent
a31608e557
commit
93c39f7595
@ -43,7 +43,6 @@ StorageFileLoader::~StorageFileLoader() {
|
||||
void StorageFileLoader::threadfunc() {
|
||||
SetCurrentThreadName("StorageFileLoader");
|
||||
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(initMutex);
|
||||
_assert_(!active_);
|
||||
@ -85,10 +84,10 @@ void StorageFileLoader::threadfunc() {
|
||||
if (operationRequested_) {
|
||||
switch (operation_.type) {
|
||||
case OpType::READ_AT: {
|
||||
Streams::Buffer ^buf = ref new Streams::Buffer(operation_.size);
|
||||
Streams::Buffer ^buf = ref new Streams::Buffer((unsigned int)operation_.size);
|
||||
operationFailed_ = false;
|
||||
stream_->Seek(operation_.offset);
|
||||
auto task = create_task(stream_->ReadAsync(buf, operation_.size, Streams::InputStreamOptions::None));
|
||||
auto task = create_task(stream_->ReadAsync(buf, (unsigned int)operation_.size, Streams::InputStreamOptions::None));
|
||||
Streams::IBuffer ^output = nullptr;
|
||||
try {
|
||||
task.wait();
|
||||
@ -98,8 +97,8 @@ void StorageFileLoader::threadfunc() {
|
||||
const char *what = e.what();
|
||||
INFO_LOG(SYSTEM, "%s", what);
|
||||
}
|
||||
operationRequested_ = false;
|
||||
std::unique_lock<std::mutex> lock(mutexResponse_);
|
||||
operationRequested_ = false;
|
||||
response_.buffer = output;
|
||||
responseAvailable_ = true;
|
||||
condResponse_.notify_one();
|
||||
@ -142,7 +141,11 @@ void StorageFileLoader::EnsureOpen() {
|
||||
}
|
||||
|
||||
size_t StorageFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags) {
|
||||
// We can't handle multiple of these at a time, so serialize the easy way.
|
||||
std::unique_lock<std::mutex> lock(operationMutex_);
|
||||
|
||||
EnsureOpen();
|
||||
|
||||
_assert_(!operationRequested_);
|
||||
_assert_(!responseAvailable_)
|
||||
|
||||
@ -166,6 +169,7 @@ size_t StorageFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, vo
|
||||
if (operationFailed_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DataReader ^rd = DataReader::FromBuffer(response_.buffer);
|
||||
size_t len = response_.buffer->Length;
|
||||
Platform::Array<uint8_t> ^bytearray = ref new Platform::Array<uint8_t>((unsigned int)len);
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
Windows::Storage::Streams::IRandomAccessStreamWithContentType ^stream_;
|
||||
Path path_;
|
||||
|
||||
std::mutex operationMutex_;
|
||||
|
||||
bool operationRequested_ = false;
|
||||
Operation operation_{ OpType::NONE, 0, 0 };
|
||||
std::condition_variable cond_;
|
||||
|
Loading…
Reference in New Issue
Block a user