int sdlwindow_init(running_machine *machine) { // determine if we are using multithreading or not multithreading_enabled = options_get_bool(mame_options(), SDLOPTION_MULTITHREADING); // get the main thread ID before anything else main_threadid = SDL_ThreadID(); // ensure we get called on the way out add_exit_callback(machine, sdlwindow_exit); // if multithreading, create a thread to run the windows if (multithreading_enabled) { // create a thread to run the windows from #ifndef SDLMAME_OS2 work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); #else work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); #endif if (work_queue == NULL) return 1; osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE); } else { // otherwise, treat the window thread as the main thread //window_threadid = main_threadid; sdlwindow_thread_id(NULL, 0); } // initialize the drawers #if USE_OPENGL if (video_config.mode == VIDEO_MODE_OPENGL) { if (drawogl_init(&draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif #if SDL_VERSION_ATLEAST(1,3,0) if (video_config.mode == VIDEO_MODE_SDL13) { if (draw13_init(&draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif if (video_config.mode == VIDEO_MODE_SOFT) { if (drawsdl_init(&draw)) return 1; } // set up the window list last_window_ptr = &sdl_window_list; return 0; }
int sdlwindow_init(running_machine &machine) { mame_printf_verbose("Enter sdlwindow_init\n"); // determine if we are using multithreading or not multithreading_enabled = downcast<sdl_options &>(machine.options()).multithreading(); // get the main thread ID before anything else main_threadid = SDL_ThreadID(); // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdlwindow_exit), &machine)); // if multithreading, create a thread to run the windows if (multithreading_enabled) { // create a thread to run the windows from work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); if (work_queue == NULL) return 1; osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE); } else { // otherwise, treat the window thread as the main thread //window_threadid = main_threadid; sdlwindow_thread_id(NULL, 0); } // initialize the drawers #if USE_OPENGL if (video_config.mode == VIDEO_MODE_OPENGL) { if (drawogl_init(machine, &draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif #if SDLMAME_SDL2 if (video_config.mode == VIDEO_MODE_SDL13) { if (draw13_init(machine, &draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif if (video_config.mode == VIDEO_MODE_SOFT) { if (drawsdl_init(&draw)) return 1; } // set up the window list last_window_ptr = &sdl_window_list; mame_printf_verbose("Leave sdlwindow_init\n"); return 0; }