void uae_Signal(uaecptr task, uae_u32 mask) { write_comm_pipe_int (&native2amiga_pending, 0, 0); write_comm_pipe_u32 (&native2amiga_pending, task, 0); write_comm_pipe_int (&native2amiga_pending, mask, 1); uae_int_requested = 1; }
void uae_NotificationHack (uaecptr port, uaecptr nr) { uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 4, 0); write_comm_pipe_int (&native2amiga_pending, port, 0); write_comm_pipe_int (&native2amiga_pending, nr, 1); do_uae_int_requested (); uae_sem_post (&n2asem); }
void uae_Signal (uaecptr task, uae_u32 mask) { uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 0, 0); write_comm_pipe_u32 (&native2amiga_pending, task, 0); write_comm_pipe_int (&native2amiga_pending, mask, 1); do_uae_int_requested (); uae_sem_post (&n2asem); }
void uae_ReplyMsg(uaecptr msg) { write_comm_pipe_int (&native2amiga_pending, 2, 0); write_comm_pipe_u32 (&native2amiga_pending, msg, 1); uae_int_requested = 1; }
void uae_ReplyMsg (uaecptr msg) { uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 2, 0); write_comm_pipe_u32 (&native2amiga_pending, msg, 1); do_uae_int_requested (); uae_sem_post (&n2asem); }
void uae_Cause (uaecptr interrupt) { uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 3, 0); write_comm_pipe_u32 (&native2amiga_pending, interrupt, 1); do_uae_int_requested (); uae_sem_post (&n2asem); }
void uae_PutMsg(uaecptr port, uaecptr msg) { uae_pt data; data.i = 1; write_comm_pipe_int (&native2amiga_pending, 1, 0); write_comm_pipe_u32 (&native2amiga_pending, port, 0); write_comm_pipe_u32 (&native2amiga_pending, msg, 1); uae_int_requested = 1; }
void close_sound (void) { config_changed = 1; gui_data.sndbuf = 0; gui_data.sndbuf_status = 3; if (!have_sound) return; // SDL_PauseAudio (1); clearbuffer(); if (in_callback) { closing_sound = 1; uae_sem_post (&data_available_sem); } write_comm_pipe_int (&to_sound_pipe, 1, 1); uae_sem_wait (&sound_init_sem); // SDL_CloseAudio (); uae_sem_destroy (&data_available_sem); uae_sem_destroy (&sound_init_sem); uae_sem_destroy (&callback_done_sem); have_sound = 0; }
int init_sound(void) { write_log("init_sound\n"); gui_data.sndbuf_status = 3; gui_data.sndbuf = 0; if (!sound_available) return 0; if (currprefs.produce_sound <= 1) return 0; if (have_sound) return 1; in_callback = 0; closing_sound = 0; init_sound_thread (); write_comm_pipe_int (&to_sound_pipe, 0, 1); uae_sem_wait (&sound_init_sem); // SDL_PauseAudio (0); #ifdef DRIVESOUND driveclick_reset (); #endif return have_sound; }
/* handle_message() * * This is called from the GUI when a GUI event happened. Specifically, * HandleMessage (PPP_Messaging) forwards dispatched UI action * messages posted from JavaScript to handle_message(). */ int32_t handle_message(const char* msg) { /* Grammar for messages from the UI: * * message ::= 'insert' drive fileURL * | 'rom' fileURL * | 'connect' port input * | 'eject' drive * | 'reset' | 'pause' | 'resume' * | 'resize' <width> <height> * device ::= 'kickstart' | drive * drive ::= 'df0' | 'df1' * port ::= 'port0' | 'port1' * input ::= 'mouse' | 'joy0' | 'joy1' | 'kbd0' | 'kbd1' * fileURL ::= <a URL of the form blob://> */ DEBUG_LOG("%s\n", msg); if (!gui_initialized) { DEBUG_LOG("GUI message refused; not yet initialized.\n"); return -1; } /* TODO(cstefansen): scan the string instead of these shenanigans. */ /* Copy to non-const buffer. */ char buf[1024]; (void) strncpy(buf, msg, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; /* Ensure NUL termination. */ /* Tokenize message up to 3 tokens (max given the grammar). */ int32_t i = 0; char *t[3], *token, *rest = NULL, *sep = " "; for (token = strtok_r(buf, sep, &rest); token != NULL && i <= 3; token = strtok_r(NULL, sep, &rest), ++i) { t[i] = token; } /* Pipe message to UAE main thread. */ if (i == 1 && !strcmp(t[0], "reset")) { write_comm_pipe_int(&from_gui_pipe, UAECMD_RESET, 1); } else if (i == 1 && !strcmp(t[0], "pause")) { /* It would be cleaner to call pause_sound and resume_sound in * gui_handle_events below, i.e, on the emulator thread. However, * if we're pausing because the tab is no longer in the foreground, * no graphics flush calls will unblock and no graphics callbacks will * be delivered until the tab is back in front. This means that the * emulator is probably already stuck in some call and won't get to * our UI request to pause the sound. */ /* TODO(cstefansen)People are reporting pausing/resuming problems; let's not do this until investigated. */ /* pause_sound(); */ write_comm_pipe_int(&from_gui_pipe, UAECMD_PAUSE, 1); } else if (i == 1 && !strcmp(t[0], "resume")) { /* resume_sound(); */ write_comm_pipe_int(&from_gui_pipe, UAECMD_RESUME, 1); } else if (i == 2 && !strcmp(t[0], "eject")) { int32_t drive_num; if (!strcmp(t[1], "df0")) { drive_num = 0; } else if (!strcmp(t[1], "df1")) { drive_num = 1; } else { return -1; } write_comm_pipe_int(&from_gui_pipe, UAECMD_EJECTDISK, 0); write_comm_pipe_int(&from_gui_pipe, drive_num, 1); } else if (i == 3 && !strcmp(t[0], "resize")) { long width = strtol(t[1], NULL, 10); long height = strtol(t[2], NULL, 10); if (width > INT_MAX || height > INT_MAX || errno == ERANGE || width <= 0 || height <= 0) { write_log("Could not parse width/height in message: %s\n", msg); return -1; } write_comm_pipe_int(&from_gui_pipe, UAECMD_RESIZE, 0); write_comm_pipe_int(&from_gui_pipe, (int32_t) width, 0); write_comm_pipe_int(&from_gui_pipe, (int32_t) height, 1); } else if (i == 3 && !strcmp(t[0], "insert")) { int32_t drive_num; if (!strcmp(t[1], "df0")) { drive_num = 0; } else if (!strcmp(t[1], "df1")) { drive_num = 1; } else { return -1; } uae_sem_wait(&gui_sem); if (new_disk_string[drive_num] != 0) free (new_disk_string[drive_num]); new_disk_string[drive_num] = strdup(t[2]); uae_sem_post(&gui_sem); write_comm_pipe_int (&from_gui_pipe, UAECMD_INSERTDISK, 0); write_comm_pipe_int (&from_gui_pipe, drive_num, 1); } else if (i == 2 && !strcmp(t[0], "rom")) { uae_sem_wait(&gui_sem); if (gui_romname != 0) free (gui_romname); gui_romname = strdup(t[1]); uae_sem_post(&gui_sem); write_comm_pipe_int(&from_gui_pipe, UAECMD_SELECT_ROM, 1); } else if (i == 3 && !strcmp(t[0], "connect")) { int32_t port_num; if (!strcmp(t[1], "port0")) { port_num = 0; } else if (!strcmp(t[1], "port1")) { port_num = 1; } else { return -1; } int32_t input_device = !strcmp(t[2], "mouse") ? JSEM_MICE : !strcmp(t[2], "joy0") ? JSEM_JOYS : !strcmp(t[2], "joy1") ? JSEM_JOYS + 1 : !strcmp(t[2], "kbd0") ? JSEM_KBDLAYOUT + 1 : !strcmp(t[2], "kbd1") ? JSEM_KBDLAYOUT + 2 : JSEM_END; changed_prefs.jports[port_num].id = input_device; if (changed_prefs.jports[port_num].id != currprefs.jports[port_num].id) { /* It's a little fishy that the typical way to update input * devices doesn't use the comm pipe. */ inputdevice_updateconfig (&changed_prefs); inputdevice_config_change(); } } else { return -1; } return 0; }