Vorbis Quality Config GUI
[ardour.git] / gtk2_ardour / video_monitor.cc
index be412f6725d33e18dd691c472209f26daa778e79..d6831e45b744e6f232a17fda759f156cac53dec8 100644 (file)
@@ -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 <stdio.h>
@@ -28,7 +28,7 @@
 #include "editor.h"
 #include "video_monitor.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -159,10 +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 = ARDOUR_UI::FPSUpdate.connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
+       clock_connection = Timers::fps_connect (sigc::mem_fun (*this, &VideoMonitor::srsupdate));
        xjadeo_sync_setup();
 }
 
@@ -255,9 +255,7 @@ VideoMonitor::is_started ()
 void
 VideoMonitor::forward_keyevent (unsigned int keyval)
 {
-       Editor* ed = dynamic_cast<Editor*>(&PublicEditor::instance());
-       if (!ed) return;
-       emulate_key_event(ed, keyval);
+       emulate_key_event (keyval);
 }
 
 void
@@ -432,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);
        }
 }
 
@@ -443,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;}
@@ -468,31 +467,31 @@ VideoMonitor::get_custom_setting (const std::string k)
        return (xjadeo_settings[k]);
 }
 
-#define NO_OFFSET (ARDOUR::max_framepos) //< skip setting or modifying offset
+#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_sample_rate;
+       samplecnt_t video_frame_offset;
+       samplecnt_t audio_sample_rate;
        if (_session->config.get_videotimeline_pullup()) {
-               audio_sample_rate = _session->frame_rate();
+               audio_sample_rate = _session->sample_rate();
        } else {
-               audio_sample_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_sample_rate);
        } else {
@@ -507,19 +506,19 @@ 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_sample_rate;
+       samplecnt_t video_frame;
+       samplecnt_t audio_sample_rate;
        if (_session->config.get_videotimeline_pullup()) {
-               audio_sample_rate = _session->frame_rate();
+               audio_sample_rate = _session->sample_rate();
        } else {
-               audio_sample_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_sample_rate);
        } else {
@@ -557,9 +556,8 @@ VideoMonitor::xjadeo_sync_setup ()
        if (!_session) { return; }
 
        bool my_manual_seek = true;
-       if (_session->config.get_external_sync()) {
-               if (ARDOUR::Config->get_sync_source() == ARDOUR::Engine)
-                       my_manual_seek = false;
+       if (_session->synced_to_engine ()) {
+               my_manual_seek = false;
        }
 
        if (my_manual_seek != sync_by_manual_seek) {
@@ -570,7 +568,7 @@ VideoMonitor::xjadeo_sync_setup ()
                        process->write_to_stdin("jack connect\n");
                } else {
                        process->write_to_stdin("jack disconnect\n");
-                       clock_connection = ARDOUR_UI::FPSUpdate.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;
        }