Sort various things to reduce merge hell. No functional changes.
[ardour.git] / libs / ardour / mtc_slave.cc
index 0caa86196a868571463338d0919a90ad07ab4132..0a0fbc15292804e82f7eb27cc5d46fe707a9d708 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <errno.h>
@@ -42,6 +41,8 @@ using namespace PBD;
 MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p) 
        : session (s)
 {
+       can_notify_on_unknown_rate = true;
+
        rebind (p);
        reset ();
 }
@@ -94,8 +95,39 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
        smpte.minutes = msg[2];
        smpte.seconds = msg[1];
        smpte.frames = msg[0];
-       
-       session.smpte_to_sample( smpte, mtc_frame, true, false );
+
+       switch (msg[4]) {
+       case MTC_24_FPS:
+               smpte.rate = 24;
+               smpte.drop = false;
+               can_notify_on_unknown_rate = true;
+               break;
+       case MTC_25_FPS:
+               smpte.rate = 25;
+               smpte.drop = false;
+               can_notify_on_unknown_rate = true;
+               break;
+       case MTC_30_FPS_DROP:
+               smpte.rate = 30;
+               smpte.drop = true;
+               can_notify_on_unknown_rate = true;
+               break;
+       case MTC_30_FPS:
+               smpte.rate = 30;
+               smpte.drop = false;
+               can_notify_on_unknown_rate = true;
+               break;
+       default:
+               /* throttle error messages about unknown MTC rates */
+               if (can_notify_on_unknown_rate) {
+                       error << _("Unknown rate/drop value in incoming MTC stream, session values used instead") << endmsg;
+                       can_notify_on_unknown_rate = false;
+               }
+               smpte.rate = session.smpte_frames_per_second();
+               smpte.drop = session.smpte_drop_frames();
+       }
+
+       session.smpte_to_sample (smpte, mtc_frame, true, false);
        
        if (was_full) {
                
@@ -105,6 +137,7 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
                current.guard2++;        
                
                session.request_locate (mtc_frame, false);       
+               session.request_transport_speed (0);
                update_mtc_status (MIDI::Parser::MTC_Stopped);   
 
                reset ();
@@ -239,6 +272,7 @@ MTC_Slave::speed_and_position (float& speed, nframes_t& pos)
                mtc_speed = 0;
                pos = last.position;
                session.request_locate (pos, false);
+               session.request_transport_speed (0);
                update_mtc_status (MIDI::Parser::MTC_Stopped);
                reset();
                return false;
@@ -293,7 +327,7 @@ MTC_Slave::speed_and_position (float& speed, nframes_t& pos)
        return true;
 }
 
-nframes_t
+ARDOUR::nframes_t
 MTC_Slave::resolution() const
 {
        return (nframes_t) session.frames_per_smpte_frame();