void inet_reader::run(HINTERNET handle) { vector<char> buffer; while(true) { DWORD available=0; if(!InternetQueryDataAvailable(handle,&available,0,NULL)) break; if(!available) break; buffer.resize(max(max(1,available),buffer.size())); __int64 bytes_to_read=(__int64)buffer.size(); if(_bytes_to_read>=0) bytes_to_read=min(bytes_to_read,_bytes_to_read-_bytes_read); DWORD bytes_read=0; if(!InternetReadFile(handle,&buffer[0],(DWORD)bytes_to_read,&bytes_read)) break; _bytes_read+=bytes_read; if(bytes_read) if(!read(&buffer[0],(long)bytes_read)) break; if(_bytes_read==_bytes_to_read) break; } on_stop(); }
void VideoItem::createPanel() { _panel = new VideoControlPanel(this); _panel->setParentItem(this); setPanelPosition(); _panel->setVolume(_player->volume()); // _panel->show(); _panel->hide(); connect (this, SIGNAL(playMedia()), _panel, SLOT(on_play())); connect (this, SIGNAL(pauseMedia()), _panel, SLOT(on_pause())); connect (this, SIGNAL(stopMedia()), _panel, SLOT(on_stop())); connect (_panel, SIGNAL(positionChanged(qint64)), _player, SLOT(setPosition(qint64))); connect (_panel, SIGNAL(playClicked()), _player, SLOT(play())); connect (_panel, SIGNAL(pauseClicked()), _player, SLOT(pause())); connect (_panel, SIGNAL(volumeChanged(int)), _player, SLOT(setVolume(int))); }
void msg_server::stop() { _is_stop = true; on_stop(); net_core.stop(); }
void IgcReplay::Stop() { CloseFile(); on_stop(); Enabled = false; }
static void add_event_all (const int event, const void *data) { int i; int added = 0; if (event == EV_STATE) { switch (audio_get_state()) { case STATE_PLAY: on_song_change (); break; case STATE_STOP: on_stop (); break; } } for (i = 0; i < CLIENTS_MAX; i++) { void *data_copy = NULL; if (clients[i].socket == -1) continue; if (!clients[i].wants_plist_events && is_plist_event (event)) continue; if (data) { if (event == EV_PLIST_ADD || event == EV_QUEUE_ADD) { data_copy = plist_new_item (); plist_item_copy (data_copy, data); } else if (event == EV_PLIST_DEL || event == EV_QUEUE_DEL || event == EV_STATUS_MSG || event == EV_SRV_ERROR) { data_copy = xstrdup (data); } else if (event == EV_PLIST_MOVE || event == EV_QUEUE_MOVE) data_copy = move_ev_data_dup ( (struct move_ev_data *) data); else logit ("Unhandled data!"); } add_event (&clients[i], event, data_copy); added++; } if (added) wake_up_server (); else debug ("No events have been added because there are no clients"); }
void monitor::stop() { // Stopping a monitor is a cooperative task: the caller request a task to // stop and it's responsibility of each monitor to check for this flag and // timely stop the processing loop. FSW_MONITOR_RUN_GUARD; if (!this->running || this->should_stop) return; FSW_ELOG(_("Stopping the monitor.\n")); this->should_stop = true; on_stop(); }
void NativeEngine::handle_cmd(int32_t cmd){ switch (cmd) { case APP_CMD_INPUT_CHANGED: on_input_changed(); break; case APP_CMD_INIT_WINDOW: on_init_window(); break; case APP_CMD_TERM_WINDOW: on_term_window(); break; case APP_CMD_WINDOW_RESIZED: on_window_resized(); break; case APP_CMD_WINDOW_REDRAW_NEEDED: on_window_redraw_needed(); break; case APP_CMD_CONTENT_RECT_CHANGED: on_content_rect_changed(); break; case APP_CMD_GAINED_FOCUS: on_gained_focus(); break; case APP_CMD_LOST_FOCUS: on_lost_focus(); break; case APP_CMD_CONFIG_CHANGED: on_config_changed(); break; case APP_CMD_LOW_MEMORY: on_low_memory(); break; case APP_CMD_START: on_start(); break; case APP_CMD_RESUME: on_resume(); break; case APP_CMD_SAVE_STATE: on_save_state(); break; case APP_CMD_PAUSE: on_pause(); break; case APP_CMD_STOP: on_stop(); break; case APP_CMD_DESTROY: on_destroy(); break; } }
void MultiFrameCtrl::on_play() { if(m_display == NULL) { return; } if(m_display->get_playing()) { on_stop(); return; } m_play->set_label(Gtk::Stock::MEDIA_STOP.id); m_display->play(); }
astra_status_t stop() { if (!isStarted_) return astra_status_t::ASTRA_STATUS_SUCCESS; auto rc = on_stop(); if (rc == astra_status_t::ASTRA_STATUS_SUCCESS) { isStarted_ = false; listener_.on_stopped(this); } return rc; }
int App::start(){ int iret = 0; bool bret = 0; while (true){ app_tick_update(impl_); if (impl_->stoping){ //need stop bret = on_stop(); if (bret){ break; } continue; } if (impl_->restarting){//need restart bret = on_restart(); if (bret){ break; } continue; } if (impl_->reloading){//need reload _app_reload_env(impl_); iret = on_reload(); if (iret){ GLOG_ERR("reload error ret :%d !", iret); } impl_->reloading = false; } //running if (impl_->stcp) { //one tick , one us ? iret += dctcp_poll(impl_->stcp, impl_->maxtptick, impl_->maxtptick); } iret = on_loop(); if (iret == 0){ on_idle(); } } iret = impl_->shm_pool.stop(); if (iret){ GLOG_ERR("shm pool stop error ret:%d", iret); } return on_exit(); }
void quit_spectrum3d(){ on_stop(); gtk_main_quit(); }
int main(int argc, char *argv[]) { printf("%s \nPlease report any bug to %s\n", PACKAGE_STRING, PACKAGE_BUGREPORT); //printf("number of arg = %d, argv = %s\n", argc, argv[1]); /*printf("argc = %d\n", argc); if (argv[1] != NULL) { if (strstr (argv[1],"debug") != NULL) { debug = TRUE; printf("debug = TRUE\n"); } } DEBUG("debug is true\n");*/ gchar *filename; int i = 0; gint initialWindowHeight = 170; guint timeoutEvent, intervalDisplaySpectro; GtkWidget *pVBox[4], *pHBox[13], *menuBar, *menu, *submenu, *menuItem, *submenuItem, *button, *frame, *image, *label, *widget; GdkColor color; Spectrum3dGui spectrum3dGui; GSList *radio_menu_group; GError **error; #if defined (GTKGLEXT3) || defined (GTKGLEXT1) GdkGLConfig *glconfig; #endif gst_init (NULL, NULL); gtk_init (&argc, &argv); get_saved_values(); intervalDisplaySpectro = (guint)spectrum3d.interval_display; #if defined (GTKGLEXT3) || defined (GTKGLEXT1) gtk_gl_init(NULL, NULL); glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (glconfig == NULL) { g_print ("\n*** Cannot find the double-buffered visual.\n"); g_print ("\n*** Trying single-buffered visual.\n"); /* Try single-buffered visual */ glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH); if (glconfig == NULL) { g_print ("*** No appropriate OpenGL-capable visual found.\n"); exit (1); } } #endif initGstreamer(); init_audio_values(); init_display_values(&spectrum3dGui); spectrum3dGui.mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (spectrum3dGui.mainWindow, 700, initialWindowHeight); gtk_widget_realize(spectrum3dGui.mainWindow); gtk_window_set_title(GTK_WINDOW(spectrum3dGui.mainWindow), PACKAGE_NAME); filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "spectrum3d.png", NULL); gtk_window_set_icon(GTK_WINDOW(spectrum3dGui.mainWindow), gdk_pixbuf_new_from_file (filename, error)); g_signal_connect (G_OBJECT (spectrum3dGui.mainWindow), "destroy", G_CALLBACK (quit_spectrum3d), NULL); #ifdef GTK3 gtk_container_set_reallocate_redraws (GTK_CONTAINER (spectrum3dGui.mainWindow), TRUE); #endif #ifdef GTK3 for (i = 0; i < 4; i++) { pVBox[i] = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); } pHBox[0] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); for (i = 1; i < 12; i++) { pHBox[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); } pHBox[12] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); #elif defined GTK2 for (i = 0; i < 4; i++) { pVBox[i] = gtk_vbox_new(FALSE, 0); } pHBox[0] = gtk_hbox_new(TRUE, 0); for (i = 1; i < 12; i++) { pHBox[i] = gtk_hbox_new(FALSE, 0); } pHBox[12] = gtk_hbox_new(TRUE, 0); #endif gtk_container_add(GTK_CONTAINER(spectrum3dGui.mainWindow), pVBox[1]); gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[0], FALSE, FALSE, 0); /* Menu */ menuBar = gtk_menu_bar_new(); menu = gtk_menu_new(); // 'Quit' submenu menuItem = gtk_menu_item_new_with_label("Quit"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(gtk_main_quit), NULL); menuItem = gtk_menu_item_new_with_label("Quit"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem); menu = gtk_menu_new(); // 'Edit' submenu menuItem = gtk_menu_item_new_with_label("Preferences"); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onPreferences), &spectrum3dGui); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); menuItem = gtk_menu_item_new_with_label("Edit"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem); menu = gtk_menu_new(); // 'Sound' submenu menuItem = gtk_menu_item_new_with_label("Sound"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem); submenu = gtk_menu_new();// 'Play test sound' sub-submenu spectrum3dGui.checkMenuTestSound = gtk_check_menu_item_new_with_label("Test Sound"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), spectrum3dGui.checkMenuTestSound); g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuTestSound), "activate", G_CALLBACK(menu_check_test_sound), &spectrum3dGui); menu = gtk_menu_new(); // 'View' submenu menuItem = gtk_menu_item_new_with_label("View"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem); submenu = gtk_menu_new();// 'viewType' sub-submenu menuItem = gtk_menu_item_new_with_label("Perspective"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); spectrum3dGui.radio3D = gtk_radio_menu_item_new_with_label(NULL, "3D (D)"); radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3D)); g_signal_connect(G_OBJECT(spectrum3dGui.radio3D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3D); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3D); spectrum3dGui.radio3Dflat = gtk_radio_menu_item_new_with_label(radio_menu_group, "3D flat (F)"); radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3Dflat)); g_signal_connect(G_OBJECT(spectrum3dGui.radio3Dflat), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3Dflat); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3Dflat); spectrum3dGui.radio2D = gtk_radio_menu_item_new_with_label(radio_menu_group, "2D (D)"); radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio2D)); g_signal_connect(G_OBJECT(spectrum3dGui.radio2D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio2D); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio2D); submenu = gtk_menu_new();// 'Scale' sub-submenu menuItem = gtk_menu_item_new_with_label("Scale"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); spectrum3dGui.checkMenuText = gtk_check_menu_item_new_with_label("Text (T)"); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuText), TRUE); g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuText), "activate", G_CALLBACK(check_menu_text), &spectrum3dGui); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuText); spectrum3dGui.checkMenuLines = gtk_check_menu_item_new_with_label("Lines (L)"); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuLines), TRUE); g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuLines), "activate", G_CALLBACK(check_menu_lines), &spectrum3dGui); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuLines); spectrum3dGui.checkMenuPointer = gtk_check_menu_item_new_with_label("Pointer (P)"); g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuPointer), "activate", G_CALLBACK(check_menu_pointer), &spectrum3dGui); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuPointer); submenu = gtk_menu_new();// 'Change/reset view' sub-submenu menuItem = gtk_menu_item_new_with_label("Change/reset view"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); spectrum3dGui.reset = gtk_menu_item_new_with_label("Reset view (R)"); gtk_widget_set_tooltip_text (spectrum3dGui.reset, "Reset the view as if Spectrum3d was just started"); g_signal_connect(G_OBJECT(spectrum3dGui.reset), "activate", G_CALLBACK(reset_view), spectrum3dGui.reset); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.reset); spectrum3dGui.front = gtk_menu_item_new_with_label("Front view (O)"); gtk_widget_set_tooltip_text (spectrum3dGui.front, "2D view showing frequency versus intensity of the sound; shows a snapshot of the harmonics at a given time"); g_signal_connect(G_OBJECT(spectrum3dGui.front), "activate", G_CALLBACK(front_view), spectrum3dGui.front); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.front); submenuItem = gtk_menu_item_new_with_label("Preset view"); gtk_widget_set_tooltip_text (submenuItem, "Set the view with the chosen preset values"); g_signal_connect(G_OBJECT(submenuItem), "activate", G_CALLBACK(set_view_from_preset), submenuItem); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), submenuItem); menu = gtk_menu_new(); // 'Help...' submenu menuItem = gtk_menu_item_new_with_label("Shortcuts"); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onShortcuts), (GtkWidget*) spectrum3dGui.mainWindow); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); #ifdef HAVE_LIBGEIS menuItem = gtk_menu_item_new_with_label("Gestures Shortcuts"); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onGesturesShortcuts), (GtkWidget*) spectrum3dGui.mainWindow); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); #endif menuItem = gtk_menu_item_new_with_label("About..."); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onAbout), (GtkWidget*) spectrum3dGui.mainWindow); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); menuItem = gtk_menu_item_new_with_label("Quick start"); g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onQuickStart), (GtkWidget*) spectrum3dGui.mainWindow); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem); menuItem = gtk_menu_item_new_with_label("Help"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem); gtk_box_pack_start(GTK_BOX(pHBox[0]), menuBar, FALSE, TRUE, 0); /* SourceButtons to set type of source (none, audio file, microphone) */ spectrum3dGui.stop = gtk_button_new(); filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "stop.png", NULL); image = gtk_image_new_from_file(filename); gtk_button_set_image(GTK_BUTTON(spectrum3dGui.stop),image); gdk_color_parse ("gold",&color); gtk_widget_set_name(spectrum3dGui.stop, "stop"); gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_NORMAL, &color); gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_PRELIGHT, &color); gtk_widget_set_tooltip_text (spectrum3dGui.stop, "Stop playing everything; no source of playing"); gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[1], FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.stop, FALSE, TRUE, 2); g_signal_connect(G_OBJECT(spectrum3dGui.stop), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui); filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "microphone_grey.png", NULL); image = gtk_image_new_from_file(filename); spectrum3dGui.mic = gtk_button_new(); gtk_button_set_image (GTK_BUTTON(spectrum3dGui.mic), image); gtk_widget_set_name(spectrum3dGui.mic, "mic"); gtk_widget_set_tooltip_text (spectrum3dGui.mic, "Source is microphone; select this to record something and then load it"); gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.mic, FALSE, TRUE, 2); g_signal_connect(G_OBJECT(spectrum3dGui.mic), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui); spectrum3dGui.file = gtk_button_new(); filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "file_grey.png", NULL); image = gtk_image_new_from_file(filename); gtk_button_set_image(GTK_BUTTON(spectrum3dGui.file),image); gtk_widget_set_name(spectrum3dGui.file, "file"); gtk_widget_set_tooltip_text (spectrum3dGui.file, "Source is an audio file"); gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.file, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(spectrum3dGui.file), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui); spectrum3dGui.reload = gtk_button_new(); image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_button_set_image(GTK_BUTTON(spectrum3dGui.reload),image); gtk_widget_set_sensitive (spectrum3dGui.reload, FALSE); gtk_widget_set_tooltip_text (spectrum3dGui.reload, "Reload audio file (usefull if some audio parameters like equalizer or filters have been changed)"); gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.reload, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(spectrum3dGui.reload), "clicked", G_CALLBACK(load_audio_file), NULL); widget = gtk_check_button_new_with_label("Analyse in\nrealtime"); gtk_widget_set_tooltip_text (GTK_WIDGET(widget), "If checked, harmonics will be analysed and displayed at the same time; if unchecked, harmonics will be analysed first, then displayed for the whole audio file, then it can be played afterwards"); gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(set_analyse_in_rt), &spectrum3dGui); /* separator */ #ifdef GTK3 widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL); #elif defined GTK2 widget = gtk_vseparator_new(); #endif gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5); /* "Play/Pause" button */ playButton = gtk_button_new(); gtk_widget_set_tooltip_text (playButton, "Play/Pause the audio stream"); setPlayButtonIcon(); gtk_widget_set_size_request (playButton, 50, 20); gtk_box_pack_start(GTK_BOX(pHBox[1]), playButton, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(playButton), "clicked", G_CALLBACK(playFromSource), "NO_MESSAGE"); /* "Stop" button */ button = gtk_button_new(); gtk_widget_set_tooltip_text (button, "Stop playing audio stream"); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_button_set_image(GTK_BUTTON(button),image); gtk_box_pack_start(GTK_BOX(pHBox[1]), button, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_stop), NULL); /* "Record" button */ spectrum3dGui.record = gtk_button_new(); gtk_widget_set_tooltip_text (spectrum3dGui.record, "Record from microphone"); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_button_set_image(GTK_BUTTON(spectrum3dGui.record),image); gtk_widget_set_sensitive (spectrum3dGui.record, FALSE); gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.record, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(spectrum3dGui.record), "clicked", G_CALLBACK(record_window), NULL); /* separator */ #ifdef GTK3 widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL); #elif defined GTK2 widget = gtk_vseparator_new(); #endif gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5); /* JACK check button */ filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "qjackctl.png", NULL); image = gtk_image_new_from_file(filename); widget = gtk_check_button_new (); gtk_button_set_image (GTK_BUTTON(widget), image); gtk_widget_set_tooltip_text (widget, "Use Jack-Audio-Connection-Kit (JACK)"); gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 2); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(use_jack), &spectrum3dGui); /* separator */ #ifdef GTK3 widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL); #elif defined GTK2 widget = gtk_vseparator_new(); #endif gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5); /* Button to open the Filter and Equalizer window */ // create effectsWindow first without showing it effects_window(&spectrum3dGui); // then create a button that will call its display when clicked filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "equalizer.png", NULL); image = gtk_image_new_from_file(filename); widget = gtk_button_new(); gtk_button_set_image (GTK_BUTTON(widget), image); gtk_widget_set_tooltip_text (widget, "Show/Hide the filter and equalizer window"); gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(show_effects_window), &spectrum3dGui); /* Time label */ label=gtk_label_new("Time : "); gtk_box_pack_start(GTK_BOX(pHBox[5]), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[5], FALSE, FALSE, 2); /* Progress & seek scale */ #ifdef GTK3 scaleSeek = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1); #elif defined GTK2 scaleSeek = gtk_hscale_new_with_range (0.0, 100.0, 1); #endif gtk_scale_set_draw_value (GTK_SCALE (scaleSeek), FALSE); //gtk_scale_set_value_pos (GTK_SCALE (pScaleSeek), GTK_POS_TOP); gtk_range_set_value (GTK_RANGE (scaleSeek), 0); gtk_widget_set_size_request (scaleSeek, 500, 20); gtk_box_pack_start(GTK_BOX(pHBox[5]), scaleSeek, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(scaleSeek), "value-changed", G_CALLBACK(on_seek), NULL); timeLabel=gtk_label_new(" 0:00 / 0:00 "); gtk_box_pack_start(GTK_BOX(pHBox[5]), timeLabel, FALSE, FALSE, 0); /* Create drawing area */ if (externalWindow == FALSE){ /* Resize spectrum3dGui.mainWindow to contain drawing_area; using gtk_window_set_defaut() allows to shrink the window (gtk_widget_set_size_request() does not allow to shrink the window below the requested size); */ gtk_window_set_default_size (GTK_WINDOW(spectrum3dGui.mainWindow), (gint)spectrum3d.width, initialWindowHeight + (gint)spectrum3d.height); //gtk_widget_realize(spectrum3dGui.mainWindow); spectrum3dGui.drawing_area = gtk_drawing_area_new (); #if defined (GTKGLEXT3) || defined (GTKGLEXT1) /* Set OpenGL-capability to the widget */ gtk_widget_set_gl_capability (spectrum3dGui.drawing_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); #endif /* drawing_area has to be put in vBox AFTER the call to gtk_widget_set_gl_capability() (if GtkGlExt is used) and BEFORE the call to the sdl-gtk hack (if sdl is used)*/ gtk_box_pack_start (GTK_BOX (pVBox[1]), spectrum3dGui.drawing_area, TRUE, TRUE, 0); #ifdef HAVE_LIBSDL /* Hack to get SDL to use GTK window */ { char SDL_windowhack[32]; sprintf(SDL_windowhack,"SDL_WINDOWID=%ld", GDK_WINDOW_XID(gtk_widget_get_window(spectrum3dGui.drawing_area))); // GDK_WINDOW_XID( spectrum3dGui.drawing_area->window))); pour GTK2?? putenv(SDL_windowhack); printf("%s\n", SDL_windowhack); } if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } #endif g_signal_connect (spectrum3dGui.mainWindow, "key-press-event", G_CALLBACK (on_key_press), &spectrum3dGui); g_signal_connect (spectrum3dGui.mainWindow, "key-release-event", G_CALLBACK (on_key_release), &spectrum3dGui); g_signal_connect (spectrum3dGui.mainWindow, "motion-notify-event", G_CALLBACK (on_mouse_motion), NULL); g_signal_connect (spectrum3dGui.mainWindow, "scroll-event", G_CALLBACK (on_mouse_scroll), NULL); g_signal_connect (G_OBJECT (spectrum3dGui.drawing_area), "configure_event", G_CALLBACK (configure_event), NULL); gtk_widget_add_events (spectrum3dGui.mainWindow, gtk_widget_get_events (spectrum3dGui.mainWindow) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK); } else { create_external_window_drawing_area(&spectrum3dGui); } /* Starting value of the display */ frame = gtk_frame_new("Start value of display (in Hz)"); gtk_widget_set_tooltip_text (frame, "The lower displayed frequency (in herz)"); spectrum3dGui.adjustStart = gtk_adjustment_new(0, 0, 9000, ((gdouble)hzStep * (gdouble)zoomFactor), (((gdouble)hzStep * (gdouble)zoomFactor) * 10), 0); #ifdef GTK3 pScaleStart = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustStart)); #elif defined GTK2 pScaleStart = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustStart)); #endif gtk_scale_set_digits (GTK_SCALE(pScaleStart), 0); gtk_scale_set_value_pos(GTK_SCALE(pScaleStart), GTK_POS_RIGHT); gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[11], FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), pScaleStart); g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(change_start), &spectrum3dGui); g_signal_connect(G_OBJECT(pScaleStart), "format-value", G_CALLBACK(format_value_start), NULL); g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui); /* Range of display */ frame = gtk_frame_new("Range of display (in Hz)"); gtk_widget_set_tooltip_text (frame, "The range of the displayed frequency (in herz)"); spectrum3dGui.adjustBands = gtk_adjustment_new(1000, 20, 1000, 10, 50, 0); #ifdef GTK3 spectrum3dGui.scaleBands = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustBands)); #elif defined GTK2 spectrum3dGui.scaleBands = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustBands)); #endif gtk_scale_set_digits (GTK_SCALE(spectrum3dGui.scaleBands), 0); gtk_scale_set_value_pos(GTK_SCALE(spectrum3dGui.scaleBands), GTK_POS_RIGHT); gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleBands); gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(change_bands), &spectrum3dGui); g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "format-value", G_CALLBACK(format_value_bands), NULL); g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui); /* "x" label */ label=gtk_label_new("x"); gtk_container_add(GTK_CONTAINER(pHBox[11]), label); /* Factor that multiplies the range of display */ frame = gtk_frame_new(""); gtk_widget_set_tooltip_text (frame, "Factor that multiplies the frequency range, to make it larger"); spectrum3dGui.cbRange = gtk_combo_box_text_new(); gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.cbRange); gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0); for (i = 1; i <= 20; i++){ gchar text[4]; sprintf(text, "%d", i); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spectrum3dGui.cbRange), text); } gtk_combo_box_set_active(GTK_COMBO_BOX(spectrum3dGui.cbRange), 0); g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK( cb_range_changed ), &spectrum3dGui ); g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui ); /* Label that shows starting value, ending value and range of display */ frame = gtk_frame_new("Values displayed"); gtk_widget_set_tooltip_text (frame, "The lower and the highest displayed value (in herz), and their range"); displayLabel=gtk_label_new(""); gtk_container_add(GTK_CONTAINER(frame), displayLabel); getTextDisplayLabel(NULL, &spectrum3dGui); gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0); /* 'Gain' Gtk Scale */ frame = gtk_frame_new("Display Gain"); gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 10); filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "gain.png", NULL); image = gtk_image_new_from_file(filename); spectrum3dGui.scaleGain = gtk_scale_button_new (GTK_ICON_SIZE_LARGE_TOOLBAR, 0, 1, 0.01, NULL); gtk_button_set_image(GTK_BUTTON(spectrum3dGui.scaleGain),image); //gtk_button_set_label (GTK_BUTTON(spectrum3dGui.scaleGain), "GAIN"); gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleGain); //gtk_box_pack_start(GTK_BOX(pHBox[11]), pScaleGain, FALSE, FALSE, 0); //gtk_widget_set_size_request (pScaleGain, 200, 20); //gtk_scale_set_value_pos(GTK_SCALE(pScaleGain), GTK_POS_RIGHT); gtk_widget_set_tooltip_text (spectrum3dGui.scaleGain, "Adjust the displayed level of the intensity of the sound"); gtk_scale_button_set_value(GTK_SCALE_BUTTON(spectrum3dGui.scaleGain), 0.2); // FIXME error message here with the previous line : gtk_image_set_from_stock: assertion `GTK_IS_IMAGE (image)' failed; it could be a bug in Gtk //g_object_set (pScaleGain, "update-policy", GTK_UPDATE_DISCONTINUOUS, NULL); g_signal_connect(G_OBJECT(spectrum3dGui.scaleGain), "value-changed", G_CALLBACK(change_gain), NULL); #ifdef HAVE_LIBGEIS setupGeis(); #endif gtk_widget_show_all (spectrum3dGui.mainWindow); //timeoutEvent = g_timeout_add (100, (GSourceFunc)sdl_event, &spectrum3dGui); spectrum3d.timeoutExpose = g_timeout_add (intervalDisplaySpectro, (GSourceFunc)display_spectro, &spectrum3dGui); printf("Showing Gtk GUI\n"); gtk_main (); /* Quit everything */ #ifdef HAVE_LIBGEIS geisQuit(); #endif on_stop(); g_source_remove(spectrum3d.timeoutExpose); #ifdef HAVE_LIBSDL //g_source_remove(timeoutEvent); SDL_Quit(); #endif print_rc_file(); printf("Quit everything\nGood Bye!\n"); return 0; }
void concurrency_handler::on_yield(std::shared_ptr<profiler> &p) { on_stop(p); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->starttime->setText("0"); ui->simurate->setText("1"); ///create node //STM32 MCU Simulator* stm32comm = new Simulator(library, "Sensor_stm32comm", "stm32comm", config, QTime(),1); stm32comm->setOutputNodesName(QList<QString>()<<"stm32comm_viewer;stm32comm_storage;doordetection;simplecollect;planner"); VisualizationMono* stm32comm_viewer = new VisualizationMono(library, "Sensor_stm32comm", "stm32comm_viewer", config); stm32comm_viewer->setInputNodesName(QList<QString>()<<"stm32comm"); stm32comm_viewer->connectExternalTrigger(0, DRAINSLOT); //LCamera Simulator* l_camera = new Simulator(library, "Sensor_Camera", "l_camera", config, QTime(),1); l_camera->setOutputNodesName(QList<QString>()<<"l_camera_viewer;l_camera_storage;cameralasercalib"); VisualizationMono* l_camera_viewer = new VisualizationMono(library, "Sensor_Camera", "l_camera_viewer", config); l_camera_viewer->setInputNodesName(QList<QString>()<<"l_camera"); l_camera_viewer->connectExternalTrigger(0, DRAINSLOT); //RCamera Simulator* r_camera = new Simulator(library, "Sensor_Camera", "r_camera",config, QTime(),1); r_camera->setOutputNodesName(QList<QString>()<<"r_camera_viewer"); VisualizationMono*r_camera_viewer = new VisualizationMono(library, "Sensor_Camera", "r_camera_viewer", config); r_camera_viewer->setInputNodesName(QList<QString>()<<"r_camera"); r_camera_viewer->connectExternalTrigger(0, DRAINSLOT); //Laser Simulator* laser = new Simulator(library, "Sensor_Laser", "laser", config, QTime(),1); laser->setOutputNodesName(QList<QString>()<<"laser_viewer;doordetection;simplecollect;calib;cameralasercalib"); VisualizationMono* laser_viewer = new VisualizationMono(library, "Sensor_Laser", "laser_viewer", config); laser_viewer->setInputNodesName(QList<QString>()<<"laser"); laser_viewer->connectExternalTrigger(0, DRAINSLOT); //camera laser calib ProcessorMulti* cameralasercalib = new ProcessorMulti(library, "Processor_CameraLaser", "cameralasercalib", config); cameralasercalib->setInputNodesName(QList<QString>()<<"l_camera"<<"laser"); cameralasercalib->setOutputNodesName(QList<QString>()<<"cameralasercalib_viewer"); cameralasercalib->connectExternalTrigger(1,PROCESSORSLOT); VisualizationMono *cameralasercalib_viewer = new VisualizationMono(library, "Processor_CameraLaser", "cameralasercalib_viewer", config); cameralasercalib_viewer->setInputNodesName(QList<QString>()<<"cameralasercalib"); cameralasercalib_viewer->connectExternalTrigger(0, DRAINSLOT); //calibration VisualizationMono *laserCalib = new VisualizationMono(library, "Calibration_Laser", "calib", config); laserCalib->setInputNodesName(QList<QString>()<<"laser"); laserCalib->connectExternalTrigger(0, DRAINSLOT); //Path ProcessorMono* pathPlanner = new ProcessorMono(library, "Processor_PathGenerator", "planner", config); pathPlanner->setInputNodesName(QList<QString>() << "stm32comm"); pathPlanner->setOutputNodesName(QList<QString>() << "plannerViewer"); pathPlanner->connectExternalTrigger(0, PROCESSORSLOT); VisualizationMono* pathPlannerViewer = new VisualizationMono(library, "Processor_PathGenerator", "plannerViewer", config); pathPlannerViewer->setInputNodesName(QList<QString>() << "planner"); pathPlannerViewer->connectExternalTrigger(0, DRAINSLOT); //doordetection ProcessorMulti* doordetection = new ProcessorMulti(library,"Processor_doordetection", "doordetection",config); doordetection->setInputNodesName(QList<QString>()<<"laser"<<"stm32comm"); doordetection->setOutputNodesName(QList<QString>()<<"doordetection_viewer;simplecollect"); doordetection->connectExternalTrigger(1, PROCESSORSLOT); VisualizationMono* doordetection_viewer = new VisualizationMono(library,"Processor_doordetection", "doordetection_viewer", config); doordetection_viewer->setInputNodesName(QList<QString>()<<"doordetection"); doordetection_viewer->connectExternalTrigger(0,DRAINSLOT); //simple collect ProcessorMulti* simplecollect = new ProcessorMulti(library,"Processor_SimpleCollect", "simplecollect", config); simplecollect->setInputNodesName(QList<QString>()<<"joystick"<<"laser"<<"stm32comm"<<"doordetection"); simplecollect->setOutputNodesName(QList<QString>()<<"simplecollect_viewer"); simplecollect->connectExternalTrigger(2, PROCESSORSLOT); VisualizationMono* simplecollect_viewer = new VisualizationMono(library,"Processor_SimpleCollect", "simplecollect_viewer",config); simplecollect_viewer->setInputNodesName(QList<QString>()<<"simplecollect"); simplecollect_viewer->connectExternalTrigger(0,DRAINSLOT); ///add node edge.addNode(stm32comm, 1, MONITOR); edge.addNode(stm32comm_viewer, 0, 0); edge.addNode(l_camera, 1, MONITOR); edge.addNode(l_camera_viewer, 0, 0); edge.addNode(r_camera, 1, MONITOR); edge.addNode(r_camera_viewer, 0, 0); edge.addNode(laser, 1, MONITOR); edge.addNode(laser_viewer, 0, 0); edge.addNode(pathPlanner, 1, MONITOR); edge.addNode(pathPlannerViewer, 0, 0); edge.addNode(doordetection, 1, MONITOR); edge.addNode(doordetection_viewer, 0, 0); edge.addNode(cameralasercalib, 1, MONITOR); edge.addNode(cameralasercalib_viewer, 0, 0); // edge.addNode(simplecollect, 1, MONITOR); // edge.addNode(simplecollect_viewer, 0, 0); edge.addNode(laserCalib, 0, 0); edge.connectAll(); connect(ui->open, SIGNAL(clicked()), &edge, SLOT(openAllNodesSlot())); connect(ui->close, SIGNAL(clicked()), &edge, SLOT(closeAllNodesSlot())); connect(ui->setvale, SIGNAL(clicked()), this, SLOT(on_setvalue())); connect(this, SIGNAL(sig_setstarttime(QTime)), stm32comm, SLOT(setStartTimeSlot(QTime))); connect(this,SIGNAL(sig_setsimurate(double)), stm32comm, SLOT(setSimulateRateSlot(double))); connect(this, SIGNAL(sig_setstarttime(QTime)), l_camera, SLOT(setStartTimeSlot(QTime))); connect(this,SIGNAL(sig_setsimurate(double)), l_camera, SLOT(setSimulateRateSlot(double))); connect(this, SIGNAL(sig_setstarttime(QTime)), r_camera, SLOT(setStartTimeSlot(QTime))); connect(this,SIGNAL(sig_setsimurate(double)), r_camera, SLOT(setSimulateRateSlot(double))); connect(this, SIGNAL(sig_setstarttime(QTime)), laser, SLOT(setStartTimeSlot(QTime))); connect(this,SIGNAL(sig_setsimurate(double)), laser, SLOT(setSimulateRateSlot(double))); connect(ui->sync, SIGNAL(clicked()), this, SLOT(on_sync())); connect(this, SIGNAL(sig_sync()), stm32comm, SLOT(syncTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), l_camera, SLOT(syncTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), r_camera, SLOT(syncTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), laser, SLOT(syncTimeTrackSlot())); connect(ui->start, SIGNAL(clicked()), this, SLOT(on_start())); connect(this, SIGNAL(sig_start()), stm32comm, SLOT(startSimulatorSlot())); connect(this, SIGNAL(sig_start()), l_camera, SLOT(startSimulatorSlot())); connect(this, SIGNAL(sig_start()), r_camera, SLOT(startSimulatorSlot())); connect(this, SIGNAL(sig_start()), laser, SLOT(startSimulatorSlot())); connect(ui->stop, SIGNAL(clicked()), this, SLOT(on_stop())); connect(this, SIGNAL(sig_stop()), stm32comm, SLOT(stopSimulatorSlot())); connect(this, SIGNAL(sig_stop()), l_camera, SLOT(stopSimulatorSlot())); connect(this, SIGNAL(sig_stop()), r_camera, SLOT(stopSimulatorSlot())); connect(this, SIGNAL(sig_stop()), laser, SLOT(stopSimulatorSlot())); connect(ui->reset, SIGNAL(clicked()), this, SLOT(on_reset())); connect(this, SIGNAL(sig_sync()), stm32comm, SLOT(resetTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), l_camera, SLOT(resetTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), r_camera, SLOT(resetTimeTrackSlot())); connect(this, SIGNAL(sig_sync()), laser, SLOT(resetTimeTrackSlot())); ///visualazition QList<QWidget *> widgets; widgets = stm32comm_viewer->getVisualizationWidgets(); ui->scrollArea->setWidget(widgets.front()); widgets = laser_viewer->getVisualizationWidgets(); ui->scrollArea_2->setWidget(widgets.front()); // widgets = laserCalib->getVisualizationWidgets(); // ui->scrollArea_3->setWidget(widgets.front()); widgets =cameralasercalib_viewer->getVisualizationWidgets(); ui->scrollArea_3->setWidget(widgets.front()); widgets = l_camera_viewer->getVisualizationWidgets(); ui->scrollArea_4->setWidget(widgets.front()); widgets = r_camera_viewer->getVisualizationWidgets(); ui->scrollArea_5->setWidget(widgets.front()); widgets = doordetection_viewer->getVisualizationWidgets(); ui->scrollArea_6->setWidget(widgets.front()); widgets = pathPlannerViewer->getVisualizationWidgets(); ui->scrollArea_7->setWidget(widgets.front()); // widgets = simplecollect_viewer->getVisualizationWidgets(); // ui->scrollArea_8->setWidget(widgets.front()); if(MONITOR) ui->tabWidget->addTab(&edge, "Monitor"); }
void Chapter::stop() { on_stop(); }