void mp3_pause(int pause) { if (mp3_thread >= 0) { if (mp3_running) { if (pause) { if (mp3_status == MP3_PLAY) { mp3_status = MP3_PAUSE; sceKernelSuspendThread(mp3_thread); memset(mp3_out[0], 0, MP3_BUFFER_SIZE); memset(mp3_out[1], 0, MP3_BUFFER_SIZE); sceAudioOutputPannedBlocking(mp3_handle, 0, 0, mp3_out[0]); } } else { if (mp3_status == MP3_PAUSE) { mp3_status = MP3_PLAY; sceKernelResumeThread(mp3_thread); } else if (mp3_status == MP3_SLEEP) { mp3_status = MP3_PLAY; sceKernelWakeupThread(mp3_thread); } } } } }
int nkThreadSuspend(SceUID thId){ int i, j; SceUID myThread, *Thread_Now; if(bufNow.pThread != 0) return 1; bufNow.pThread = sceKernelAllocPartitionMemory(1, "th", 0, MAX_THREAD*sizeof(SceUID), NULL); if(bufNow.pThread < 0){ bufNow.count = 0; bufNow.pThread = 0; return 1; } Thread_Now = (SceUID*)sceKernelGetBlockHeadAddr(bufNow.pThread); sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, Thread_Now, MAX_THREAD, &(bufNow.count)); myThread = sceKernelGetThreadId(); for(i = 0; i < bufNow.count; i++){ unsigned char match = 0; SceUID tmp_thid = Thread_Now[i]; for(j = 0; j < count_Start; j++){ if((tmp_thid == Thread_Start[j]) || (tmp_thid == thId) || (tmp_thid == myThread)){ match = 1; j = count_Start; } } if(match == 0){ sceKernelSuspendThread(tmp_thid); } } return 0; }
int control_module_threads(SceUID module_id, int pause) { // get an array of all threads int thread_count; if (sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, NULL, 0, &thread_count) < 0) return 0; if (thread_count < 1) return 0; SceUID thread_id[thread_count]; if (sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_id, thread_count, NULL) < 0) return 0; int i; SceModule* module; SceKernelThreadInfo thread_info; thread_info.size = sizeof(SceKernelThreadInfo); for (i = 0; i < thread_count; i++) { // determine if a thread is from the game if (sceKernelReferThreadStatus(thread_id[i], &thread_info)) continue; module = sceKernelFindModuleByAddress((unsigned int) thread_info.entry); if (module && module->modid == module_id) { // pause or resume the thread if (pause) sceKernelSuspendThread(thread_id[i]); else sceKernelResumeThread(thread_id[i]); } } return 1; }
void suspend_thread(const char *thread_name) { int ret; ret = get_thread_id(thread_name); sceKernelSuspendThread(ret); }
void stop_gdb(void) { if(g_thid > 0) { sceKernelSuspendThread(g_thid); } /* Cancel mbx receive, should then force the thread to exit */ sceKernelCancelReceiveMbx(g_handler.mbox, NULL); }
int threadCtrlSuspend() { if (threadCtrlState() == THREAD_CTRL_STATE_SUSPEND) { return 1; } int i, n; SceUID this_thid; SceKernelThreadInfo thinfo; this_thid = sceKernelGetThreadId(); sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, current_thid, MAX_THREAD, ¤t_count); for (i = 0;i < current_count;i++) { memset(&thinfo, 0, sizeof(SceKernelThreadInfo)); thinfo.size = sizeof(SceKernelThreadInfo); sceKernelReferThreadStatus(current_thid[i], &thinfo); if (thinfo.status & PSP_THREAD_SUSPEND || current_thid[i] == this_thid) { current_thid[i] = -1; continue; } for (n = 0;n < first_count;n++) { if (current_thid[i] == first_thid[n]) { current_thid[i] = -1; break; } } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* I got a hint from taba's JPCheat, thanks! */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (use_safely_suspend) { int count; for (count = 0;count < 1000;count++) { if ((IO_MEM_STICK_STATUS & 0x2000) == 0) { count = 0; } sceKernelDelayThread(1); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - */ for (i = 0;i < current_count;i++) { if (current_thid[i] >= 0) { sceKernelSuspendThread(current_thid[i]); } } return 0; }
/** * psp_sound_pause: Stop audio output. Called when the system is being * suspended. * * [Parameters] * None * [Return value] * None */ void psp_sound_pause(void) { if (stereo_buffer.started) { sceKernelSuspendThread(stereo_buffer.thread); } }
static int MainThread( SceSize args, void *argp ) { hookDisplay(); sceKernelDcacheWritebackInvalidateAll(); sceKernelIcacheInvalidateAll(); //scePowerTick( 0 ); unsigned int paddata_old = 0; char file[64], flag = 0, size = 0; int x, y, fd, count = 0, thread_count_start, thread_count_now; SceUID thread_buf_start[MAX_THREAD], thread_buf_now[MAX_THREAD], myThread = sceKernelGetThreadId(); SceCtrlData paddata; sceKernelDelayThread(10000); sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_buf_start, MAX_THREAD, &thread_count_start); while(1) { sceCtrlPeekBufferPositive(&paddata, 1); if(paddata.Buttons != paddata_old) { //press "note" button and magick begin if(paddata.Buttons & PSP_CTRL_NOTE) { // IdList Now sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_buf_now, MAX_THREAD, &thread_count_now); //hold all threads for a moment for(x = 0; x < thread_count_now; x++) { // thread id match 0 or 1 unsigned char match = 0; SceUID tmp_thid = thread_buf_now[x]; for(y = 0; y < thread_count_start; y++) { if((tmp_thid == thread_buf_start[y]) || (tmp_thid == myThread)) { match = 1; y = thread_count_start; } } if(thread_count_start == 0) match = 1; if(match == 0) { sceKernelSuspendThread(tmp_thid); } } //can parse command list can_parse = 1; //resume all threads for(x = 0; x < thread_count_now; x++) { // thread id match 0 or 1 unsigned char match = 0; SceUID tmp_thid = thread_buf_now[x]; for(y = 0; y < thread_count_start; y++) { if((tmp_thid == thread_buf_start[y]) || (tmp_thid == myThread)) { match = 1; y = thread_count_start; } } if(thread_count_start == 0) match = 1; if(match == 0) { sceKernelResumeThread(tmp_thid); } } } } paddata_old = paddata.Buttons; sceKernelDelayThread(10000); } return( 0 ); }