X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvideo_monitor.cc;h=279a3fc9952677d3d1297795460c7456ac6e2f23;hb=a8f11b6004bfd247dd192ef642bffa0a0b46f80f;hp=94c88b1180b7d4be7c46d513b7369f534836d26b;hpb=85ceefd70a194cd68ca49f2b6e251df4bb4b808c;p=ardour.git diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc index 94c88b1180..279a3fc995 100644 --- a/gtk2_ardour/video_monitor.cc +++ b/gtk2_ardour/video_monitor.cc @@ -21,9 +21,11 @@ #include "pbd/convert.h" #include "gui_thread.h" #include "ardour_ui.h" +#include "utils.h" #include #include "public_editor.h" +#include "editor.h" #include "video_monitor.h" #include "i18n.h" @@ -45,7 +47,7 @@ VideoMonitor::VideoMonitor (PublicEditor *ed, std::string xjadeo_bin_path) starting = 0; osdmode = 10; // 1: frameno, 2: timecode, 8: box - process = new SystemExec(xjadeo_bin_path, X_("-R")); + process = new ARDOUR::SystemExec(xjadeo_bin_path, X_("-R")); process->ReadStdout.connect_same_thread (*this, boost::bind (&VideoMonitor::parse_output, this, _1 ,_2)); process->Terminated.connect (*this, invalidator (*this), boost::bind (&VideoMonitor::terminated, this), gui_context()); XJKeyEvent.connect (*this, invalidator (*this), boost::bind (&VideoMonitor::forward_keyevent, this, _1), gui_context()); @@ -92,7 +94,7 @@ VideoMonitor::query_full_state (bool wait) process->write_to_stdin("get osdcfg\n"); int timeout = 40; if (wait && knownstate !=127 && --timeout) { - usleep(50000); + Glib::usleep(50000); sched_yield(); } } @@ -111,7 +113,7 @@ VideoMonitor::quit () */ int timeout = 40; while (is_started() && --timeout) { - usleep(50000); + Glib::usleep(50000); sched_yield(); } if (timeout <= 0) { @@ -141,7 +143,7 @@ VideoMonitor::open (std::string filename) * 0x20 : don't use jack-session * 0x40 : no jack-transport control play/pause/rewind */ - process->write_to_stdin("set override 104\n"); + process->write_to_stdin("set override 120\n"); process->write_to_stdin("notify keyboard\n"); process->write_to_stdin("notify settings\n"); process->write_to_stdin("window letterbox on\n"); @@ -198,6 +200,7 @@ void VideoMonitor::send_cmd (int what, int param) { bool osd_update = false; + int prev_osdmode = osdmode; if (!is_started()) return; switch (what) { case 1: @@ -207,17 +210,17 @@ VideoMonitor::send_cmd (int what, int param) case 2: if (param) osdmode |= 2; else osdmode &= ~2; - osd_update = true; + osd_update = (prev_osdmode != osdmode); break; case 3: if (param) osdmode |= 1; else osdmode &= ~1; - osd_update = true; + osd_update = (prev_osdmode != osdmode); break; case 4: if (param) osdmode |= 8; else osdmode &= ~8; - osd_update = true; + osd_update = (prev_osdmode != osdmode); break; case 5: if (param) process->write_to_stdin("window zoom on\n"); @@ -233,7 +236,7 @@ VideoMonitor::send_cmd (int what, int param) default: break; } - if (osd_update >= 0) { + if (osd_update) { std::ostringstream osstream; osstream << "osd mode " << osdmode << "\n"; process->write_to_stdin(osstream.str()); } @@ -248,33 +251,9 @@ VideoMonitor::is_started () void VideoMonitor::forward_keyevent (unsigned int keyval) { -#if 0 // TODO just 'fake' keyboard input - GdkEventKey ev; - ev.type = GDK_KEY_PRESS; - ev.window = NULL; // XXX - ev.send_event = TRUE; - ev.time = 0; - ev.state = 0; - ev.keyval = keyval; - ev.length = 1; - ev.string = NULL; - ev.hardware_keycode = 0; - ev.group = 0; - - PublicEditor::instance().on_key_press_event(&ev); - ev.type = GDK_KEY_RELEASE; - PublicEditor::instance().on_key_press_event(&ev); -#else - if (keyval == GDK_KEY_space) { - if(_session->transport_rolling ()) { - _session->request_transport_speed (0.0); - } else { - _session->request_transport_speed (1.0f); - } - } else if (keyval == GDK_KEY_BackSpace) { - _session->goto_start (); - } -#endif + Editor* ed = dynamic_cast(&PublicEditor::instance()); + if (!ed) return; + emulate_key_event(ed, keyval); } void @@ -443,8 +422,9 @@ void VideoMonitor::save_session () { if (!_session) { return; } - XMLNode* node = _session->extra_xml (X_("XJSettings")); + XMLNode* node = _session->extra_xml (X_("XJSettings"), true); if (!node) return; + node->remove_nodes_and_delete("XJSetting"); for(XJSettings::const_iterator it = xjadeo_settings.begin(); it != xjadeo_settings.end(); ++it) { XMLNode* child = node->add_child (X_("XJSetting")); @@ -471,16 +451,6 @@ VideoMonitor::set_session (ARDOUR::Session *s) } } -void -VideoMonitor::clear_session_state () -{ - xjadeo_settings.clear(); - if (!_session) { return; } - XMLNode* node = new XMLNode(X_("XJSettings")); - _session->add_extra_xml (*node); - _session->set_dirty (); -} - bool VideoMonitor::set_custom_setting (const std::string k, const std::string v) { @@ -511,21 +481,23 @@ VideoMonitor::set_offset (ARDOUR::frameoffset_t offset) if (offset == NO_OFFSET ) { return; } framecnt_t video_frame_offset; - framecnt_t audio_frame_rate; + framecnt_t audio_sample_rate; if (_session->config.get_videotimeline_pullup()) { - audio_frame_rate = _session->frame_rate(); + audio_sample_rate = _session->frame_rate(); } else { - audio_frame_rate = _session->nominal_frame_rate(); + audio_sample_rate = _session->nominal_frame_rate(); } /* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */ if (_session->config.get_use_video_file_fps()) { - video_frame_offset = floor(offset * fps / audio_frame_rate); + video_frame_offset = floor(offset * fps / audio_sample_rate); } else { - video_frame_offset = floor(offset * _session->timecode_frames_per_second() / audio_frame_rate); + video_frame_offset = floor(offset * _session->timecode_frames_per_second() / audio_sample_rate); } - // TODO remember if changed.. + if (video_offset == video_frame_offset) { return; } + video_offset = video_frame_offset; + std::ostringstream osstream1; osstream1 << -1 * video_frame_offset; process->write_to_stdin("set offset " + osstream1.str() + "\n"); } @@ -536,18 +508,18 @@ VideoMonitor::manual_seek (framepos_t when, bool /*force*/, ARDOUR::frameoffset_ if (!is_started()) { return; } if (!_session) { return; } framecnt_t video_frame; - framecnt_t audio_frame_rate; + framecnt_t audio_sample_rate; if (_session->config.get_videotimeline_pullup()) { - audio_frame_rate = _session->frame_rate(); + audio_sample_rate = _session->frame_rate(); } else { - audio_frame_rate = _session->nominal_frame_rate(); + audio_sample_rate = _session->nominal_frame_rate(); } /* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */ if (_session->config.get_use_video_file_fps()) { - video_frame = floor(when * fps / audio_frame_rate); + video_frame = floor(when * fps / audio_sample_rate); } else { - video_frame = floor(when * _session->timecode_frames_per_second() / audio_frame_rate); + video_frame = floor(when * _session->timecode_frames_per_second() / audio_sample_rate); } if (video_frame < 0 ) video_frame = 0; @@ -582,7 +554,7 @@ VideoMonitor::xjadeo_sync_setup () bool my_manual_seek = true; if (_session->config.get_external_sync()) { - if (ARDOUR::Config->get_sync_source() == ARDOUR::JACK) + if (ARDOUR::Config->get_sync_source() == ARDOUR::Engine) my_manual_seek = false; }