Merge branch 'master' into saveas
[ardour.git] / libs / midi++2 / mmc.cc
index 1b9481c9bf8127e1a89580ff4ebc6f78cc707c9f..d722a816eef104932a99669b875aed6bfd09de0b 100644 (file)
@@ -22,6 +22,7 @@
 #include <map>
 
 #include "timecode/time.h"
+#include "timecode/bbt_time.h"
 
 #include "pbd/error.h"
 
@@ -37,6 +38,13 @@ using namespace std;
 using namespace MIDI;
 using namespace PBD;
 
+/**
+ * As libtimecode is linked statically to libmidi++ this
+ * is necessary to pull in all the symbols from libtimecode
+ * so they are exported for other users of libtimecode.
+ */
+double tmp = Timecode::BBT_Time::ticks_per_beat;
+
 static std::map<int,string> mmc_cmd_map;
 static void build_mmc_cmd_map ()
 {
@@ -276,7 +284,7 @@ MachineControl::process_mmc_message (Parser &, MIDI::byte *msg, size_t len)
        cerr << endl;
 #endif
 
-       if (msg[1] != 0x7f && msg[1] != _receive_device_id) {
+       if (_receive_device_id != 0x7f && msg[1] != 0x7f && msg[1] != _receive_device_id) {
                return;
        }
 
@@ -643,7 +651,7 @@ MachineControl::enable_send (bool yn)
  *  @param c command.
  */
 void
-MachineControl::send (MachineControlCommand const & c)
+MachineControl::send (MachineControlCommand const & c, timestamp_t when)
 {
        if (_output_port == 0 || !_enable_send) {
                // cerr << "Not delivering MMC " << _mmc->port() << " - " << session_send_mmc << endl;
@@ -653,7 +661,7 @@ MachineControl::send (MachineControlCommand const & c)
        MIDI::byte buffer[32];
        MIDI::byte* b = c.fill_buffer (this, buffer);
 
-       if (_output_port->midimsg (buffer, b - buffer, 0)) {
+       if (_output_port->midimsg (buffer, b - buffer, when)) {
                error << "MMC: cannot send command" << endmsg;
        }
 }
@@ -702,7 +710,7 @@ MachineControlCommand::fill_buffer (MachineControl* mmc, MIDI::byte* b) const
        if (_command == MachineControl::cmdLocate) {
                *b++ = 0x6; // byte count
                *b++ = 0x1; // "TARGET" subcommand
-               *b++ = _time.hours;
+               *b++ = _time.hours % 24;
                *b++ = _time.minutes;
                *b++ = _time.seconds;
                *b++ = _time.frames;