Merge pull request #3548 from frangarcj/master

(VITA) Use pthreads
This commit is contained in:
Twinaphex 2016-09-09 17:56:34 +02:00 committed by GitHub
commit 1bf6887c59
5 changed files with 41 additions and 36 deletions

View File

@ -378,6 +378,9 @@ CFLAGS += -DHAVE_THREADS
ifeq ($(platform), psp1)
LIBS += -lpthread-psp
endif
ifeq ($(platform), vita)
LIBS += -lpthread
endif
endif
ifeq ($(HAVE_RSOUND), 1)

View File

@ -101,7 +101,7 @@ static int audioMainLoop(SceSize args, void* argp)
#ifdef VITA
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
sceKernelSignalLwCond(&psp->cond);
sceKernelSignalLwCond((struct SceKernelLwCondWork*)&psp->cond);
sceAudioOutOutput(port,
cond ? (psp->zeroBuffer)
@ -145,7 +145,7 @@ static void *psp_audio_init(const char *device,
sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)&psp->lock, "audio_get_lock", 0, 0, 0);
sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock, "audio_get_cond_lock", 0, 0, 0);
sceKernelCreateLwCond(&psp->cond, "audio_get_cond", 0, &psp->cond_lock, 0);
sceKernelCreateLwCond((struct SceKernelLwCondWork*)&psp->cond, "audio_get_cond", 0, (struct SceKernelLwMutexWork*)&psp->cond_lock, 0);
psp->thread = sceKernelCreateThread
("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL);
#else
@ -172,7 +172,7 @@ static void psp_audio_free(void *data)
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->lock);
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock);
sceKernelDeleteLwCond(&psp->cond);
sceKernelDeleteLwCond((struct SceKernelLwCondWork*)&psp->cond);
#else
sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif
@ -198,7 +198,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
while (AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size){
sceKernelWaitLwCond(&psp->cond, 0);
sceKernelWaitLwCond((struct SceKernelLwCondWork*)&psp->cond, 0);
}
sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0);

View File

@ -23,6 +23,7 @@
#include <psp2/power.h>
#include <psp2/sysmodule.h>
#include <psp2/appmgr.h>
#include <pthread.h>
#else
#include <pspkernel.h>
#include <pspdebug.h>
@ -298,6 +299,7 @@ static void frontend_psp_init(void *data)
#ifdef VITA
scePowerSetArmClockFrequency(444);
sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
pthread_init();
#else
(void)data;
/* initialize debug screen */

View File

@ -73,7 +73,7 @@ static int psp_thread_wrap(SceSize args, void *argp)
static INLINE int pthread_create(pthread_t *thread,
const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
{
sprintf(name_buffer, "0x%08X", (uint32_t) thread);
sprintf(name_buffer, "0x%08X", (unsigned int) thread);
#ifdef VITA
*thread = sceKernelCreateThread(name_buffer, psp_thread_wrap,
@ -93,7 +93,7 @@ static INLINE int pthread_create(pthread_t *thread,
static INLINE int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr)
{
sprintf(name_buffer, "0x%08X", (uint32_t) mutex);
sprintf(name_buffer, "0x%08X", (unsigned int) mutex);
#ifdef VITA
*mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0);
@ -224,7 +224,7 @@ static INLINE int pthread_cond_init(pthread_cond_t *cond,
if(cond->mutex<0){
return cond->mutex;
}
sprintf(name_buffer, "0x%08X", (uint32_t) cond);
sprintf(name_buffer, "0x%08X", (unsigned int) cond);
//cond->sema = sceKernelCreateCond(name_buffer, 0, cond->mutex, 0);
cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0);
if(cond->sema<0){
@ -251,7 +251,7 @@ static INLINE int pthread_cond_signal(pthread_cond_t *cond)
if (cond->waiting)
{
--cond->waiting;
int ret = sceKernelSignalSema(cond->sema, 1);
sceKernelSignalSema(cond->sema, 1);
}
pthread_mutex_unlock(&cond->mutex);
return 0;

View File

@ -41,7 +41,7 @@
#endif
#elif defined(GEKKO)
#include "gx_pthread.h"
#elif defined(PSP) || defined(VITA)
#elif defined(PSP)
#include "psp_pthread.h"
#elif defined(__CELLOS_LV2__)
#include <pthread.h>