Fix a threading issue with PS Vita.

This commit is contained in:
David Reid
2026-02-28 17:08:37 +10:00
parent e35c1fd64b
commit 69396f97a7
+18 -1
View File
@@ -17919,7 +17919,7 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
int result; int result;
pthread_attr_t* pAttr = NULL; pthread_attr_t* pAttr = NULL;
#if !defined(MA_EMSCRIPTEN) && !defined(MA_N3DS) && !defined(MA_SWITCH) && !defined(MA_DREAMCAST) #if !defined(MA_EMSCRIPTEN) && !defined(MA_N3DS) && !defined(MA_SWITCH) && !defined(MA_DREAMCAST) && !defined(MA_VITA)
/* Try setting the thread priority. It's not critical if anything fails here. */ /* Try setting the thread priority. It's not critical if anything fails here. */
pthread_attr_t attr; pthread_attr_t attr;
if (pthread_attr_init(&attr) == 0) { if (pthread_attr_init(&attr) == 0) {
@@ -17955,6 +17955,23 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
{ {
if (stackSize > 0) { if (stackSize > 0) {
pthread_attr_setstacksize(&attr, stackSize); pthread_attr_setstacksize(&attr, stackSize);
} else {
/*
Note for Vita SDK
When using pthread_attr_t (this path we're in now), the default stack size seems to be too small. If the
pthread_attr_t path is skipped entirely, things work fine. It looks like skipping the call to
pthread_attr_setstacksize(), which happens when stackSize is 0, the chosen stack size is smaller than
what it would be if we skipped the pthread_attr_t path.
There are two work arounds for this. The first is to always skip the pthread_attr_t path. The second is
to have a specialized path here for Vita and explicitly default to something bigger. I'm doing both.
*/
#if defined(MA_VITA)
{
pthread_attr_setstacksize(&attr, 0x10000);
}
#endif
} }
} }
#else #else