Fix crash with input (not duplex) control MIDI ports.
[ardour.git] / libs / midi++2 / mmc.cc
index 3e1aefd4ebffe47ed86e1fa9507aff7cf3e8fb2e..c16b243a16689dd2718a9d049150533a5e69c01d 100644 (file)
 
 #include <map>
 
-#include <pbd/error.h>
-#include <midi++/mmc.h>
-#include <midi++/port.h>
-#include <midi++/parser.h>
+#include "pbd/error.h"
+#include "midi++/mmc.h"
+#include "midi++/port.h"
+#include "midi++/parser.h"
 
 using namespace std;
 using namespace MIDI;
+using namespace PBD;
 
 static std::map<int,string> mmc_cmd_map;
 static void build_mmc_cmd_map ()
@@ -191,9 +192,9 @@ static void build_mmc_cmd_map ()
 }
 
 
-MachineControl::MachineControl (Port &p, float version,
-                               CommandSignature &csig,
-                               ResponseSignature &rsig)
+MachineControl::MachineControl (Port &p, float /*version*/,
+                               CommandSignature & /*csig*/,
+                               ResponseSignature & /*rsig*/)
 
        : _port (p)
 {
@@ -201,7 +202,8 @@ MachineControl::MachineControl (Port &p, float version,
        
        build_mmc_cmd_map ();
 
-       _device_id = 1;
+       _receive_device_id = 0;
+       _send_device_id = 0x7f;
        
        if ((parser = _port.input()) != 0) {
                parser->mmc.connect 
@@ -213,10 +215,15 @@ MachineControl::MachineControl (Port &p, float version,
 }
 
 void
-MachineControl::set_device_id (byte id)
+MachineControl::set_receive_device_id (byte id)
+{
+       _receive_device_id = id & 0x7f;
+}
 
+void
+MachineControl::set_send_device_id (byte id)
 {
-       _device_id = id & 0x7f;
+       _send_device_id = id & 0x7f;
 }
 
 bool
@@ -240,7 +247,7 @@ MachineControl::is_mmc (byte *sysex_buf, size_t len)
 }
 
 void
-MachineControl::process_mmc_message (Parser &p, byte *msg, size_t len)
+MachineControl::process_mmc_message (Parser &, byte *msg, size_t len)
 
 {
        size_t skiplen;
@@ -257,14 +264,14 @@ MachineControl::process_mmc_message (Parser &p, byte *msg, size_t len)
        */
 
 #if 0
-       cerr << "*** MMC message: len = " << len << "\n\t";
+       cerr << "*** me = " << (int) _receive_device_id << " MMC message: len = " << len << "\n\t";
        for (size_t i = 0; i < len; i++) {
                cerr << hex << (int) msg[i] << dec << ' ';
        }
        cerr << endl;
 #endif
 
-       if (msg[1] != 0x7f && msg[1] != _device_id) {
+       if (msg[1] != 0x7f && msg[1] != _receive_device_id) {
                return;
        }
 
@@ -471,7 +478,7 @@ MachineControl::do_masked_write (byte *msg, size_t len)
 }
 
 void
-MachineControl::write_track_record_ready (byte *msg, size_t len)
+MachineControl::write_track_record_ready (byte *msg, size_t /*len*/)
 
 {
        size_t n;
@@ -557,7 +564,7 @@ MachineControl::write_track_record_ready (byte *msg, size_t len)
 }
 
 int
-MachineControl::do_locate (byte *msg, size_t msglen)
+MachineControl::do_locate (byte *msg, size_t /*msglen*/)
 
 {
        if (msg[2] == 0) {
@@ -573,7 +580,7 @@ MachineControl::do_locate (byte *msg, size_t msglen)
 }
 
 int
-MachineControl::do_step (byte *msg, size_t msglen)
+MachineControl::do_step (byte *msg, size_t /*msglen*/)
 {
        int steps = msg[2] & 0x3f;
 
@@ -586,7 +593,7 @@ MachineControl::do_step (byte *msg, size_t msglen)
 }
 
 int
-MachineControl::do_shuttle (byte *msg, size_t msglen)
+MachineControl::do_shuttle (byte *msg, size_t /*msglen*/)
 
 {
        size_t forward;