X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvideo_monitor.cc;h=cb146e4ea5f6ac0d10da13b6b12fffde70e9c98b;hb=d6e96a688dda3a9fa8fbb4c3a60526475aabb7bc;hp=ae4d5faacc2ce008d230d818e2024a6de6fe2e96;hpb=a6e0b60ae1df3676ba45eeb302108eecfe7a7797;p=ardour.git diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc index ae4d5faacc..cb146e4ea5 100644 --- a/gtk2_ardour/video_monitor.cc +++ b/gtk2_ardour/video_monitor.cc @@ -20,7 +20,7 @@ #include "pbd/file_utils.h" #include "pbd/convert.h" #include "gui_thread.h" -#include "ardour_ui.h" +#include "timers.h" #include "utils.h" #include @@ -28,17 +28,18 @@ #include "editor.h" #include "video_monitor.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace PBD; +using namespace ARDOUR_UI_UTILS; VideoMonitor::VideoMonitor (PublicEditor *ed, std::string xjadeo_bin_path) : editor (ed) { - manually_seeked_frame = 0; + manually_seeked_sample = 0; fps =0.0; // = _session->timecode_frames_per_second(); - sync_by_manual_seek = false; + sync_by_manual_seek = true; _restore_settings_mask = 0; clock_connection = sigc::connection(); state_connection = sigc::connection(); @@ -47,7 +48,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 -J")); 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()); @@ -71,7 +72,7 @@ VideoMonitor::start () return true; } - manually_seeked_frame = 0; + manually_seeked_sample = 0; sync_by_manual_seek = false; if (clock_connection.connected()) { clock_connection.disconnect(); } @@ -125,9 +126,8 @@ void VideoMonitor::open (std::string filename) { if (!is_started()) return; - manually_seeked_frame = 0; + manually_seeked_sample = 0; osdmode = 10; // 1: frameno, 2: timecode, 8: box - sync_by_manual_seek = false; starting = 15; process->write_to_stdin("load " + filename + "\n"); process->write_to_stdin("set fps -1\n"); @@ -135,15 +135,17 @@ VideoMonitor::open (std::string filename) process->write_to_stdin("window ontop on\n"); process->write_to_stdin("set seekmode 1\n"); /* override bitwise flags -- see xjadeo.h - * 0x01 : ignore 'q', ESC / quite - * 0x02 : ignore "window closed by WM" / quit - * 0x04 : (osx only) menu-exit / quit - * 0x08 : ignore mouse-button 1 -- resize - * 0x10 : no A/V offset - * 0x20 : don't use jack-session - * 0x40 : no jack-transport control play/pause/rewind + * 0x0001 : ignore 'q', ESC / quit + * 0x0002 : ignore "window closed by WM" / quit + * 0x0004 : (osx only) menu-exit / quit + * 0x0008 : ignore mouse-button 1 -- resize + * 0x0010 : no A/V offset control with keyboard + * 0x0020 : don't use jack-session + * 0x0040 : disable jack transport control + * 0x0080 : disallow sync source change (OSX menu) + * 0x0100 : disallow file open (OSX menu, X11 DnD) */ - process->write_to_stdin("set override 120\n"); + process->write_to_stdin("set override 504\n"); process->write_to_stdin("notify keyboard\n"); process->write_to_stdin("notify settings\n"); process->write_to_stdin("window letterbox on\n"); @@ -157,8 +159,10 @@ VideoMonitor::open (std::string filename) querystate(); state_clk_divide = 0; /* TODO once every two second or so -- state_clk_divide hack below */ - state_connection = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::querystate)); + state_connection = Timers::rapid_connect (sigc::mem_fun (*this, &VideoMonitor::querystate)); } + sync_by_manual_seek = true; + clock_connection = Timers::fps_connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate)); xjadeo_sync_setup(); } @@ -251,9 +255,7 @@ VideoMonitor::is_started () void VideoMonitor::forward_keyevent (unsigned int keyval) { - Editor* ed = dynamic_cast(&PublicEditor::instance()); - if (!ed) return; - emulate_key_event(ed, keyval); + emulate_key_event (keyval); } void @@ -382,8 +384,8 @@ VideoMonitor::parse_output (std::string d, size_t /*s*/) osdmode = atoi(value); if (starting || atoi(xjadeo_settings["osd mode"]) != osdmode) { if (!starting && _session) _session->set_dirty (); - if ((osdmode & 1) == 1) { UiState("xjadeo-window-osd-frame-on"); } - if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-frame-off"); } + if ((osdmode & 1) == 1) { UiState("xjadeo-window-osd-sample-on"); } + if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-sample-off"); } if ((osdmode & 2) == 2) { UiState("xjadeo-window-osd-timecode-on"); } if ((osdmode & 2) == 0) { UiState("xjadeo-window-osd-timecode-off"); } if ((osdmode & 8) == 8) { UiState("xjadeo-window-osd-box-on"); } @@ -428,8 +430,8 @@ VideoMonitor::save_session () for(XJSettings::const_iterator it = xjadeo_settings.begin(); it != xjadeo_settings.end(); ++it) { XMLNode* child = node->add_child (X_("XJSetting")); - child->add_property (X_("k"), it->first); - child->add_property (X_("v"), it->second); + child->set_property (X_("k"), it->first); + child->set_property (X_("v"), it->second); } } @@ -439,6 +441,7 @@ VideoMonitor::set_session (ARDOUR::Session *s) { SessionHandlePtr::set_session (s); if (!_session) { return; } + ARDOUR::Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoMonitor::parameter_changed, this, _1), gui_context()); _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoMonitor::parameter_changed, this, _1), gui_context()); XMLNode* node = _session->extra_xml (X_("XJSettings")); if (!node) { return;} @@ -464,35 +467,35 @@ VideoMonitor::get_custom_setting (const std::string k) return (xjadeo_settings[k]); } -#define NO_OFFSET (1<<31) //< skip setting or modifying offset -- TODO check ARDOUR::frameoffset_t max value. +#define NO_OFFSET (Temporal::max_samplepos) //< skip setting or modifying offset void VideoMonitor::srsupdate () { if (!_session) { return; } if (editor->dragging_playhead()) { return ;} - manual_seek(_session->audible_frame(), false, NO_OFFSET); + manual_seek(_session->audible_sample(), false, NO_OFFSET); } void -VideoMonitor::set_offset (ARDOUR::frameoffset_t offset) +VideoMonitor::set_offset (ARDOUR::sampleoffset_t offset) { if (!is_started()) { return; } if (!_session) { return; } if (offset == NO_OFFSET ) { return; } - framecnt_t video_frame_offset; - framecnt_t audio_frame_rate; + samplecnt_t video_frame_offset; + samplecnt_t audio_sample_rate; if (_session->config.get_videotimeline_pullup()) { - audio_frame_rate = _session->frame_rate(); + audio_sample_rate = _session->sample_rate(); } else { - audio_frame_rate = _session->nominal_frame_rate(); + audio_sample_rate = _session->nominal_sample_rate(); } - /* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */ + /* Note: pull-up/down are applied here: sample_rate() vs. nominal_sample_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); } if (video_offset == video_frame_offset) { return; } @@ -503,28 +506,28 @@ VideoMonitor::set_offset (ARDOUR::frameoffset_t offset) } void -VideoMonitor::manual_seek (framepos_t when, bool /*force*/, ARDOUR::frameoffset_t offset) +VideoMonitor::manual_seek (samplepos_t when, bool /*force*/, ARDOUR::sampleoffset_t offset) { if (!is_started()) { return; } if (!_session) { return; } - framecnt_t video_frame; - framecnt_t audio_frame_rate; + samplecnt_t video_frame; + samplecnt_t audio_sample_rate; if (_session->config.get_videotimeline_pullup()) { - audio_frame_rate = _session->frame_rate(); + audio_sample_rate = _session->sample_rate(); } else { - audio_frame_rate = _session->nominal_frame_rate(); + audio_sample_rate = _session->nominal_sample_rate(); } - /* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */ + /* Note: pull-up/down are applied here: sample_rate() vs. nominal_sample_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; - if (video_frame == manually_seeked_frame) { return; } - manually_seeked_frame = video_frame; + if (video_frame == manually_seeked_sample) { return; } + manually_seeked_sample = video_frame; #if 0 /* DEBUG */ std::cout <<"seek: " << video_frame << std::endl; @@ -554,7 +557,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; } @@ -566,7 +569,7 @@ VideoMonitor::xjadeo_sync_setup () process->write_to_stdin("jack connect\n"); } else { process->write_to_stdin("jack disconnect\n"); - clock_connection = ARDOUR_UI::SuperRapidScreenUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate)); + clock_connection = Timers::fps_connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate)); } sync_by_manual_seek = my_manual_seek; }