static void *dev_thread (void *devs) { struct s2devstruct *dev = (struct s2devstruct*)devs; uae_set_thread_priority (NULL, 1); dev->thread_running = 1; uae_sem_post (&dev->sync_sem); for (;;) { uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); uae_sem_wait (&change_sem); if (!request) { dev->thread_running = 0; uae_sem_post (&dev->sync_sem); uae_sem_post (&change_sem); write_log (_T("%s: dev_thread killed\n"), getdevname ()); return 0; } else if (get_async_request (dev, request, 1)) { uae_ReplyMsg (request); release_async_request (dev, request); rem_async_packet (dev, request); } else if (dev_do_io (dev, request, 0) == 0) { uae_ReplyMsg (request); rem_async_packet (dev, request); } else { add_async_request (dev, request); ethernet_trigger (dev->sysdata); } uae_sem_post (&change_sem); } return 0; }
static void *dev_thread (void *devs) { struct devstruct *dev = (struct devstruct*)devs; uae_set_thread_priority (2); dev->thread_running = 1; uae_sem_post (&dev->sync_sem); for (;;) { uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); uae_sem_wait (&change_sem); if (!request) { dev->thread_running = 0; uae_sem_post (&dev->sync_sem); uae_sem_post (&change_sem); return 0; } else if (get_async_request (dev, request, 1)) { uae_ReplyMsg (request); release_async_request (dev, request); } else if (dev_do_io (dev, request, 0) == 0) { uae_ReplyMsg (request); } else { add_async_request (dev, request); uaeser_trigger (dev->sysdata); } uae_sem_post (&change_sem); } return 0; }
static void *dev_thread (void *devs) { struct devstruct *dev = devs; uae_set_thread_priority (2); dev->thread_running = 1; sys_command_open_thread (DF_SCSI, dev->unitnum); sys_command_open_thread (DF_IOCTL, dev->unitnum); uae_sem_post (&dev->sync_sem); for (;;) { uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&dev->requests); uae_sem_wait (&change_sem); if (!request) { dev->thread_running = 0; uae_sem_post (&dev->sync_sem); uae_sem_post (&change_sem); break; } else if (dev_do_io (dev, request) == 0) { put_byte (request + 30, get_byte (request + 30) & ~1); release_async_request (dev, request); uae_ReplyMsg (request); } else { if (log_scsi) write_log ("async request %08.8X\n", request); } uae_sem_post (&change_sem); } sys_command_close_thread (DF_SCSI, dev->unitnum); sys_command_close_thread (DF_IOCTL, dev->unitnum); return 0; }
static void *cdda_unpack_func (void *v) { cdimage_unpack_thread = 1; mp3decoder *mp3dec = NULL; for (;;) { uae_u32 cduidx = read_comm_pipe_u32_blocking (&unpack_pipe); if (cdimage_unpack_thread == 0) break; uae_u32 tocidx = read_comm_pipe_u32_blocking (&unpack_pipe); struct cdunit *cdu = &cdunits[cduidx]; struct cdtoc *t = &cdu->toc[tocidx]; if (t->handle) { // force unpack if handle points to delayed zipped file uae_s64 pos = zfile_ftell (t->handle); zfile_fseek (t->handle, -1, SEEK_END); uae_u8 b; zfile_fread (&b, 1, 1, t->handle); zfile_fseek (t->handle, pos, SEEK_SET); if (!t->data && (t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC)) { t->data = xcalloc (uae_u8, t->filesize + 2352); cdimage_unpack_active = 1; if (t->data) { if (t->enctype == AUDENC_MP3) { if (!mp3dec) { try { mp3dec = new mp3decoder(); } catch (exception) { }; } if (mp3dec) t->data = mp3dec->get (t->handle, t->data, t->filesize); } else if (t->enctype == AUDENC_FLAC) { flac_get_data (t); } } } } cdimage_unpack_active = 2; } delete mp3dec; cdimage_unpack_thread = -1; return 0; }
static void *display_thread (void *unused) { VC_DISPMANX_ALPHA_T alpha = { (DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), 255 /*alpha 0->255*/ , 0 }; uint32_t vc_image_ptr; SDL_Surface *Dummy_prSDLScreen; int width, height; bool callback_registered = false; for(;;) { display_thread_busy = false; uae_u32 signal = read_comm_pipe_u32_blocking(display_pipe); display_thread_busy = true; switch(signal) { case DISPLAY_SIGNAL_SETUP: if(!callback_registered) { bcm_host_init(); dispmanxdisplay = vc_dispmanx_display_open(0); vc_dispmanx_vsync_callback(dispmanxdisplay, vsync_callback, NULL); callback_registered = true; } break; case DISPLAY_SIGNAL_SUBSHUTDOWN: if (DispManXElementpresent == 1) { DispManXElementpresent = 0; dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_remove(dispmanxupdate, dispmanxelement); vc_dispmanx_update_submit_sync(dispmanxupdate); } if (dispmanxresource_amigafb_1 != 0) { vc_dispmanx_resource_delete(dispmanxresource_amigafb_1); dispmanxresource_amigafb_1 = 0; } if (dispmanxresource_amigafb_2 != 0) { vc_dispmanx_resource_delete(dispmanxresource_amigafb_2); dispmanxresource_amigafb_2 = 0; } if(prSDLScreen != NULL) { SDL_FreeSurface(prSDLScreen); prSDLScreen = NULL; } uae_sem_post (&display_sem); break; case DISPLAY_SIGNAL_OPEN: width = display_width; height = display_height; Dummy_prSDLScreen = SDL_SetVideoMode(width, height, 16, SDL_SWSURFACE | SDL_FULLSCREEN); prSDLScreen = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 16, Dummy_prSDLScreen->format->Rmask, Dummy_prSDLScreen->format->Gmask, Dummy_prSDLScreen->format->Bmask, Dummy_prSDLScreen->format->Amask); SDL_FreeSurface(Dummy_prSDLScreen); vc_dispmanx_display_get_info(dispmanxdisplay, &dispmanxdinfo); dispmanxresource_amigafb_1 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, width, height, &vc_image_ptr); dispmanxresource_amigafb_2 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, width, height, &vc_image_ptr); vc_dispmanx_rect_set(&blit_rect, 0, 0, width, height); vc_dispmanx_resource_write_data(dispmanxresource_amigafb_1, VC_IMAGE_RGB565, prSDLScreen->pitch, prSDLScreen->pixels, &blit_rect); vc_dispmanx_rect_set(&src_rect, 0, 0, width << 16, height << 16); // 16/9 to 4/3 ratio adaptation. if (currprefs.gfx_correct_aspect == 0 || screen_is_picasso) { // Fullscreen. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width)/2, (dispmanxdinfo.height - scaled_height)/2, scaled_width, scaled_height); } else { // 4/3 shrink. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width - scaled_width / 16 * 12)/2, (dispmanxdinfo.height - scaled_height)/2, scaled_width/16*12, scaled_height); } if (DispManXElementpresent == 0) { DispManXElementpresent = 1; dispmanxupdate = vc_dispmanx_update_start(0); dispmanxelement = vc_dispmanx_element_add(dispmanxupdate, dispmanxdisplay, 2, // layer &dst_rect, dispmanxresource_amigafb_1, &src_rect, DISPMANX_PROTECTION_NONE, &alpha, NULL, DISPMANX_NO_ROTATE); vc_dispmanx_update_submit(dispmanxupdate, NULL, NULL); } uae_sem_post (&display_sem); break; case DISPLAY_SIGNAL_SHOW: if (current_resource_amigafb == 1) { current_resource_amigafb = 0; vc_dispmanx_resource_write_data(dispmanxresource_amigafb_1, VC_IMAGE_RGB565, adisplays.gfxvidinfo.drawbuffer.rowbytes, adisplays.gfxvidinfo.drawbuffer.bufmem, &blit_rect); dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_change_source(dispmanxupdate, dispmanxelement, dispmanxresource_amigafb_1); } else { current_resource_amigafb = 1; vc_dispmanx_resource_write_data(dispmanxresource_amigafb_2, VC_IMAGE_RGB565, adisplays.gfxvidinfo.drawbuffer.rowbytes, adisplays.gfxvidinfo.drawbuffer.bufmem, &blit_rect); dispmanxupdate = vc_dispmanx_update_start(0); vc_dispmanx_element_change_source(dispmanxupdate, dispmanxelement, dispmanxresource_amigafb_2); } vc_dispmanx_update_submit(dispmanxupdate, NULL, NULL); break; case DISPLAY_SIGNAL_QUIT: callback_registered = false; vc_dispmanx_vsync_callback(dispmanxdisplay, NULL, NULL); vc_dispmanx_display_close(dispmanxdisplay); bcm_host_deinit(); SDL_VideoQuit(); display_tid = 0; return 0; } } }