mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
Misc: use std::lock_guard
Some checks failed
🐧 Linux Builds / AppImage (push) Has been cancelled
🐧 Linux Builds / Flatpak (push) Has been cancelled
🍎 MacOS Builds / Defaults (push) Has been cancelled
🖥️ Windows Builds / Lint VS Project Files (push) Has been cancelled
🖥️ Windows Builds / CMake (push) Has been cancelled
🖥️ Windows Builds / SSE4 (push) Has been cancelled
🖥️ Windows Builds / AVX2 (push) Has been cancelled
🏭 Update Controller Database / update-controller-db (push) Has been cancelled
Some checks failed
🐧 Linux Builds / AppImage (push) Has been cancelled
🐧 Linux Builds / Flatpak (push) Has been cancelled
🍎 MacOS Builds / Defaults (push) Has been cancelled
🖥️ Windows Builds / Lint VS Project Files (push) Has been cancelled
🖥️ Windows Builds / CMake (push) Has been cancelled
🖥️ Windows Builds / SSE4 (push) Has been cancelled
🖥️ Windows Builds / AVX2 (push) Has been cancelled
🏭 Update Controller Database / update-controller-db (push) Has been cancelled
This commit is contained in:
parent
74db386144
commit
9955e07470
@ -153,7 +153,7 @@ void DebuggerSettingsManager::saveGameSettings(QAbstractTableModel* abstractTabl
|
||||
if (path.empty())
|
||||
return;
|
||||
|
||||
const std::lock_guard<std::mutex> lock(writeLock);
|
||||
std::lock_guard<std::mutex> lock(writeLock);
|
||||
QJsonObject loadedSettings = loadGameSettingsJSON();
|
||||
QJsonArray rowsArray;
|
||||
QStringList keys;
|
||||
|
||||
@ -71,7 +71,7 @@ std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view
|
||||
|
||||
add_string:
|
||||
s_translation_string_mutex.unlock_shared();
|
||||
s_translation_string_mutex.lock();
|
||||
std::lock_guard lock(s_translation_string_mutex);
|
||||
|
||||
if (s_translation_string_cache.empty()) [[unlikely]]
|
||||
{
|
||||
@ -110,7 +110,6 @@ add_string:
|
||||
|
||||
ret.first = &s_translation_string_cache[insert_pos];
|
||||
ret.second = static_cast<u32>(len);
|
||||
s_translation_string_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -132,10 +131,9 @@ std::string Host::TranslateToString(const std::string_view context, const std::s
|
||||
|
||||
void Host::ClearTranslationCache()
|
||||
{
|
||||
s_translation_string_mutex.lock();
|
||||
std::lock_guard lock(s_translation_string_mutex);
|
||||
s_translation_string_map.clear();
|
||||
s_translation_string_cache_pos = 0;
|
||||
s_translation_string_mutex.unlock();
|
||||
}
|
||||
|
||||
void Host::ReportFormattedInfoAsync(const std::string_view title, const char* format, ...)
|
||||
|
||||
@ -56,11 +56,10 @@ namespace usb_eyetoy
|
||||
|
||||
static void store_mpeg_frame(const unsigned char* data, const unsigned int len)
|
||||
{
|
||||
mpeg_mutex.lock();
|
||||
std::lock_guard lock(mpeg_mutex);
|
||||
if (len > 0)
|
||||
memcpy(mpeg_buffer.start, data, len);
|
||||
mpeg_buffer.length = len;
|
||||
mpeg_mutex.unlock();
|
||||
}
|
||||
|
||||
static void process_image(const unsigned char* data, int size)
|
||||
@ -642,13 +641,12 @@ namespace usb_eyetoy
|
||||
|
||||
int V4L2::GetImage(uint8_t* buf, size_t len)
|
||||
{
|
||||
mpeg_mutex.lock();
|
||||
std::lock_guard lock(mpeg_mutex);
|
||||
int len2 = mpeg_buffer.length;
|
||||
if (len < mpeg_buffer.length)
|
||||
len2 = len;
|
||||
memcpy(buf, mpeg_buffer.start, len2);
|
||||
mpeg_buffer.length = 0;
|
||||
mpeg_mutex.unlock();
|
||||
return len2;
|
||||
};
|
||||
|
||||
|
||||
@ -374,11 +374,10 @@ namespace usb_eyetoy
|
||||
|
||||
void store_mpeg_frame(const unsigned char* data, const unsigned int len)
|
||||
{
|
||||
mpeg_mutex.lock();
|
||||
std::lock_guard lock(mpeg_mutex);
|
||||
if (len > 0)
|
||||
memcpy(mpeg_buffer.start, data, len);
|
||||
mpeg_buffer.length = len;
|
||||
mpeg_mutex.unlock();
|
||||
}
|
||||
|
||||
void dshow_callback(unsigned char* data, int len, int bitsperpixel)
|
||||
@ -593,13 +592,12 @@ namespace usb_eyetoy
|
||||
|
||||
int DirectShow::GetImage(uint8_t* buf, size_t len)
|
||||
{
|
||||
mpeg_mutex.lock();
|
||||
std::lock_guard lock(mpeg_mutex);
|
||||
int len2 = mpeg_buffer.length;
|
||||
if (static_cast<size_t>(len) < mpeg_buffer.length)
|
||||
len2 = len;
|
||||
memcpy(buf, mpeg_buffer.start, len2);
|
||||
mpeg_buffer.length = 0;
|
||||
mpeg_mutex.unlock();
|
||||
return len2;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user