13
0

Merge branch 'master' of git.ardour.org:ardour/ardour

This commit is contained in:
Paul Davis 2013-04-09 14:25:02 -04:00
commit 6592c8696a
8 changed files with 137 additions and 112 deletions

View File

@ -834,13 +834,10 @@ ARDOUR_UI::idle_finish ()
void void
ARDOUR_UI::finish() 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) { if (_session) {
#ifdef WITH_VIDEOTIMELINE
ARDOUR_UI::instance()->video_timeline->sync_session_state();
#endif
if (_session->dirty()) { if (_session->dirty()) {
vector<string> actions; vector<string> actions;
@ -2557,7 +2554,7 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
*/ */
#ifdef WITH_VIDEOTIMELINE #ifdef WITH_VIDEOTIMELINE
if (_session && ARDOUR_UI::instance()->video_timeline) { if (_session && ARDOUR_UI::instance()->video_timeline) {
ARDOUR_UI::instance()->video_timeline->close_session(); ARDOUR_UI::instance()->video_timeline->sync_session_state();
} }
#endif #endif
if (_session && _session->dirty()) { if (_session && _session->dirty()) {
@ -2744,9 +2741,6 @@ ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, stri
void void
ARDOUR_UI::close_session() ARDOUR_UI::close_session()
{ {
#ifdef WITH_VIDEOTIMELINE
ARDOUR_UI::instance()->video_timeline->close_session();
#endif
if (!check_audioengine()) { if (!check_audioengine()) {
return; return;
} }

View File

@ -217,7 +217,7 @@ ARDOUR_UI::unload_session (bool hide_stuff)
{ {
#ifdef WITH_VIDEOTIMELINE #ifdef WITH_VIDEOTIMELINE
if (_session) { if (_session) {
ARDOUR_UI::instance()->video_timeline->close_session(); ARDOUR_UI::instance()->video_timeline->sync_session_state();
} }
#endif #endif
if (_session && _session->dirty()) { if (_session && _session->dirty()) {
@ -250,6 +250,9 @@ ARDOUR_UI::unload_session (bool hide_stuff)
ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false); ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
rec_button.set_sensitive (false); rec_button.set_sensitive (false);
#ifdef WITH_VIDEOTIMELINE
ARDOUR_UI::instance()->video_timeline->close_session();
#endif
stop_blinking (); stop_blinking ();
stop_clocking (); stop_clocking ();

View File

@ -79,11 +79,9 @@ VideoMonitor::start ()
} }
void void
VideoMonitor::quit () VideoMonitor::query_full_state (bool wait)
{ {
if (!is_started()) return; knownstate = 0;
if (state_connection.connected()) { state_connection.disconnect(); }
if (clock_connection.connected()) { clock_connection.disconnect(); }
process->write_to_stdin("get windowsize\n"); process->write_to_stdin("get windowsize\n");
process->write_to_stdin("get windowpos\n"); process->write_to_stdin("get windowpos\n");
process->write_to_stdin("get letterbox\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 ontop\n");
process->write_to_stdin("get offset\n"); process->write_to_stdin("get offset\n");
process->write_to_stdin("get osdcfg\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"); process->write_to_stdin("quit\n");
#if 1 /* the 'quit' command should result in process termination
/* wait for replies to the config requests above.
* the 'quit' command should result in process termination
* but in case it fails (communication failure, SIGSTOP, ??) * but in case it fails (communication failure, SIGSTOP, ??)
* here's a timeout.. * here's a timeout..
*/ */
@ -104,11 +113,8 @@ VideoMonitor::quit ()
sched_yield(); sched_yield();
} }
if (timeout <= 0) { if (timeout <= 0) {
printf("xjadeo connection: time-out. session may not be saved.\n");
process->terminate(); process->terminate();
} }
#endif
save_session();
} }
void void
@ -145,9 +151,16 @@ void
VideoMonitor::querystate () VideoMonitor::querystate ()
{ {
/* clock-divider hack -- RapidScreenUpdate == every_point_one_seconds */ /* clock-divider hack -- RapidScreenUpdate == every_point_one_seconds */
state_clk_divide = (state_clk_divide + 1) % 15; // every 1.5 seconds state_clk_divide = (state_clk_divide + 1) % 300; // 30 secs
if (state_clk_divide != 0) return; 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 fullscreen\n");
process->write_to_stdin("get ontop\n"); process->write_to_stdin("get ontop\n");
process->write_to_stdin("get osdcfg\n"); process->write_to_stdin("get osdcfg\n");
@ -268,35 +281,50 @@ VideoMonitor::parse_output (std::string d, size_t s)
#if 0 /* DEBUG */ #if 0 /* DEBUG */
std::cout << "parsed: " << key << " => " << value << std::endl; std::cout << "parsed: " << key << " => " << value << std::endl;
#endif #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; xjadeo_settings["window xy"] = value;
} else if(key == "windowsize") { } else if(key == "windowsize") {
knownstate |= 32;
if (xjadeo_settings["window size"] != value) {
if (!starting && _session) _session->set_dirty ();
}
xjadeo_settings["window size"] = value; xjadeo_settings["window size"] = value;
} else if(key == "windowontop") { } else if(key == "windowontop") {
knownstate |= 2;
if (starting || xjadeo_settings["window ontop"] != value) { 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"); } if (atoi(value.c_str())) { UiState("xjadeo-window-ontop-on"); }
else { UiState("xjadeo-window-ontop-off"); } else { UiState("xjadeo-window-ontop-off"); }
starting &= ~2;
} }
xjadeo_settings["window ontop"] = value; xjadeo_settings["window ontop"] = value;
} else if(key == "fullscreen") { } else if(key == "fullscreen") {
knownstate |= 4;
if (starting || xjadeo_settings["window zoom"] != value) { 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"); } if (atoi(value.c_str())) { UiState("xjadeo-window-fullscreen-on"); }
else { UiState("xjadeo-window-fullscreen-off"); } else { UiState("xjadeo-window-fullscreen-off"); }
starting &= ~4;
} }
xjadeo_settings["window zoom"] = value; xjadeo_settings["window zoom"] = value;
} else if(key == "letterbox") { } else if(key == "letterbox") {
knownstate |= 8;
if (starting || xjadeo_settings["window letterbox"] != value) { 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"); } if (atoi(value.c_str())) { UiState("xjadeo-window-letterbox-on"); }
else { UiState("xjadeo-window-letterbox-off"); } else { UiState("xjadeo-window-letterbox-off"); }
starting &= ~8;
} }
xjadeo_settings["window letterbox"] = value; xjadeo_settings["window letterbox"] = value;
} else if(key == "osdmode") { } else if(key == "osdmode") {
if (starting || xjadeo_settings["osd mode"] != value) { knownstate |= 1;
starting &= ~1; osdmode = atoi(value.c_str());
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) == 1) { UiState("xjadeo-window-osd-frame-on"); }
if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-frame-off"); } if ((osdmode & 1) == 0) { UiState("xjadeo-window-osd-frame-off"); }
if ((osdmode & 2) == 2) { UiState("xjadeo-window-osd-timecode-on"); } 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) == 8) { UiState("xjadeo-window-osd-box-on"); }
if ((osdmode & 8) == 0) { UiState("xjadeo-window-osd-box-off"); } if ((osdmode & 8) == 0) { UiState("xjadeo-window-osd-box-off"); }
} }
starting &= ~1;
xjadeo_settings["osd mode"] = value; xjadeo_settings["osd mode"] = value;
} else if(key == "offset") { } else if(key == "offset") {
knownstate |= 64;
if (xjadeo_settings["set offset"] != value) {
if (!starting && _session) _session->set_dirty ();
}
xjadeo_settings["set offset"] = value; xjadeo_settings["set offset"] = value;
} }
} }
@ -321,7 +354,6 @@ void
VideoMonitor::terminated () VideoMonitor::terminated ()
{ {
process->terminate(); // from gui-context clean up process->terminate(); // from gui-context clean up
save_session();
Terminated(); Terminated();
} }
@ -329,35 +361,13 @@ void
VideoMonitor::save_session () VideoMonitor::save_session ()
{ {
if (!_session) { return; } if (!_session) { return; }
bool is_dirty = false; XMLNode* node = _session->extra_xml (X_("XJSettings"));
if (!node) return;
XMLNode* prev = _session->extra_xml (X_("XJSettings"));
XMLNode* node = new XMLNode(X_("XJSettings"));
XMLNodeList nlist;
if (!prev) { is_dirty = true; }
else { nlist = prev->children(); }
for(XJSettings::const_iterator it = xjadeo_settings.begin(); it != xjadeo_settings.end(); ++it) { for(XJSettings::const_iterator it = xjadeo_settings.begin(); it != xjadeo_settings.end(); ++it) {
XMLNode* child = node->add_child (X_("XJSetting")); XMLNode* child = node->add_child (X_("XJSetting"));
child->add_property (X_("k"), it->first); child->add_property (X_("k"), it->first);
child->add_property (X_("v"), it->second); 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 ();
} }
} }

View File

@ -62,7 +62,9 @@ class VideoMonitor : public sigc::trackable , public ARDOUR::SessionHandlePtr, p
void open (std::string); void open (std::string);
void set_session (ARDOUR::Session *s); void set_session (ARDOUR::Session *s);
void save_session ();
void clear_session_state (); void clear_session_state ();
void query_full_state (bool);
bool set_custom_setting (const std::string, const std::string); bool set_custom_setting (const std::string, const std::string);
const std::string get_custom_setting (const std::string); const std::string get_custom_setting (const std::string);
void restore_settings_mask (int i) { _restore_settings_mask = i;} 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 parse_output (std::string d, size_t s);
void terminated (); void terminated ();
void save_session ();
void parameter_changed (std::string const & p); void parameter_changed (std::string const & p);
typedef std::map<std::string,std::string> XJSettings; 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; sigc::connection state_connection;
int state_clk_divide; int state_clk_divide;
int starting; int starting;
int knownstate;
int osdmode; int osdmode;
#if 1 #if 1
bool debug_enable; bool debug_enable;

View File

@ -89,63 +89,26 @@ VideoTimeLine::save_session ()
LocaleGuard lg (X_("POSIX")); 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")); XMLNode* node = new XMLNode(X_("Videomonitor"));
if (!node) return;
node->add_property (X_("active"), (vmonitor && vmonitor->is_started())?"yes":"no"); 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);
_session->add_extra_xml (*node);
is_dirty=true; // TODO not if !prev && value==default if (vmonitor) {
if (vmonitor->is_started()) {
vmonitor->query_full_state(true);
}
vmonitor->save_session();
} }
/* VTL settings */ /* VTL settings */
node = _session->extra_xml (X_("Videotimeline")); node = _session->extra_xml (X_("Videotimeline"));
if (!node) return;
if (node) { node->add_property (X_("id"), id().to_s());
if (!(node->property(X_("id")) && node->property(X_("id"))->value() == id().to_s())) { node->add_property (X_("Height"), editor->get_videotl_bar_height());
node->add_property (X_("id"), id().to_s()); node->add_property (X_("VideoOffsetLock"), video_offset_lock?X_("1"):X_("0"));
is_dirty=true; node->add_property (X_("VideoOffset"), video_offset);
} node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0"));
}
/* 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 ();
}
} }
/* close and save settings */ /* close and save settings */
@ -155,7 +118,7 @@ VideoTimeLine::close_session ()
if (video_duration == 0) { if (video_duration == 0) {
return; return;
} }
save_session(); sessionsave.disconnect();
close_video_monitor(); close_video_monitor();
remove_frames(); remove_frames();
@ -164,6 +127,15 @@ VideoTimeLine::close_session ()
GuiUpdate("set-xjadeo-sensitive-off"); GuiUpdate("set-xjadeo-sensitive-off");
} }
void
VideoTimeLine::sync_session_state ()
{
if (!_session || !vmonitor || !vmonitor->is_started()) {
return;
}
save_session();
}
/** load settings from session */ /** load settings from session */
void void
VideoTimeLine::set_session (ARDOUR::Session *s) VideoTimeLine::set_session (ARDOUR::Session *s)
@ -171,6 +143,7 @@ VideoTimeLine::set_session (ARDOUR::Session *s)
SessionHandlePtr::set_session (s); SessionHandlePtr::set_session (s);
if (!_session) { return ; } if (!_session) { return ; }
_session->SaveSession.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
LocaleGuard lg (X_("POSIX")); LocaleGuard lg (X_("POSIX"));
XMLNode* node = _session->extra_xml (X_("Videotimeline")); XMLNode* node = _session->extra_xml (X_("Videotimeline"));
@ -227,9 +200,28 @@ VideoTimeLine::set_session (ARDOUR::Session *s)
_session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context()); _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 void
VideoTimeLine::save_undo () VideoTimeLine::save_undo ()
{ {
if (_session && video_offset_p != video_offset) {
_session->set_dirty ();
}
video_offset_p = video_offset; video_offset_p = video_offset;
} }
@ -610,6 +602,9 @@ VideoTimeLine::gui_update(std::string const & t) {
void void
VideoTimeLine::set_height (int height) { VideoTimeLine::set_height (int height) {
if (_session && bar_height != height) {
_session->set_dirty ();
}
bar_height = height; bar_height = height;
flush_local_cache(); flush_local_cache();
} }
@ -738,6 +733,17 @@ VideoTimeLine::open_video_monitor() {
GuiUpdate("set-xjadeo-active-on"); GuiUpdate("set-xjadeo-active-on");
vmonitor->set_fps(video_file_fps); vmonitor->set_fps(video_file_fps);
vmonitor->open(video_filename); 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"); GuiUpdate("set-xjadeo-active-off");
vmonitor=0; vmonitor=0;
if (reopen_vmonitor) { if (reopen_vmonitor) {
reopen_vmonitor=false; reopen_vmonitor=false;
open_video_monitor(); open_video_monitor();
} else {
if (_session) {
_session->set_dirty ();
}
} }
} }

View File

@ -72,8 +72,8 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p
double get_video_file_fps () { return video_file_fps; } double get_video_file_fps () { return video_file_fps; }
void set_update_session_fps (bool v=true) { auto_set_session_fps = v; } void set_update_session_fps (bool v=true) { auto_set_session_fps = v; }
void set_offset_locked (bool v) { video_offset_lock = v; } void set_offset_locked (bool v);
void toggle_offset_locked () { video_offset_lock = !video_offset_lock; } void toggle_offset_locked ();
bool is_offset_locked () { return video_offset_lock; } bool is_offset_locked () { return video_offset_lock; }
void open_video_monitor (); void open_video_monitor ();
@ -93,6 +93,7 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p
void flush_cache (); void flush_cache ();
void save_session (); void save_session ();
void close_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; */ float get_apv(); /* audio frames per video frame; */
ARDOUR::framecnt_t get_duration () { return video_duration;} ARDOUR::framecnt_t get_duration () { return video_duration;}
ARDOUR::frameoffset_t get_offset () { return video_offset;} 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::Signal0<void> VtlUpdate;
PBD::Signal1<void,std::string> GuiUpdate; PBD::Signal1<void,std::string> GuiUpdate;
void gui_update (const std::string &); void gui_update (const std::string &);
PBD::ScopedConnection sessionsave;
}; };
#endif /* __ardour_video_timeline_h__ */ #endif /* __ardour_video_timeline_h__ */

View File

@ -397,6 +397,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
PBD::Signal1<void,std::string> StateSaved; PBD::Signal1<void,std::string> StateSaved;
PBD::Signal0<void> StateReady; PBD::Signal0<void> StateReady;
PBD::Signal0<void> SaveSession;
std::vector<std::string*>* possible_states() const; std::vector<std::string*>* possible_states() const;
static std::vector<std::string*>* possible_states (std::string path); static std::vector<std::string*>* possible_states (std::string path);

View File

@ -772,6 +772,8 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
} }
} }
SaveSession (); /* EMIT SIGNAL */
tree.set_root (&get_state()); tree.set_root (&get_state());
if (snapshot_name.empty()) { if (snapshot_name.empty()) {