/**************************************************************************** * InitDeviceThread * * libOGC provides a nice wrapper for LWP access. * This function sets up a new local queue and attaches the thread to it. ***************************************************************************/ void InitDeviceThread() { #ifdef HW_RVL LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40); #endif LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80); }
void runBlinkTexts(struct stBlinkTextsGroup *stBlinkTexts) { stBlinkTexts->intThreadId=LWP_THREAD_NULL; stBlinkTexts->mtxThread=LWP_MUTEX_NULL; if (!LWP_MutexInit(&stBlinkTexts->mtxThread,false)) { LWP_CreateThread(&stBlinkTexts->intThreadId,(void *(*)(void *)) updateBlinkTexts,(void *)stBlinkTexts,NULL,0,64); } }
void initialize_joysticks(void) { MQ_Init(&eq, EVENT_QUEUE_SIZE); eq_inited = 1; LWP_CreateThread(&poll_thread, wii_poll_thread, NULL, poll_stack, STACKSIZE, 40); }
void InitRemovalThread() { #ifdef DEVICE_REMOVAL_THREAD LWP_CreateThread (&removalThread, removalCallback, NULL, NULL, 0, 40); rThreadCreated = 1; #endif }
/**************************************************************************** * InitGUIThread * * Startup GUI threads ***************************************************************************/ void InitGUIThreads() { ExitRequested = false; if(guithread == LWP_THREAD_NULL) LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 65536, LWP_PRIO_HIGHEST); }
bor_thread *thread_create(int (*fn)(void *), const char *name, void *data) { bor_thread *thread = malloc(sizeof(bor_thread)); thread->run = fn; thread->data = data; LWP_CreateThread(&thread->thread, run_thread, thread, NULL, 0, 64); return thread; }
/**************************************************************************** * StartNetworkThread * * Signals the network thread to resume, or creates a new thread ***************************************************************************/ void StartNetworkThread() { netHalt = 0; if(networkthread == LWP_THREAD_NULL) LWP_CreateThread(&networkthread, netcb, NULL, netstack, 8192, 40); else LWP_ResumeThread(networkthread); }
u32 GuiImageAsync::ThreadInit() { if (Thread == LWP_THREAD_NULL) { LWP_MutexInit(&ListLock, false); LWP_CreateThread(&Thread, GuiImageAsyncThread, NULL, NULL, 32768, 80); } return ++ThreadCount; }
static void DebugHelper_start( DebugHelper_t *helper) { LWP_CreateThread( &__db_helper_thread, /* thread handle */ DebugHelper_run, /* code */ helper, /* arg pointer for thread */ NULL, /* stack base */ 16*1024, /* stack size */ 50 /* thread priority */ ); }
SoundHandler::SoundHandler() { Decoding = false; ExitRequested = false; for(u32 i = 0; i < MAX_DECODERS; ++i) DecoderList[i] = NULL; ThreadStack = (u8 *) memalign(32, 32768); if(!ThreadStack) return; LWP_CreateThread(&SoundThread, UpdateThread, this, ThreadStack, 32768, 100); }
void WiiInit() { extern const devoptab_t dotab_stdnull; devoptab_list[STD_OUT] = &dotab_stdnull; devoptab_list[STD_ERR] = &dotab_stdnull; //USBGeckoOutput(); // uncomment to enable USB gecko output __exception_setreload(8); fatInitDefault(); ASND_Init(); SetupPads(); InitFreeType((u8*)font_ttf, font_ttf_size); LWP_CreateThread (&keythread, PressKeys, NULL, NULL, 0, 65); appPath[0] = 0; }
void WiiLoad_Start(char *tempPath, int startSleep) { threadStartSleep = startSleep; if (firstInit) { memset (&wiiload, 0, sizeof(s_wiiload)); firstInit = 0; } wiiload.status = WIILOAD_INITIALIZING; if (tempPath != NULL) { strcpy (tpath, tempPath); } threadStack = (u8 *) memalign(32, STACKSIZE); if(!threadStack) { wiiload.status = WIILOAD_STOPPED; return; } else LWP_CreateThread (&networkthread, WiiloadThread, NULL, threadStack, STACKSIZE, 8); threadStackG = (u8 *) memalign(32, STACKSIZE); if (!threadStackG) { return; } else LWP_CreateThread (&geckothread, GeckoThread, NULL, threadStackG, STACKSIZE, 8); started = 1; }
EXPORT void CALL RomOpen() { #ifdef THREADED_AUDIO // Create our semaphores and start/resume the audio thread; reset the buffer index LWP_SemInit(&buffer_full, 0, NUM_BUFFERS); LWP_SemInit(&buffer_empty, NUM_BUFFERS, NUM_BUFFERS); LWP_SemInit(&audio_free, 0, 1); LWP_SemInit(&first_audio, 0, 1); thread_running = 0; LWP_CreateThread(&audio_thread, (void*)play_buffer, NULL, audio_stack, AUDIO_STACK_SIZE, AUDIO_PRIORITY); AUDIO_RegisterDMACallback(done_playing); thread_buffer = which_buffer = 0; audio_paused = 1; #endif }
static void system_init(void) { #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); #ifndef IS_SALAMANDER gx_init_mem2(); #endif #endif #ifndef DEBUG __exception_setreload(8); #endif fatInitDefault(); #ifdef HAVE_LOGGER inl_logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) inl_logger_init(); #ifndef IS_SALAMANDER devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) lwp_t gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); LWP_MutexInit(&gx_device_mutex, false); LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66); #endif }
void OSystem_Wii::initSfx() { _mixer = new Audio::MixerImpl(this, 48000); sfx_thread_running = false; sfx_thread_quit = false; sfx_stack = (u8 *) memalign(32, SFX_THREAD_STACKSIZE); if (sfx_stack) { memset(sfx_stack, 0, SFX_THREAD_STACKSIZE); LWP_InitQueue(&sfx_queue); s32 res = LWP_CreateThread(&sfx_thread, sfx_thread_func, _mixer, sfx_stack, SFX_THREAD_STACKSIZE, SFX_THREAD_PRIO); if (res) { printf("ERROR creating sfx thread: %d\n", res); LWP_CloseQueue(sfx_queue); return; } sfx_thread_running = true; } for (u32 i = 0; i < SFX_BUFFERS; ++i) { sound_buffer[i] = (u8 *) memalign(32, SFX_THREAD_FRAG_SIZE); memset(sound_buffer[i], 0, SFX_THREAD_FRAG_SIZE); DCFlushRange(sound_buffer[i], SFX_THREAD_FRAG_SIZE); } _mixer->setReady(true); sb_hw = 0; AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_RegisterDMACallback(audio_switch_buffers); AUDIO_InitDMA((u32) sound_buffer[sb_hw], SFX_THREAD_FRAG_SIZE); AUDIO_StartDMA(); }
int InitNetwork(NET_STATE* ref) { int ret, result; ret = if_config(ref->localip, ref->netmask, ref->gateway, TRUE); if (ret < 0) { return -1; } ref->socket = net_socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (ref->socket == INVALID_SOCKET) { return -1; } memset(&ref->sockAddr, 0, sizeof(ref->sockAddr)); ref->sockAddr.sin_family = AF_INET; ref->sockAddr.sin_port = htons(NETWORK_PORT_A); ref->sockAddr.sin_addr.s_addr = inet_addr(HOST_IP); /* getaddrinfo(HOST_NAME, STR(HOST_IP), NULL, &addrinfo); */ result = net_connect(ref->socket, (struct sockaddr *)&ref->sockAddr, sizeof(ref->sockAddr)); if (result == -1) { net_close(ref->socket); return -1; } if (LWP_CreateThread(&ref->thread_handle, NetworkThread, (void*)ref, NULL, 256*1024, 60) < 0) { ref->threadTerminated = 1; return -1; } return 0; }
void init_network_thread() { LWP_CreateThread (&initnetthread, init_network, NULL, NULL, 0, 40); }
DiHandler::DiHandler() { LWP_MutexInit( &mutex, false ); LWP_CreateThread( &thread, ThreadMain, NULL, NULL, 32768, 80); }
ThreadedTask::ThreadedTask() : ExitRequested(false) { LWP_CreateThread (&Thread, ThreadCallback, this, NULL, 16384, 70); }
int main() { void *xfb; GXRModeObj *rmode; lwp_t handle; int r; char *stack; IOS_ReloadIOS(30); VIDEO_Init(); switch(VIDEO_GetCurrentTvMode()) { case VI_NTSC: rmode = &TVNtsc480IntDf; break; case VI_PAL: rmode = &TVPal528IntDf; break; case VI_MPAL: rmode = &TVMpal480IntDf; break; default: rmode = &TVNtsc480IntDf; break; } xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); #if 1 printf("Calling main()\n"); main_real(); printf("main() returned\n"); #else printf("Creating main thread\n"); stack = malloc(1024*1024); if (stack == 0) { printf("Unable to allocate stack\n"); while(1); } handle = 0; r = LWP_CreateThread(&handle, main_real, 0, stack, 1024*1024, 50); if (r != 0) { printf("Failed to create thread\n"); while(1); } printf("Main thread created\n"); LWP_SetThreadPriority(0, 0); printf("Looping\n"); while(1); #endif }
void CMenu::_system() { int msg = 0, newVer = SVN_REV_NUM; lwp_t thread = LWP_THREAD_NULL; wstringEx prevMsg; int amount_of_skips = 0; int update_x = 0, update_y = 0; u32 update_w = 0, update_h = 0; bool first = true; m_btnMgr.reset(m_systemLblInfo, true); SetupInput(); m_btnMgr.setText(m_systemBtnBack, _t("dl1", L"Cancel")); m_thrdStop = false; m_thrdMessageAdded = false; m_showtimer = -1; while(!m_exit) { _mainLoopCommon(); if(amount_of_skips == 0) // Check dimensions in the loop, because the animation can have an effect m_btnMgr.getDimensions(m_systemLblInfo, update_x, update_y, update_w, update_h); // Get original dimensions if(first) { m_btnMgr.moveBy(m_systemLblInfo, 0, -(pixels_to_skip * 10)); amount_of_skips++; first = false; } if (m_showtimer == -1) { m_showtimer = 120; m_btnMgr.show(m_downloadPBar); m_btnMgr.setProgress(m_downloadPBar, 0.f); m_thrdStop = false; m_thrdWorking = true; LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionTxtDownloaderInit, (void *)this, downloadStack, downloadStackSize, 40); } if (m_showtimer > 0 && !m_thrdWorking) { if (thread != LWP_THREAD_NULL) { LWP_JoinThread(thread, NULL); thread = LWP_THREAD_NULL; } if (--m_showtimer == 0) { m_btnMgr.hide(m_downloadPBar); m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -2.f, 0.f); m_btnMgr.hide(m_downloadLblMessage[1], 0, 0, -2.f, 0.f); CMenu::_version[1] = m_version.getInt("GENERAL", "version", SVN_REV_NUM); num_versions = m_version.getInt("GENERAL", "num_versions", 1); for (i = 2; i < num_versions; i++) { CMenu::_version[i] = m_version.getInt(fmt("VERSION%i", i-1u), "version", SVN_REV_NUM); //add the changelog info here } if (num_versions > 1 && version_num == 0) version_num = 1; i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u); newVer = CMenu::_version[i]; _showSystem(); } } if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop)) { if (update_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (35 + update_y))) { m_btnMgr.moveBy(m_systemLblInfo, 0, -pixels_to_skip); amount_of_skips++; } } else if ((BTN_UP_PRESSED || BTN_UP_HELD) && !(m_thrdWorking && m_thrdStop)) { if (amount_of_skips > 1) { m_btnMgr.moveBy(m_systemLblInfo, 0, pixels_to_skip); amount_of_skips--; } } else if ((BTN_HOME_PRESSED || BTN_B_PRESSED || m_exit) && !m_thrdWorking) break; else if ((BTN_A_PRESSED) && !(m_thrdWorking && m_thrdStop)) { if ((m_btnMgr.selected(m_systemBtnDownload)) && !m_thrdWorking) { // Download selected version _hideSystem(); m_btnMgr.show(m_downloadPBar); m_btnMgr.setProgress(m_downloadPBar, 0.f); m_thrdStop = false; m_thrdWorking = true; gprintf("\nVersion to DL: %i\n", newVer); if(m_version.getInt("GENERAL", "version", 0) == newVer) m_app_update_size = m_version.getInt("GENERAL", "app_zip_size", 0); m_data_update_size = m_version.getInt("GENERAL", "data_zip_size", 0); m_app_update_url = fmt("%s/Wiiflow_Mod_svn_r%i.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer); m_data_update_url = fmt("%s/r%i/data.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer); m_showtimer = 120; LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionDownloaderInit, (void *)this, downloadStack, downloadStackSize, 40); if (m_exit && !m_thrdWorking) { m_thrdStop = true; break; } } else if (m_btnMgr.selected(m_systemBtnBack)) { LockMutex lock(m_mutex); m_thrdStop = true; m_thrdMessageAdded = true; m_thrdMessage = _t("dlmsg6", L"Canceling..."); } else if (m_btnMgr.selected(m_systemBtnVerSelectM)) { if (version_num > 1) --version_num; else version_num = num_versions; i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u); { m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i]))); newVer = CMenu::_version[i]; m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0); if (i > 1 && i != num_versions) m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false); else if (i == num_versions) m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false); else m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false); } } else if (m_btnMgr.selected(m_systemBtnVerSelectP)) { if (version_num < num_versions) ++version_num; else version_num = 1; i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u); { m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i]))); newVer = CMenu::_version[i]; m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0); if (i > 1 && i != num_versions) m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false); else if (i == num_versions) m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false); else m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false); } } } if (Sys_Exiting()) { LockMutex lock(m_mutex); m_thrdStop = true; m_thrdMessageAdded = true; m_thrdMessage = _t("dlmsg6", L"Canceling..."); } // if (m_thrdMessageAdded) { LockMutex lock(m_mutex); m_thrdMessageAdded = false; m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress); if (m_thrdProgress == 1.f) m_btnMgr.setText(m_systemBtnBack, _t("dl2", L"Back")); if (prevMsg != m_thrdMessage) { prevMsg = m_thrdMessage; m_btnMgr.setText(m_downloadLblMessage[msg], m_thrdMessage, false); m_btnMgr.hide(m_downloadLblMessage[msg], -200, 0, 1.f, 0.5f, true); m_btnMgr.show(m_downloadLblMessage[msg]); msg ^= 1; m_btnMgr.hide(m_downloadLblMessage[msg], +400, 0, 1.f, 1.f); } } if (m_thrdStop && !m_thrdWorking) break; } if (thread != LWP_THREAD_NULL) { LWP_JoinThread(thread, NULL); thread = LWP_THREAD_NULL; } _hideSystem(); }
/**************************************************************************** * InitGUIThread * * Startup GUI threads ***************************************************************************/ void InitGUIThreads() { LWP_CreateThread (&guithread, UpdateGUI, NULL, NULL, 0, 70); }
/**************************************************************************** * InitNetworkThread with priority 0 (idle) ***************************************************************************/ void InitNetworkThread() { LWP_CreateThread(&networkthread, networkinitcallback, NULL, NULL, 16384, 0); }
void startNetworkStuff () { LWP_CreateThread(&netThread, networkThread, NULL, netStack, NETSTACK_SZ, 40); }
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { LWP_CreateThread(&thread->handle, run_thread, args, 0, 0, 80); return (0); }
int main(int argc, char *argv[]) { #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); gx_init_mem2(); #endif fatInitDefault(); #ifdef HAVE_LOGGER g_extern.verbose = true; logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) g_extern.verbose = true; log_fp = fopen("/retroarch-log.txt", "w"); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #ifdef HW_RVL lwp_t gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); LWP_MutexInit(&gx_device_mutex, false); LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66); #endif get_environment_settings(); make_directories(); config_set_defaults(); input_gx.init(); video_gx.start(); driver.video = &video_gx; gx_video_t *gx = (gx_video_t*)driver.video_data; gx->menu_data = (uint32_t *) menu_framebuf; char tmp_path[PATH_MAX]; const char *extension = default_paths.executable_extension; snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir); const char *path_prefix = tmp_path; char full_path[1024]; snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension); bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix, default_paths.config_file, extension); rarch_settings_set_default(&input_gx); rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file); char core_name[64]; rarch_console_name_from_id(core_name, sizeof(core_name)); char input_path[1024]; snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name); config_read_keybinds(input_path); init_libretro_sym(); input_gx.post_init(); menu_init(); if (argc > 2 && argv[1] != NULL && argv[2] != NULL) { char rom[PATH_MAX]; g_console.external_launcher_support = EXTERN_LAUNCHER_CHANNEL; snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]); g_console.zip_extract_mode = ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE; rarch_console_load_game_wrap(rom, g_console.zip_extract_mode, S_DELAY_1); rgui_iterate(rgui, RGUI_ACTION_MESSAGE); gx->menu_render = true; rarch_render_cached_frame(); gx->menu_render = false; rarch_startup(default_paths.config_file); } else { g_console.external_launcher_support = EXTERN_LAUNCHER_SALAMANDER; } begin_loop: if(g_console.mode_switch == MODE_EMULATION) { bool repeat = false; input_gx.poll(NULL); video_set_aspect_ratio_func(g_console.aspect_ratio_index); audio_start_func(); do{ repeat = rarch_main_iterate(); }while(repeat && !g_console.frame_advance_enable); audio_stop_func(); } else if(g_console.mode_switch == MODE_MENU) { menu_loop(); if (g_console.mode_switch != MODE_EXIT) rarch_startup(default_paths.config_file); } else goto begin_shutdown; goto begin_loop; begin_shutdown: rarch_config_save(default_paths.config_file); config_save_keybinds(input_path); if(g_console.emulator_initialized) rarch_main_deinit(); input_gx.free(NULL); video_gx.stop(); menu_free(); #ifdef HAVE_LOGGER logger_shutdown(); #elif defined(HAVE_FILE_LOGGER) fclose(log_fp); #endif if(g_console.return_to_launcher) rarch_console_exec(g_console.launch_app_on_exit); exit(0); }
/**************************************************************************** * InitDeviceThread * * libOGC provides a nice wrapper for LWP access. * This function sets up a new local queue and attaches the thread to it. ***************************************************************************/ void InitDeviceThread() { LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40); }