/*-------------------------------------------------------------------------*\ * Waits for a set of sockets until a condition is met or timeout. \*-------------------------------------------------------------------------*/ static int global_select(lua_State *L) { int rtab, wtab, itab, ret, ndirty; t_socket max_fd; fd_set rset, wset; t_timeout tm; double t = luaL_optnumber(L, 3, -1); FD_ZERO(&rset); FD_ZERO(&wset); lua_settop(L, 3); lua_newtable(L); itab = lua_gettop(L); lua_newtable(L); rtab = lua_gettop(L); lua_newtable(L); wtab = lua_gettop(L); max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset); ndirty = check_dirty(L, 1, rtab, &rset); t = ndirty > 0? 0.0: t; timeout_init(&tm, t, -1); timeout_markstart(&tm); max_fd = collect_fd(L, 2, max_fd, itab, &wset); ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm); if (ret > 0 || ndirty > 0) { return_fd(L, &rset, max_fd+1, itab, rtab, ndirty); return_fd(L, &wset, max_fd+1, itab, wtab, 0); make_assoc(L, rtab); make_assoc(L, wtab); return 2; } else if (ret == 0) { lua_pushstring(L, "timeout"); return 3; } else { lua_pushstring(L, "error"); return 3; } }
static void new_project (void) { check_dirty (); if (project) g_object_unref (project); project = project_new (scene_store, sequence_store, channel_store); }
static gboolean quit (void) { check_dirty (); g_print ("quit!\n"); audio_stop (); gtk_main_quit (); return TRUE; }
static int global_select(lua_State *L, const sigset_t* mask, int sigreceived) { int rtab, wtab, etab, itab, ret, ndirty; t_socket max_fd; fd_set rset, wset, eset; t_timeout tm; double t = luaL_optnumber(L, 4, -1); FD_ZERO(&rset); FD_ZERO(&wset); FD_ZERO(&eset); lua_settop(L, 4); lua_newtable(L); itab = lua_gettop(L); lua_newtable(L); rtab = lua_gettop(L); lua_newtable(L); wtab = lua_gettop(L); lua_newtable(L); etab = lua_gettop(L); max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset); ndirty = check_dirty(L, 1, rtab, &rset); t = ndirty > 0? 0.0: t; timeout_init(&tm, t, -1); timeout_markstart(&tm); max_fd = collect_fd(L, 2, max_fd, itab, &wset); max_fd = collect_fd(L, 3, max_fd, itab, &eset); //printf("+enter select\n"); if (sigreceived) { ret = -1; } else { ret = socket_select(max_fd+1, &rset, &wset, &eset, &tm, mask); } //printf("+exit select\n"); if (ret > 0 || ndirty > 0) { return_fd(L, &rset, max_fd+1, itab, rtab, ndirty); return_fd(L, &wset, max_fd+1, itab, wtab, 0); return_fd(L, &eset, max_fd+1, itab, etab, 0); make_assoc(L, rtab); make_assoc(L, wtab); make_assoc(L, etab); return 3; //3 values pushed: 3 result tables } else if (ret == 0) { lua_pushstring(L, "timeout"); return 4; //4 values pushed: 3 result tables + timeout msg } else { lua_pushstring(L, strerror(errno)); return 4; //4 values pushed: 3 result tables + errno msg } }
static void open_file (GtkWidget *button, gpointer user_data) { const gchar *filename; check_dirty (); filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (user_data)); if (project) g_object_unref (project); project = project_new_from_file (filename, scene_store, sequence_store, channel_store); if (project == NULL) { GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (user_data), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error loading file '%s': %s"), filename, g_strerror (errno)); g_signal_connect_swapped (GTK_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (dialog)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); project = project_new (scene_store, sequence_store, channel_store); } }
static void tcx24_update_display(void *opaque) { TCXState *ts = opaque; ram_addr_t page, page_min, page_max, cpage, page24; int y, y_start, dd, ds; uint8_t *d, *s; uint32_t *cptr, *s24; if (ds_get_bits_per_pixel(ts->ds) != 32) return; page = 0; page24 = ts->vram24_offset; cpage = ts->cplane_offset; y_start = -1; page_min = -1; page_max = 0; d = ds_get_data(ts->ds); s = ts->vram; s24 = ts->vram24; cptr = ts->cplane; dd = ds_get_linesize(ts->ds); ds = 1024; for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE, page24 += TARGET_PAGE_SIZE, cpage += TARGET_PAGE_SIZE) { if (check_dirty(ts, page, page24, cpage)) { if (y_start < 0) y_start = y; if (page < page_min) page_min = page; if (page > page_max) page_max = page; tcx24_draw_line32(ts, d, s, ts->width, cptr, s24); d += dd; s += ds; cptr += ds; s24 += ds; tcx24_draw_line32(ts, d, s, ts->width, cptr, s24); d += dd; s += ds; cptr += ds; s24 += ds; tcx24_draw_line32(ts, d, s, ts->width, cptr, s24); d += dd; s += ds; cptr += ds; s24 += ds; tcx24_draw_line32(ts, d, s, ts->width, cptr, s24); d += dd; s += ds; cptr += ds; s24 += ds; } else { if (y_start >= 0) { /* flush to display */ dpy_update(ts->ds, 0, y_start, ts->width, y - y_start); y_start = -1; } d += dd * 4; s += ds * 4; cptr += ds * 4; s24 += ds * 4; } } if (y_start >= 0) { /* flush to display */ dpy_update(ts->ds, 0, y_start, ts->width, y - y_start); } /* reset modified pages */ if (page_max >= page_min) { reset_dirty(ts, page_min, page_max, page24, cpage); } }