From 8630fd1703acb2f9a36d6db7e0d18963b461614f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 8 Apr 2013 19:51:00 +0200 Subject: [PATCH 1/8] add session save signal and hook-up videotimeline --- gtk2_ardour/video_timeline.cc | 1 + libs/ardour/ardour/session.h | 1 + libs/ardour/session_state.cc | 2 ++ 3 files changed, 4 insertions(+) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 9cd9d35315..e33f171a3c 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -171,6 +171,7 @@ VideoTimeLine::set_session (ARDOUR::Session *s) SessionHandlePtr::set_session (s); if (!_session) { return ; } + _session->SaveSession.connect_same_thread (*this, boost::bind (&VideoTimeLine::save_session, this)); LocaleGuard lg (X_("POSIX")); XMLNode* node = _session->extra_xml (X_("Videotimeline")); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 525faa4e13..a149224607 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -397,6 +397,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi PBD::Signal1 StateSaved; PBD::Signal0 StateReady; + PBD::Signal0 SaveSession; std::vector* possible_states() const; static std::vector* possible_states (std::string path); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index a713375755..4ce39340a3 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -827,6 +827,8 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot if (!pending) { + SaveSession (); /* EMIT SIGNAL */ + save_history (snapshot_name); bool was_dirty = dirty(); From d9df0ea6e50f4caa23b4c9e67236e17e303ef89e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 8 Apr 2013 20:52:33 +0200 Subject: [PATCH 2/8] fix prev commit SaveSession() signal was sent too late. --- libs/ardour/session_state.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 4ce39340a3..9a82192175 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -772,6 +772,8 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } } + SaveSession (); /* EMIT SIGNAL */ + tree.set_root (&get_state()); if (snapshot_name.empty()) { @@ -827,8 +829,6 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot if (!pending) { - SaveSession (); /* EMIT SIGNAL */ - save_history (snapshot_name); bool was_dirty = dirty(); From c7daf40358f91f9803b43edebb8395d93530b268 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 8 Apr 2013 21:11:17 +0200 Subject: [PATCH 3/8] mark session dirty if video is moved --- gtk2_ardour/video_timeline.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index e33f171a3c..729ac05ed3 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -231,6 +231,9 @@ VideoTimeLine::set_session (ARDOUR::Session *s) void VideoTimeLine::save_undo () { + if (_session && video_offset_p != video_offset) { + _session->set_dirty (); + } video_offset_p = video_offset; } From f7abf2de82d2bf97eaa7395b7056771197f1fe36 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 8 Apr 2013 21:17:48 +0200 Subject: [PATCH 4/8] vtl: mark session dirty if video position-lock or timeline height changes --- gtk2_ardour/video_timeline.cc | 19 +++++++++++++++++++ gtk2_ardour/video_timeline.h | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 729ac05ed3..269e465623 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -228,6 +228,22 @@ VideoTimeLine::set_session (ARDOUR::Session *s) _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context()); } +void +VideoTimeLine::set_offset_locked (bool v) { + if (_session && v != video_offset_lock) { + _session->set_dirty (); + } + video_offset_lock = v; +} + +void +VideoTimeLine::toggle_offset_locked () { + video_offset_lock = !video_offset_lock; + if (_session) { + _session->set_dirty (); + } +} + void VideoTimeLine::save_undo () { @@ -614,6 +630,9 @@ VideoTimeLine::gui_update(std::string const & t) { void VideoTimeLine::set_height (int height) { + if (_session && bar_height != height) { + _session->set_dirty (); + } bar_height = height; flush_local_cache(); } diff --git a/gtk2_ardour/video_timeline.h b/gtk2_ardour/video_timeline.h index ab1a9a92d8..559709d708 100644 --- a/gtk2_ardour/video_timeline.h +++ b/gtk2_ardour/video_timeline.h @@ -72,8 +72,8 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p double get_video_file_fps () { return video_file_fps; } void set_update_session_fps (bool v=true) { auto_set_session_fps = v; } - void set_offset_locked (bool v) { video_offset_lock = v; } - void toggle_offset_locked () { video_offset_lock = !video_offset_lock; } + void set_offset_locked (bool v); + void toggle_offset_locked (); bool is_offset_locked () { return video_offset_lock; } void open_video_monitor (); From 8a3ebe7510195b7d7f2c3eba3ae75b0e76b8db70 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 Apr 2013 00:48:15 +0200 Subject: [PATCH 5/8] vtl: resume if "don't close/exit" is selected --- gtk2_ardour/ardour_ui.cc | 1 + gtk2_ardour/ardour_ui_dialogs.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index c29c8136a0..83931816be 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -849,6 +849,7 @@ ARDOUR_UI::finish() actions.push_back (_("Save and quit")); switch (ask_about_saving_session(actions)) { case -1: + ARDOUR_UI::instance()->video_timeline->set_session(_session); return; break; case 1: diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 2789c37464..fb31ba513a 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -217,6 +217,10 @@ ARDOUR_UI::unload_session (bool hide_stuff) { #ifdef WITH_VIDEOTIMELINE if (_session) { + /* close video-monitor + * this needed to enfore querying its settings (window size,..) + * which are reported asynchroneously. + */ ARDOUR_UI::instance()->video_timeline->close_session(); } #endif @@ -227,6 +231,7 @@ ARDOUR_UI::unload_session (bool hide_stuff) actions.push_back (_("Save and close")); switch (ask_about_saving_session (actions)) { case -1: + ARDOUR_UI::instance()->video_timeline->set_session(_session); // cancel return 1; From 49ddf8ecce0027e5cb96de2d361aec8d74b3c921 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 Apr 2013 03:47:47 +0200 Subject: [PATCH 6/8] vtl: disconnect from session-save signal the videotimeline is a global unique instance that is allocated during startup and deleted on exit. The Scopedconnection is not deleted with the session. --- gtk2_ardour/video_timeline.cc | 3 ++- gtk2_ardour/video_timeline.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 269e465623..563a6a366e 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -155,6 +155,7 @@ VideoTimeLine::close_session () if (video_duration == 0) { return; } + sessionsave.disconnect(); save_session(); close_video_monitor(); @@ -171,7 +172,7 @@ VideoTimeLine::set_session (ARDOUR::Session *s) SessionHandlePtr::set_session (s); if (!_session) { return ; } - _session->SaveSession.connect_same_thread (*this, boost::bind (&VideoTimeLine::save_session, this)); + _session->SaveSession.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this)); LocaleGuard lg (X_("POSIX")); XMLNode* node = _session->extra_xml (X_("Videotimeline")); diff --git a/gtk2_ardour/video_timeline.h b/gtk2_ardour/video_timeline.h index 559709d708..4bc3eb86c7 100644 --- a/gtk2_ardour/video_timeline.h +++ b/gtk2_ardour/video_timeline.h @@ -137,6 +137,8 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p PBD::Signal0 VtlUpdate; PBD::Signal1 GuiUpdate; void gui_update (const std::string &); + + PBD::ScopedConnection sessionsave; }; #endif /* __ardour_video_timeline_h__ */ From ed1f310f109279347906bbcb85757b5a54792e26 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 Apr 2013 04:05:07 +0200 Subject: [PATCH 7/8] vtl: rework session-needs-save logic * videotimeline now immediately marks the session dirty on every state-changing operation * video-montor is polled every 2.5 seconds for menu-relevant state info (ontop, OSD,..) and every 30 seconds for full state (window pos, size,..) * new interface to query the video-monitor for its state and wait for all replies - terminating the process and using ::wait() is no longer required * Ardour> quit and Ardour > close-session does no longer close the video session to enforce video-monitor state sync but uses above new interface --- gtk2_ardour/ardour_ui.cc | 15 ++--- gtk2_ardour/ardour_ui_dialogs.cc | 10 ++-- gtk2_ardour/video_monitor.cc | 100 +++++++++++++++++-------------- gtk2_ardour/video_monitor.h | 4 +- gtk2_ardour/video_timeline.cc | 90 ++++++++++++---------------- gtk2_ardour/video_timeline.h | 1 + 6 files changed, 104 insertions(+), 116 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 83931816be..b7cccbfaa5 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -834,13 +834,10 @@ ARDOUR_UI::idle_finish () void ARDOUR_UI::finish() { -#ifdef WITH_VIDEOTIMELINE - /* close video-monitor & pending requests - * would better be done in ~Editor() but that is not called.. - */ - ARDOUR_UI::instance()->video_timeline->close_session(); -#endif if (_session) { +#ifdef WITH_VIDEOTIMELINE + ARDOUR_UI::instance()->video_timeline->sync_session_state(); +#endif if (_session->dirty()) { vector actions; @@ -849,7 +846,6 @@ ARDOUR_UI::finish() actions.push_back (_("Save and quit")); switch (ask_about_saving_session(actions)) { case -1: - ARDOUR_UI::instance()->video_timeline->set_session(_session); return; break; case 1: @@ -2558,7 +2554,7 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri */ #ifdef WITH_VIDEOTIMELINE if (_session && ARDOUR_UI::instance()->video_timeline) { - ARDOUR_UI::instance()->video_timeline->close_session(); + ARDOUR_UI::instance()->video_timeline->sync_session_state(); } #endif if (_session && _session->dirty()) { @@ -2745,9 +2741,6 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri void ARDOUR_UI::close_session() { -#ifdef WITH_VIDEOTIMELINE - ARDOUR_UI::instance()->video_timeline->close_session(); -#endif if (!check_audioengine()) { return; } diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index fb31ba513a..0cfe341211 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -217,11 +217,7 @@ ARDOUR_UI::unload_session (bool hide_stuff) { #ifdef WITH_VIDEOTIMELINE if (_session) { - /* close video-monitor - * this needed to enfore querying its settings (window size,..) - * which are reported asynchroneously. - */ - ARDOUR_UI::instance()->video_timeline->close_session(); + ARDOUR_UI::instance()->video_timeline->sync_session_state(); } #endif if (_session && _session->dirty()) { @@ -231,7 +227,6 @@ ARDOUR_UI::unload_session (bool hide_stuff) actions.push_back (_("Save and close")); switch (ask_about_saving_session (actions)) { case -1: - ARDOUR_UI::instance()->video_timeline->set_session(_session); // cancel return 1; @@ -255,6 +250,9 @@ ARDOUR_UI::unload_session (bool hide_stuff) ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false); rec_button.set_sensitive (false); +#ifdef WITH_VIDEOTIMELINE + ARDOUR_UI::instance()->video_timeline->close_session(); +#endif stop_blinking (); stop_clocking (); diff --git a/gtk2_ardour/video_monitor.cc b/gtk2_ardour/video_monitor.cc index 5bc6bb6777..9bcd244cf0 100644 --- a/gtk2_ardour/video_monitor.cc +++ b/gtk2_ardour/video_monitor.cc @@ -79,11 +79,9 @@ VideoMonitor::start () } void -VideoMonitor::quit () +VideoMonitor::query_full_state (bool wait) { - if (!is_started()) return; - if (state_connection.connected()) { state_connection.disconnect(); } - if (clock_connection.connected()) { clock_connection.disconnect(); } + knownstate = 0; process->write_to_stdin("get windowsize\n"); process->write_to_stdin("get windowpos\n"); process->write_to_stdin("get letterbox\n"); @@ -91,10 +89,21 @@ VideoMonitor::quit () process->write_to_stdin("get ontop\n"); process->write_to_stdin("get offset\n"); process->write_to_stdin("get osdcfg\n"); + int timeout = 40; + if (wait && knownstate !=127 && --timeout) { + usleep(50000); + sched_yield(); + } +} + +void +VideoMonitor::quit () +{ + if (!is_started()) return; + if (state_connection.connected()) { state_connection.disconnect(); } + if (clock_connection.connected()) { clock_connection.disconnect(); } process->write_to_stdin("quit\n"); -#if 1 - /* wait for replies to the config requests above. - * the 'quit' command should result in process termination + /* the 'quit' command should result in process termination * but in case it fails (communication failure, SIGSTOP, ??) * here's a timeout.. */ @@ -104,11 +113,8 @@ VideoMonitor::quit () sched_yield(); } if (timeout <= 0) { - printf("xjadeo connection: time-out. session may not be saved.\n"); process->terminate(); } -#endif - save_session(); } void @@ -145,9 +151,16 @@ void VideoMonitor::querystate () { /* clock-divider hack -- RapidScreenUpdate == every_point_one_seconds */ - state_clk_divide = (state_clk_divide + 1) % 15; // every 1.5 seconds - if (state_clk_divide != 0) return; - + state_clk_divide = (state_clk_divide + 1) % 300; // 30 secs + if (state_clk_divide == 0) { + // every 30 seconds + query_full_state(false); + return; + } + if (state_clk_divide%25 != 0) { + return; + } + // every 2.5 seconds: process->write_to_stdin("get fullscreen\n"); process->write_to_stdin("get ontop\n"); process->write_to_stdin("get osdcfg\n"); @@ -268,35 +281,50 @@ VideoMonitor::parse_output (std::string d, size_t s) #if 0 /* DEBUG */ std::cout << "parsed: " << key << " => " << value << std::endl; #endif - if(key == "windowpos") { + if (key == "windowpos") { + knownstate |= 16; + if (xjadeo_settings["window xy"] != value) { + if (!starting && _session) _session->set_dirty (); + } xjadeo_settings["window xy"] = value; } else if(key == "windowsize") { + knownstate |= 32; + if (xjadeo_settings["window size"] != value) { + if (!starting && _session) _session->set_dirty (); + } xjadeo_settings["window size"] = value; } else if(key == "windowontop") { + knownstate |= 2; if (starting || xjadeo_settings["window ontop"] != value) { - starting &= ~2; + if (!starting && _session) _session->set_dirty (); if (atoi(value.c_str())) { UiState("xjadeo-window-ontop-on"); } else { UiState("xjadeo-window-ontop-off"); } + starting &= ~2; } xjadeo_settings["window ontop"] = value; } else if(key == "fullscreen") { + knownstate |= 4; if (starting || xjadeo_settings["window zoom"] != value) { - starting &= ~4; + if (!starting && _session) _session->set_dirty (); if (atoi(value.c_str())) { UiState("xjadeo-window-fullscreen-on"); } else { UiState("xjadeo-window-fullscreen-off"); } + starting &= ~4; } xjadeo_settings["window zoom"] = value; } else if(key == "letterbox") { + knownstate |= 8; if (starting || xjadeo_settings["window letterbox"] != value) { - starting &= ~8; + if (!starting && _session) _session->set_dirty (); if (atoi(value.c_str())) { UiState("xjadeo-window-letterbox-on"); } else { UiState("xjadeo-window-letterbox-off"); } + starting &= ~8; } xjadeo_settings["window letterbox"] = value; } else if(key == "osdmode") { - if (starting || xjadeo_settings["osd mode"] != value) { - starting &= ~1; - osdmode = atoi(value.c_str()); + knownstate |= 1; + osdmode = atoi(value.c_str()); + if (starting || atoi(xjadeo_settings["osd mode"].c_str()) != 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 & 2) == 2) { UiState("xjadeo-window-osd-timecode-on"); } @@ -304,8 +332,13 @@ VideoMonitor::parse_output (std::string d, size_t s) if ((osdmode & 8) == 8) { UiState("xjadeo-window-osd-box-on"); } if ((osdmode & 8) == 0) { UiState("xjadeo-window-osd-box-off"); } } + starting &= ~1; xjadeo_settings["osd mode"] = value; } else if(key == "offset") { + knownstate |= 64; + if (xjadeo_settings["set offset"] != value) { + if (!starting && _session) _session->set_dirty (); + } xjadeo_settings["set offset"] = value; } } @@ -321,7 +354,6 @@ void VideoMonitor::terminated () { process->terminate(); // from gui-context clean up - save_session(); Terminated(); } @@ -329,35 +361,13 @@ void VideoMonitor::save_session () { if (!_session) { return; } - bool is_dirty = false; - - XMLNode* prev = _session->extra_xml (X_("XJSettings")); - XMLNode* node = new XMLNode(X_("XJSettings")); - XMLNodeList nlist; - if (!prev) { is_dirty = true; } - else { nlist = prev->children(); } + XMLNode* node = _session->extra_xml (X_("XJSettings")); + if (!node) return; 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); - if (!is_dirty) { - bool found = false; - XMLNodeConstIterator i; - for (i = nlist.begin(); i != nlist.end(); ++i) { - if ((*i)->property(X_("k"))->value() == it->first && - (*i)->property(X_("v"))->value() == it->second ) { - found=true; - break; - } - } - if (!found) {is_dirty = true;} - } - } - - if (is_dirty) { - _session->add_extra_xml (*node); - _session->set_dirty (); } } diff --git a/gtk2_ardour/video_monitor.h b/gtk2_ardour/video_monitor.h index be3b76f9a4..0f954e9cd5 100644 --- a/gtk2_ardour/video_monitor.h +++ b/gtk2_ardour/video_monitor.h @@ -62,7 +62,9 @@ class VideoMonitor : public sigc::trackable , public ARDOUR::SessionHandlePtr, p void open (std::string); void set_session (ARDOUR::Session *s); + void save_session (); void clear_session_state (); + void query_full_state (bool); bool set_custom_setting (const std::string, const std::string); const std::string get_custom_setting (const std::string); void restore_settings_mask (int i) { _restore_settings_mask = i;} @@ -89,7 +91,6 @@ class VideoMonitor : public sigc::trackable , public ARDOUR::SessionHandlePtr, p void parse_output (std::string d, size_t s); void terminated (); - void save_session (); void parameter_changed (std::string const & p); typedef std::map XJSettings; @@ -105,6 +106,7 @@ class VideoMonitor : public sigc::trackable , public ARDOUR::SessionHandlePtr, p sigc::connection state_connection; int state_clk_divide; int starting; + int knownstate; int osdmode; #if 1 bool debug_enable; diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 563a6a366e..78b5f0345d 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -89,63 +89,23 @@ VideoTimeLine::save_session () LocaleGuard lg (X_("POSIX")); - bool is_dirty = false; - - XMLNode* prev = _session->extra_xml (X_("Videomonitor")); - - /* remember if vmonitor was open.. */ XMLNode* node = new XMLNode(X_("Videomonitor")); - + if (!node) return; node->add_property (X_("active"), (vmonitor && vmonitor->is_started())?"yes":"no"); - if (!prev || !(prev->property (X_("active")) && prev->property (X_("active"))->value() == node->property(X_("active"))->value()) ){ - _session->add_extra_xml (*node); - is_dirty=true; // TODO not if !prev && value==default + _session->add_extra_xml (*node); + + if (vmonitor) { + vmonitor->save_session(); } /* VTL settings */ node = _session->extra_xml (X_("Videotimeline")); - - if (node) { - if (!(node->property(X_("id")) && node->property(X_("id"))->value() == id().to_s())) { - node->add_property (X_("id"), id().to_s()); - is_dirty=true; - } - } - - /* remember timeline height.. */ - if (node) { - int h = editor->get_videotl_bar_height(); - if (!(node->property(X_("Height")) && atoi(node->property(X_("Height"))->value().c_str())==h)) { - node->add_property (X_("Height"), h); - is_dirty=true; - } - } - - /* save video-offset-lock */ - if (node) { - if (!(node->property(X_("VideoOffsetLock")) && atoi(node->property(X_("VideoOffsetLock"))->value().c_str())==video_offset_lock)) { - node->add_property (X_("VideoOffsetLock"), video_offset_lock?X_("1"):X_("0")); - is_dirty=true; - } - } - /* save video-offset */ - if (node) { - if (!(node->property(X_("VideoOffset")) && atoll(node->property(X_("VideoOffset"))->value().c_str())==video_offset)) { - node->add_property (X_("VideoOffset"), video_offset); - is_dirty=true; - } - } - - /* save 'auto_set_session_fps' */ - if (node) { - if (!(node->property(X_("AutoFPS")) && atoi(node->property(X_("AutoFPS"))->value().c_str())==auto_set_session_fps)) { - node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0")); - is_dirty=true; - } - } - if (is_dirty) { - _session->set_dirty (); - } + if (!node) return; + node->add_property (X_("id"), id().to_s()); + node->add_property (X_("Height"), editor->get_videotl_bar_height()); + node->add_property (X_("VideoOffsetLock"), video_offset_lock?X_("1"):X_("0")); + node->add_property (X_("VideoOffset"), video_offset); + node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0")); } /* close and save settings */ @@ -156,7 +116,6 @@ VideoTimeLine::close_session () return; } sessionsave.disconnect(); - save_session(); close_video_monitor(); remove_frames(); @@ -165,6 +124,16 @@ VideoTimeLine::close_session () GuiUpdate("set-xjadeo-sensitive-off"); } +void +VideoTimeLine::sync_session_state () +{ + if (!_session || !vmonitor || !vmonitor->is_started()) { + return; + } + vmonitor->query_full_state(true); + save_session(); +} + /** load settings from session */ void VideoTimeLine::set_session (ARDOUR::Session *s) @@ -762,6 +731,17 @@ VideoTimeLine::open_video_monitor() { GuiUpdate("set-xjadeo-active-on"); vmonitor->set_fps(video_file_fps); vmonitor->open(video_filename); + + if (_session) { + XMLNode* node = _session->extra_xml (X_("Videomonitor")); + if (node) { + const XMLProperty* prop = node->property (X_("active")); + if (prop && prop->value() != "yes") _session->set_dirty (); + } else { + _session->set_dirty (); + } + } + } } @@ -788,9 +768,13 @@ VideoTimeLine::terminated_video_monitor () { } GuiUpdate("set-xjadeo-active-off"); vmonitor=0; - if (reopen_vmonitor) { + if (reopen_vmonitor) { reopen_vmonitor=false; open_video_monitor(); + } else { + if (_session) { + _session->set_dirty (); + } } } diff --git a/gtk2_ardour/video_timeline.h b/gtk2_ardour/video_timeline.h index 4bc3eb86c7..b80faa3b27 100644 --- a/gtk2_ardour/video_timeline.h +++ b/gtk2_ardour/video_timeline.h @@ -93,6 +93,7 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p void flush_cache (); void save_session (); void close_session (); + void sync_session_state (); /* video-monitor does not actively report window/pos changes, query it */ float get_apv(); /* audio frames per video frame; */ ARDOUR::framecnt_t get_duration () { return video_duration;} ARDOUR::frameoffset_t get_offset () { return video_offset;} From 082de27a4e4b192e541c95cb90b97be67d5ed2d0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 9 Apr 2013 17:13:42 +0200 Subject: [PATCH 8/8] vtl: query video-monitor-state on explicit session save --- gtk2_ardour/video_timeline.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 78b5f0345d..2953fd8277 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -95,6 +95,9 @@ VideoTimeLine::save_session () _session->add_extra_xml (*node); if (vmonitor) { + if (vmonitor->is_started()) { + vmonitor->query_full_state(true); + } vmonitor->save_session(); } @@ -130,7 +133,6 @@ VideoTimeLine::sync_session_state () if (!_session || !vmonitor || !vmonitor->is_started()) { return; } - vmonitor->query_full_state(true); save_session(); }