mirror of
https://github.com/libretro/RetroArch
synced 2025-03-04 16:13:50 +00:00
commit
1bf6887c59
@ -378,6 +378,9 @@ CFLAGS += -DHAVE_THREADS
|
|||||||
ifeq ($(platform), psp1)
|
ifeq ($(platform), psp1)
|
||||||
LIBS += -lpthread-psp
|
LIBS += -lpthread-psp
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(platform), vita)
|
||||||
|
LIBS += -lpthread
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_RSOUND), 1)
|
ifeq ($(HAVE_RSOUND), 1)
|
||||||
|
@ -45,8 +45,8 @@ typedef struct psp_audio
|
|||||||
volatile bool running;
|
volatile bool running;
|
||||||
volatile uint16_t read_pos;
|
volatile uint16_t read_pos;
|
||||||
volatile uint16_t write_pos;
|
volatile uint16_t write_pos;
|
||||||
|
|
||||||
#ifdef VITA
|
#ifdef VITA
|
||||||
char lock[32] __attribute__ ((aligned (8)));
|
char lock[32] __attribute__ ((aligned (8)));
|
||||||
char cond_lock[32] __attribute__ ((aligned (8)));
|
char cond_lock[32] __attribute__ ((aligned (8)));
|
||||||
char cond[32] __attribute__ ((aligned (8)));
|
char cond[32] __attribute__ ((aligned (8)));
|
||||||
@ -101,8 +101,8 @@ static int audioMainLoop(SceSize args, void* argp)
|
|||||||
|
|
||||||
#ifdef VITA
|
#ifdef VITA
|
||||||
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
|
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
|
||||||
sceKernelSignalLwCond(&psp->cond);
|
sceKernelSignalLwCond((struct SceKernelLwCondWork*)&psp->cond);
|
||||||
|
|
||||||
sceAudioOutOutput(port,
|
sceAudioOutOutput(port,
|
||||||
cond ? (psp->zeroBuffer)
|
cond ? (psp->zeroBuffer)
|
||||||
: (psp->buffer + read_pos_2));
|
: (psp->buffer + read_pos_2));
|
||||||
@ -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->lock, "audio_get_lock", 0, 0, 0);
|
||||||
sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock, "audio_get_cond_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
|
psp->thread = sceKernelCreateThread
|
||||||
("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL);
|
("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL);
|
||||||
#else
|
#else
|
||||||
@ -172,7 +172,7 @@ static void psp_audio_free(void *data)
|
|||||||
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
|
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
|
||||||
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->lock);
|
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->lock);
|
||||||
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock);
|
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock);
|
||||||
sceKernelDeleteLwCond(&psp->cond);
|
sceKernelDeleteLwCond((struct SceKernelLwCondWork*)&psp->cond);
|
||||||
#else
|
#else
|
||||||
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
sceKernelWaitThreadEnd(psp->thread, &timeout);
|
||||||
#endif
|
#endif
|
||||||
@ -187,7 +187,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
|||||||
psp_audio_t* psp = (psp_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
uint16_t write_pos = psp->write_pos;
|
uint16_t write_pos = psp->write_pos;
|
||||||
uint16_t sampleCount = size / sizeof(uint32_t);
|
uint16_t sampleCount = size / sizeof(uint32_t);
|
||||||
|
|
||||||
#ifdef VITA
|
#ifdef VITA
|
||||||
if (psp->nonblocking)
|
if (psp->nonblocking)
|
||||||
{
|
{
|
||||||
@ -198,7 +198,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
|||||||
|
|
||||||
while (AUDIO_BUFFER_SIZE - ((uint16_t)
|
while (AUDIO_BUFFER_SIZE - ((uint16_t)
|
||||||
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size){
|
(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);
|
sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0);
|
||||||
@ -218,11 +218,11 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
|||||||
write_pos &= AUDIO_BUFFER_SIZE_MASK;
|
write_pos &= AUDIO_BUFFER_SIZE_MASK;
|
||||||
psp->write_pos = write_pos;
|
psp->write_pos = write_pos;
|
||||||
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
|
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (psp->nonblocking)
|
if (psp->nonblocking)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <psp2/power.h>
|
#include <psp2/power.h>
|
||||||
#include <psp2/sysmodule.h>
|
#include <psp2/sysmodule.h>
|
||||||
#include <psp2/appmgr.h>
|
#include <psp2/appmgr.h>
|
||||||
|
#include <pthread.h>
|
||||||
#else
|
#else
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspdebug.h>
|
#include <pspdebug.h>
|
||||||
@ -298,6 +299,7 @@ static void frontend_psp_init(void *data)
|
|||||||
#ifdef VITA
|
#ifdef VITA
|
||||||
scePowerSetArmClockFrequency(444);
|
scePowerSetArmClockFrequency(444);
|
||||||
sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
|
sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
|
||||||
|
pthread_init();
|
||||||
#else
|
#else
|
||||||
(void)data;
|
(void)data;
|
||||||
/* initialize debug screen */
|
/* initialize debug screen */
|
||||||
|
@ -73,7 +73,7 @@ static int psp_thread_wrap(SceSize args, void *argp)
|
|||||||
static INLINE int pthread_create(pthread_t *thread,
|
static INLINE int pthread_create(pthread_t *thread,
|
||||||
const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
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
|
#ifdef VITA
|
||||||
*thread = sceKernelCreateThread(name_buffer, psp_thread_wrap,
|
*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,
|
static INLINE int pthread_mutex_init(pthread_mutex_t *mutex,
|
||||||
const pthread_mutexattr_t *attr)
|
const pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
sprintf(name_buffer, "0x%08X", (uint32_t) mutex);
|
sprintf(name_buffer, "0x%08X", (unsigned int) mutex);
|
||||||
|
|
||||||
#ifdef VITA
|
#ifdef VITA
|
||||||
*mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0);
|
*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){
|
if(cond->mutex<0){
|
||||||
return cond->mutex;
|
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 = sceKernelCreateCond(name_buffer, 0, cond->mutex, 0);
|
||||||
cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0);
|
cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0);
|
||||||
if(cond->sema<0){
|
if(cond->sema<0){
|
||||||
@ -251,7 +251,7 @@ static INLINE int pthread_cond_signal(pthread_cond_t *cond)
|
|||||||
if (cond->waiting)
|
if (cond->waiting)
|
||||||
{
|
{
|
||||||
--cond->waiting;
|
--cond->waiting;
|
||||||
int ret = sceKernelSignalSema(cond->sema, 1);
|
sceKernelSignalSema(cond->sema, 1);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&cond->mutex);
|
pthread_mutex_unlock(&cond->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
#include "gx_pthread.h"
|
#include "gx_pthread.h"
|
||||||
#elif defined(PSP) || defined(VITA)
|
#elif defined(PSP)
|
||||||
#include "psp_pthread.h"
|
#include "psp_pthread.h"
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -154,11 +154,11 @@ error:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sthread_detach:
|
* sthread_detach:
|
||||||
* @thread : pointer to thread object
|
* @thread : pointer to thread object
|
||||||
*
|
*
|
||||||
* Detach a thread. When a detached thread terminates, its
|
* Detach a thread. When a detached thread terminates, its
|
||||||
* resource sare automatically released back to the system
|
* resource sare automatically released back to the system
|
||||||
* without the need for another thread to join with the
|
* without the need for another thread to join with the
|
||||||
* terminated thread.
|
* terminated thread.
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, otherwise it returns a non-zero error number.
|
* Returns: 0 on success, otherwise it returns a non-zero error number.
|
||||||
@ -176,13 +176,13 @@ int sthread_detach(sthread_t *thread)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sthread_join:
|
* sthread_join:
|
||||||
* @thread : pointer to thread object
|
* @thread : pointer to thread object
|
||||||
*
|
*
|
||||||
* Join with a terminated thread. Waits for the thread specified by
|
* Join with a terminated thread. Waits for the thread specified by
|
||||||
* @thread to terminate. If that thread has already terminated, then
|
* @thread to terminate. If that thread has already terminated, then
|
||||||
* it will return immediately. The thread specified by @thread must
|
* it will return immediately. The thread specified by @thread must
|
||||||
* be joinable.
|
* be joinable.
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, otherwise it returns a non-zero error number.
|
* Returns: 0 on success, otherwise it returns a non-zero error number.
|
||||||
*/
|
*/
|
||||||
void sthread_join(sthread_t *thread)
|
void sthread_join(sthread_t *thread)
|
||||||
@ -198,13 +198,13 @@ void sthread_join(sthread_t *thread)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* sthread_isself:
|
* sthread_isself:
|
||||||
* @thread : pointer to thread object
|
* @thread : pointer to thread object
|
||||||
*
|
*
|
||||||
* Join with a terminated thread. Waits for the thread specified by
|
* Join with a terminated thread. Waits for the thread specified by
|
||||||
* @thread to terminate. If that thread has already terminated, then
|
* @thread to terminate. If that thread has already terminated, then
|
||||||
* it will return immediately. The thread specified by @thread must
|
* it will return immediately. The thread specified by @thread must
|
||||||
* be joinable.
|
* be joinable.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if calling thread is the specified thread
|
* Returns: true (1) if calling thread is the specified thread
|
||||||
*/
|
*/
|
||||||
bool sthread_isself(sthread_t *thread)
|
bool sthread_isself(sthread_t *thread)
|
||||||
@ -248,7 +248,7 @@ error:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* slock_free:
|
* slock_free:
|
||||||
* @lock : pointer to mutex object
|
* @lock : pointer to mutex object
|
||||||
*
|
*
|
||||||
* Frees a mutex.
|
* Frees a mutex.
|
||||||
**/
|
**/
|
||||||
@ -267,7 +267,7 @@ void slock_free(slock_t *lock)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* slock_lock:
|
* slock_lock:
|
||||||
* @lock : pointer to mutex object
|
* @lock : pointer to mutex object
|
||||||
*
|
*
|
||||||
* Locks a mutex. If a mutex is already locked by
|
* Locks a mutex. If a mutex is already locked by
|
||||||
* another thread, the calling thread shall block until
|
* another thread, the calling thread shall block until
|
||||||
@ -284,7 +284,7 @@ void slock_lock(slock_t *lock)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* slock_unlock:
|
* slock_unlock:
|
||||||
* @lock : pointer to mutex object
|
* @lock : pointer to mutex object
|
||||||
*
|
*
|
||||||
* Unlocks a mutex.
|
* Unlocks a mutex.
|
||||||
**/
|
**/
|
||||||
@ -333,7 +333,7 @@ error:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* scond_free:
|
* scond_free:
|
||||||
* @cond : pointer to condition variable object
|
* @cond : pointer to condition variable object
|
||||||
*
|
*
|
||||||
* Frees a condition variable.
|
* Frees a condition variable.
|
||||||
**/
|
**/
|
||||||
@ -352,16 +352,16 @@ void scond_free(scond_t *cond)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* scond_wait:
|
* scond_wait:
|
||||||
* @cond : pointer to condition variable object
|
* @cond : pointer to condition variable object
|
||||||
* @lock : pointer to mutex object
|
* @lock : pointer to mutex object
|
||||||
*
|
*
|
||||||
* Block on a condition variable (i.e. wait on a condition).
|
* Block on a condition variable (i.e. wait on a condition).
|
||||||
**/
|
**/
|
||||||
void scond_wait(scond_t *cond, slock_t *lock)
|
void scond_wait(scond_t *cond, slock_t *lock)
|
||||||
{
|
{
|
||||||
#ifdef USE_WIN32_THREADS
|
#ifdef USE_WIN32_THREADS
|
||||||
WaitForSingleObject(cond->event, 0);
|
WaitForSingleObject(cond->event, 0);
|
||||||
|
|
||||||
SignalObjectAndWait(lock->lock, cond->event, INFINITE, FALSE);
|
SignalObjectAndWait(lock->lock, cond->event, INFINITE, FALSE);
|
||||||
slock_lock(lock);
|
slock_lock(lock);
|
||||||
#else
|
#else
|
||||||
@ -371,15 +371,15 @@ void scond_wait(scond_t *cond, slock_t *lock)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* scond_broadcast:
|
* scond_broadcast:
|
||||||
* @cond : pointer to condition variable object
|
* @cond : pointer to condition variable object
|
||||||
*
|
*
|
||||||
* Broadcast a condition. Unblocks all threads currently blocked
|
* Broadcast a condition. Unblocks all threads currently blocked
|
||||||
* on the specified condition variable @cond.
|
* on the specified condition variable @cond.
|
||||||
**/
|
**/
|
||||||
int scond_broadcast(scond_t *cond)
|
int scond_broadcast(scond_t *cond)
|
||||||
{
|
{
|
||||||
#ifdef USE_WIN32_THREADS
|
#ifdef USE_WIN32_THREADS
|
||||||
/* FIXME _- check how this function should differ
|
/* FIXME _- check how this function should differ
|
||||||
* from scond_signal implementation. */
|
* from scond_signal implementation. */
|
||||||
SetEvent(cond->event);
|
SetEvent(cond->event);
|
||||||
return 0;
|
return 0;
|
||||||
@ -390,10 +390,10 @@ int scond_broadcast(scond_t *cond)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* scond_signal:
|
* scond_signal:
|
||||||
* @cond : pointer to condition variable object
|
* @cond : pointer to condition variable object
|
||||||
*
|
*
|
||||||
* Signal a condition. Unblocks at least one of the threads currently blocked
|
* Signal a condition. Unblocks at least one of the threads currently blocked
|
||||||
* on the specified condition variable @cond.
|
* on the specified condition variable @cond.
|
||||||
**/
|
**/
|
||||||
void scond_signal(scond_t *cond)
|
void scond_signal(scond_t *cond)
|
||||||
{
|
{
|
||||||
@ -406,8 +406,8 @@ void scond_signal(scond_t *cond)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* scond_wait_timeout:
|
* scond_wait_timeout:
|
||||||
* @cond : pointer to condition variable object
|
* @cond : pointer to condition variable object
|
||||||
* @lock : pointer to mutex object
|
* @lock : pointer to mutex object
|
||||||
* @timeout_us : timeout (in microseconds)
|
* @timeout_us : timeout (in microseconds)
|
||||||
*
|
*
|
||||||
* Try to block on a condition variable (i.e. wait on a condition) until
|
* Try to block on a condition variable (i.e. wait on a condition) until
|
||||||
|
Loading…
x
Reference in New Issue
Block a user