(Vita/PSP) Code de-duplication

This commit is contained in:
twinaphex 2015-09-16 10:39:30 +02:00
parent 504bea51e0
commit 7f946eb972

View File

@ -48,6 +48,13 @@ typedef struct psp_audio
#define AUDIO_BUFFER_SIZE (1u<<13u)
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
#ifdef VITA
#define PSP_THREAD_STOPPED PSP2_THREAD_STOPPED
#else
#define SceKernelThreadInfo SceKernelThreadRunStatus
#define sceKernelGetThreadInfo sceKernelReferThreadRunStatus
#endif
static int audioMainLoop(SceSize args, void* argp)
{
psp_audio_t* psp = *((psp_audio_t**)argp);
@ -190,37 +197,22 @@ static bool psp_audio_alive(void *data)
return psp->running;
}
static bool psp_audio_stop(void *data)
{
SceKernelThreadInfo info;
SceUInt timeout = 100000;
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
SceKernelThreadInfo info;
info.size = sizeof(SceKernelThreadInfo);
if (sceKernelGetThreadInfo(
psp->thread, &info) < 0) /* Error */
return false;
if (info.status == PSP2_THREAD_STOPPED)
if (info.status == PSP_THREAD_STOPPED)
return false;
#else
SceKernelThreadRunStatus runStatus;
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
psp->thread, &runStatus) < 0) /* Error */
return false;
if (runStatus.status == PSP_THREAD_STOPPED)
return false;
#endif
psp->running = false;
#if defined(VITA)
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
@ -233,10 +225,8 @@ static bool psp_audio_stop(void *data)
static bool psp_audio_start(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
SceKernelThreadInfo info;
psp_audio_t* psp = (psp_audio_t*)data;
info.size = sizeof(SceKernelThreadInfo);
@ -244,22 +234,9 @@ static bool psp_audio_start(void *data)
psp->thread, &info) < 0) /* Error */
return false;
if (info.status != PSP2_THREAD_STOPPED)
if (info.status != PSP_THREAD_STOPPED)
return false;
#else
SceKernelThreadRunStatus runStatus;
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
psp->thread, &runStatus) < 0) /* Error */
return false;
if (runStatus.status != PSP_THREAD_STOPPED)
return false;
#endif
psp->running = true;
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);