/** * Start engine. * */ engine_type * engine_start(const char* cfgfile, int cmdline_verbosity, int daemonize, int info) { engine_type* engine = NULL; int use_syslog = 0; ods_status status = ODS_STATUS_OK; ods_log_assert(cfgfile); ods_log_init(NULL, use_syslog, cmdline_verbosity); ods_log_verbose("[%s] starting enforcer", engine_str); /* initialize */ xmlInitGlobals(); xmlInitParser(); xmlInitThreads(); engine = engine_create(); if (!engine) { ods_fatal_exit("[%s] create failed", engine_str); return NULL; } engine->daemonize = daemonize; /* config */ engine->config = engine_config(engine->allocator, cfgfile, cmdline_verbosity); status = engine_config_check(engine->config); if (status != ODS_STATUS_OK) { ods_log_error("[%s] cfgfile %s has errors", engine_str, cfgfile); engine_stop(engine); return NULL; } if (info) { engine_config_print(stdout, engine->config); /* for debugging */ engine_stop(engine); return NULL; } /* open log */ ods_log_init(engine->config->log_filename, engine->config->use_syslog, engine->config->verbosity); /* setup */ tzset(); /* for portability */ /* initialize protobuf and protobuf-orm */ ods_protobuf_initialize(); ods_orm_initialize(); return engine; }
bool TiEmuDCOP::send_file(QString filename) { if (img_loaded && !engine_is_stopped()) { engine_stop(); fs_send_file(filename.local8Bit()); engine_start(); return true; } else return false; }
bool TiEmuDCOP::enter_debugger() { if (img_loaded && !engine_is_stopped()) { engine_stop(); ti68k_debug_break(); engine_start(); return true; } else return false; }
bool TiEmuDCOP::send_files(QStringList filenames) { if (img_loaded && !engine_is_stopped()) { engine_stop(); for (QStringList::Iterator it = filenames.begin(); it != filenames.end(); ++it) fs_send_file((*it).local8Bit()); engine_start(); return true; } else return false; }
bool TiEmuDCOP::turn_calc_on() { if (img_loaded && !engine_is_stopped()) { engine_stop(); hw_m68k_irq(6); while (ti68k_debug_is_supervisor()) hw_m68k_run(1,0); engine_start(); return true; } else return false; }
void controller_stop() { if ( playlist->playing ) { playlist->playing->flags &= ~F_PAUSED; playlist->playing = NULL; gui_update_playlist(); } engine_stop(); gui_update_playback(); controller_update_statefile(); }
bool TiEmuDCOP::reset_calc(bool clearram) { if (img_loaded) { engine_stop(); if(clearram) std::memset(tihw.ram, 0, tihw.ram_size); ti68k_reset(); if (dbg_on) close_debugger_async(); else engine_start(); return true; } else return false; }
/* ================= engine_start ================= */ erbool engine_start (void) { init_time(); sys_get_time(); INIT(cvar); INIT(cmd); INIT(cmdbuf); cmd_register("quit", NULL, &quit_f, 0); cmd_register("echo", NULL, &echo_f, 0); INIT(fs); INIT(keyboard); cmdbuf_add("exec config.cfg\n", CMD_SRC_ENGINE); cmdbuf_frame(); INIT(mouse); INIT(image); INIT(video); INIT(gl); INIT(r); INIT(snd); INIT(g); cmdbuf_add("exec autoexec.cfg\n", CMD_SRC_ENGINE); cmdbuf_frame(); /* put sys args into cmdbuf (which begin with '+') once again (after all cmds like 'map' were registered) */ sys_arg_to_cmdbuf('+'); cmdbuf_frame(); return true; error: engine_stop(); return false; }
void controller_jump_to_song ( songdata_song *next ) { if ( !next ) return; if ( playlist->playing != next ) { //It's really a jump.... engine_stop(); } char * current = next->fullpath; playlist->playing = next; engine_jump_to(current); /* GUI stuff */ gui_update_playlist(); gui_update_info(); gui_update_playback(); controller_update_whereplaying(); controller_update_statefile(); }
GLADE_CB void on_dockmode1_activate (GtkMenuItem *menu_item, gpointer user_data) { msg_box1(_("Warning"), _("TiEmu is about to restart...")); #ifndef NO_GDB // In GDB mode, we have to restart the engine here, otherwise // gtk_debugger_close will call gdbcall_continue to do so and never // return. engine_start(); #endif gtk_debugger_close(); // Stop the engine before calling gtk_main_quit. // Otherwise, it will keep running even when it is supposed to have // been stopped by the debugger. engine_stop(); if(options3.dbg_dock) gtk_widget_destroy(dbgw.dock); options3.dbg_dock = GTK_CHECK_MENU_ITEM(menu_item)->active; gtk_main_quit(); }
int main(int argc, char **argv) { struct engine *engine = NULL; Display *dpy; int num; XSetWindowAttributes attr; unsigned long mask; Window root; Window win; XVisualInfo *info = NULL; GLXContext ctx = NULL; int conf[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, GL_FALSE, GLX_DEPTH_SIZE, 1, None, }; dpy = XOpenDisplay(NULL); if (!dpy) { _err("failed to open X display\n"); return 1; } num = DefaultScreen(dpy); _inf("use GLX_SGIX_pbuffer on screen %d\n", num); root = RootWindow(dpy, num); info = glXChooseVisual(dpy, num, conf); if (!info) { _err("glXChooseVisual() failed\n"); goto out; } /* window attributes */ attr.border_pixel = 0; attr.colormap = XCreateColormap(dpy, root, info->visual, AllocNone); attr.event_mask = ButtonPressMask | ExposureMask | KeyPressMask; mask = CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow(dpy, root, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, info->depth, InputOutput, info->visual, mask, &attr); ctx = glXCreateContext(dpy, info, NULL, GL_TRUE); if (!ctx) { _err("glXCreateContext() failed\n"); goto out; } XFree(info); info = NULL; XMapWindow(dpy, win); _msg("call glXMakeCurrent()\n"); glXMakeCurrent(dpy, win, ctx); _inf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); _inf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); _inf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); _inf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); _inf("GL_SHADING_LANGUAGE_VERSION = %s\n", (char *) glGetString(GL_SHADING_LANGUAGE_VERSION)); _msg("clear window\n"); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glXSwapBuffers(dpy, win); _msg("init engine\n"); if (engine_init(&engine, argc, argv) < 0) { _err("engine_init() failed\n"); goto out; } _msg("start engine\n"); engine_start(engine); glXSwapBuffers(dpy, win); engine_stop(engine); event_loop(dpy); _msg("exit engine\n"); engine_exit(&engine); out: glXMakeCurrent(dpy, 0, 0); if (info) XFree(info); if (ctx) glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); XCloseDisplay(dpy); return 0; }
void engine_loop () { int maxfd; fd_set rfdset; fd_set wfdset; struct timeval tv; int fds; while (!exiting || nbclients > 0) { FD_ZERO (&rfdset); FD_ZERO (&wfdset); maxfd = -1; engine_set_readers (&rfdset, &maxfd); engine_set_writers (&wfdset, &maxfd); /* Wait for the end of created process to avoid zombie */ engine_wait_pids(); if (maxfd == -1) { /* * well... in fact this should not happen * or very rarely */ log (LOG_WARNING, _("engine - No data to wait\n")); sleep (ENGINE_TIMEOUT); fds = 0; /* simulate a timeout */ } else { tv.tv_sec = ENGINE_TIMEOUT; tv.tv_usec = 0; fds = select (maxfd + 1, &rfdset, &wfdset, NULL, &tv); } /* FIXME: find a better way of doing this */ if(!haccess->is_connected()) { log (LOG_WARNING, _("Server drop the connection.\n")); engine_stop(); } if (fds > 0) { engine_read (&rfdset); engine_write (&wfdset); engine_timeout (); } else { /* * There was no data to read/write */ debug (9, "engine - Timed out\n"); engine_timeout (); } if (exiting && nbclients > 0) engine_end_clients (); } debug (1, "engine - ended\n"); }
/** Quit current executable. */ static int l_quit(lua_State *L) { engine_stop(engine_luaget(L)); return 0; }
void handle_method_call (GDBusConnection * connection, const gchar * sender, const gchar * object_path, const gchar * interface_name, const gchar * method_name, GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * myobj) { gboolean ret = TRUE; GError *error = NULL; if (g_strcmp0 (object_path, MPRIS_OBJECT_NAME) != 0 || g_strcmp0 (interface_name, MPRIS_PLAYER_INTERFACE) != 0) { g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Method %s.%s not supported", interface_name, method_name); return; } if (g_strcmp0 (method_name, "OpenUri") == 0) { gchar *uri; // g_print ("openUri.. uri: %s\n", uri); g_variant_get (parameters, "(s)", &uri); my_object_change_uri (myobj, uri); g_dbus_method_invocation_return_value (invocation, NULL); } else if (g_strcmp0 (method_name, "Next") == 0) { /// ToDo: next track call handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Play") == 0) { engine_play (myobj->engine); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Pause") == 0) { change_state (myobj->engine, "Paused"); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Stop") == 0) { engine_stop (myobj->engine); handle_result (invocation, ret, error); } else if (g_strcmp0 (method_name, "Seek") == 0) { gint64 offset, position; gfloat relative; g_variant_get (parameters, "(x)", &offset); relative = offset / 100000000.0; position = myobj->engine->media_duration * relative; // g_print ("offset: %ld relative: %f", offset, relative); engine_seek (myobj->engine, position, FALSE); handle_result (invocation, ret, error); } }