summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-04-09 14:25:02 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-04-09 14:25:02 -0400
commit6592c8696ad5e8b479c3997639e7b54981ec06af (patch)
tree21b14ad96ecce8742969cbd2c0efb1c5ccc62aba /gtk2_ardour
parent722d7f4de6b9c664b7bb9331e67a9f4869f4f9af (diff)
parent082de27a4e4b192e541c95cb90b97be67d5ed2d0 (diff)
Merge branch 'master' of git.ardour.org:ardour/ardour
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc12
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc5
-rw-r--r--gtk2_ardour/video_monitor.cc100
-rw-r--r--gtk2_ardour/video_monitor.h4
-rw-r--r--gtk2_ardour/video_timeline.cc116
-rw-r--r--gtk2_ardour/video_timeline.h7
6 files changed, 133 insertions, 111 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index c29c8136a0..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()
{
+ if (_session) {
#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();
+ ARDOUR_UI::instance()->video_timeline->sync_session_state();
#endif
- if (_session) {
if (_session->dirty()) {
vector<string> actions;
@@ -2557,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()) {
@@ -2744,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 2789c37464..0cfe341211 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -217,7 +217,7 @@ ARDOUR_UI::unload_session (bool hide_stuff)
{
#ifdef WITH_VIDEOTIMELINE
if (_session) {
- ARDOUR_UI::instance()->video_timeline->close_session();
+ ARDOUR_UI::instance()->video_timeline->sync_session_state();
}
#endif
if (_session && _session->dirty()) {
@@ -250,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<std::string,std::string> 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 9cd9d35315..2953fd8277 100644
--- a/gtk2_ardour/video_timeline.cc
+++ b/gtk2_ardour/video_timeline.cc
@@ -89,63 +89,26 @@ 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
- }
-
- /* VTL settings */
- node = _session->extra_xml (X_("Videotimeline"));
+ _session->add_extra_xml (*node);
- 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;
+ if (vmonitor) {
+ if (vmonitor->is_started()) {
+ vmonitor->query_full_state(true);
}
+ vmonitor->save_session();
}
- /* 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 ();
- }
+ /* VTL settings */
+ node = _session->extra_xml (X_("Videotimeline"));
+ 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 */
@@ -155,7 +118,7 @@ VideoTimeLine::close_session ()
if (video_duration == 0) {
return;
}
- save_session();
+ sessionsave.disconnect();
close_video_monitor();
remove_frames();
@@ -164,6 +127,15 @@ VideoTimeLine::close_session ()
GuiUpdate("set-xjadeo-sensitive-off");
}
+void
+VideoTimeLine::sync_session_state ()
+{
+ if (!_session || !vmonitor || !vmonitor->is_started()) {
+ return;
+ }
+ save_session();
+}
+
/** load settings from session */
void
VideoTimeLine::set_session (ARDOUR::Session *s)
@@ -171,6 +143,7 @@ VideoTimeLine::set_session (ARDOUR::Session *s)
SessionHandlePtr::set_session (s);
if (!_session) { return ; }
+ _session->SaveSession.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
LocaleGuard lg (X_("POSIX"));
XMLNode* node = _session->extra_xml (X_("Videotimeline"));
@@ -228,8 +201,27 @@ VideoTimeLine::set_session (ARDOUR::Session *s)
}
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 ()
{
+ if (_session && video_offset_p != video_offset) {
+ _session->set_dirty ();
+ }
video_offset_p = video_offset;
}
@@ -610,6 +602,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();
}
@@ -738,6 +733,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 ();
+ }
+ }
+
}
}
@@ -764,9 +770,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 ab1a9a92d8..b80faa3b27 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 ();
@@ -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;}
@@ -137,6 +138,8 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p
PBD::Signal0<void> VtlUpdate;
PBD::Signal1<void,std::string> GuiUpdate;
void gui_update (const std::string &);
+
+ PBD::ScopedConnection sessionsave;
};
#endif /* __ardour_video_timeline_h__ */