Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef WITH_VIDEOTIMELINE
-
#include "pbd/file_utils.h"
#include "gui_thread.h"
#include "ardour_ui.h"
}
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");
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..
*/
sched_yield();
}
if (timeout <= 0) {
- printf("xjadeo connection: time-out. session may not be saved.\n");
process->terminate();
}
-#endif
- save_session();
}
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");
}
void
-VideoMonitor::parse_output (std::string d, size_t s)
+VideoMonitor::parse_output (std::string d, size_t /*s*/)
{
std::string line = d;
std::string::size_type start = 0;
#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"); }
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;
}
}
VideoMonitor::terminated ()
{
process->terminate(); // from gui-context clean up
- save_session();
Terminated();
}
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 ();
}
}
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..
}
void
-VideoMonitor::manual_seek (framepos_t when, bool force, ARDOUR::frameoffset_t offset)
+VideoMonitor::manual_seek (framepos_t when, bool /*force*/, ARDOUR::frameoffset_t offset)
{
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;
sync_by_manual_seek = my_manual_seek;
}
}
-#endif /* WITH_VIDEOTIMELINE */