Example #1
0
static bool psp_audio_start(void *data)
{
    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)
        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);

    return true;
}
Example #2
0
int terminateDeleteAllUserThreads()
{
        SceKernelSemaInfo semaInfo;
        SceKernelThreadInfo threadInfo;
        globals_t *globals;
        int res;

        globals = getGlobals();
        sceKernelLockMutex(globals->threadmgrMutex, 1, NULL);

        semaInfo.size = sizeof(semaInfo);
        res = sceKernelGetSemaInfo(globals->threadmgrSema, &semaInfo);
        if (res)
                return res;

        while (semaInfo.currentCount < semaInfo.maxCount) {
                res = sceKernelGetThreadInfo(globals->threadmgrTable[semaInfo.currentCount].uid, &threadInfo);
                if (res == 0 && (threadInfo.status == PSP2_THREAD_STOPPED
                                  || threadInfo.status == PSP2_THREAD_KILLED))
                        sceKernelDeleteThread(globals->threadmgrTable[semaInfo.currentCount].uid);
                else
                        sceKernelNotifyCallback(globals->threadmgrTable[semaInfo.currentCount].exitDeleteCb, 0);

                semaInfo.currentCount++;
        }

        sceKernelUnlockMutex(globals->threadmgrMutex, 1);

        sceKernelWaitSema(globals->threadmgrSema, MAX_THREADS_NUM, NULL);
        sceKernelSignalSema(globals->threadmgrSema, MAX_THREADS_NUM);

        return 0;
}
Example #3
0
static void VITAAUD_ThreadInit(_THIS)
{
    /* Increase the priority of this audio thread by 1 to put it
       ahead of other SDL threads. */
    SceUID thid;
    SceKernelThreadInfo info;
    thid = sceKernelGetThreadId();
    info.size = sizeof(SceKernelThreadInfo);
    if (sceKernelGetThreadInfo(thid, &info) == 0) {
        sceKernelChangeThreadPriority(thid, info.currentPriority - 1);
    }
}
Example #4
0
static bool psp_audio_start(void *data)
{
   SceKernelThreadInfo info;
   psp_audio_t* psp = (psp_audio_t*)data;

   info.size = sizeof(SceKernelThreadInfo);

   if (sceKernelGetThreadInfo(
            psp->thread, &info) < 0) /* Error */
      return false;

   if (info.status != PSP_THREAD_STOPPED)
      return false;

   psp->running = true;

   sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);

   return true;
}
Example #5
0
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
{
    SceKernelThreadInfo info;
    int priority = 32;

    /* Set priority of new thread to the same as the current thread */
    info.size = sizeof(SceKernelThreadInfo);
    if (sceKernelGetThreadInfo(sceKernelGetThreadId(), &info) == 0) {
        priority = info.currentPriority;
    }

    thread->handle = sceKernelCreateThread("SDL thread", ThreadEntry,
                           priority, 0x10000, 0, 0, NULL);

    if (thread->handle < 0) {
        return SDL_SetError("sceKernelCreateThread() failed");
    }

    sceKernelStartThread(thread->handle, 4, &args);
    return 0;
}
Example #6
0
static bool psp_audio_stop(void *data)
{
    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)
        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);
#else
    sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif

    return true;
}