$Id$
*/
+#include <fcntl.h>
#include <map>
-#include "control_protocol/timecode.h"
+#include "timecode/time.h"
#include "pbd/error.h"
#include "midi++/mmc.h"
#include "midi++/port.h"
+#include "midi++/jack_midi_port.h"
#include "midi++/parser.h"
+#include "midi++/manager.h"
using namespace std;
using namespace MIDI;
}
-MachineControl::MachineControl ()
- : _port (0)
+MachineControl::MachineControl (Manager* m, jack_client_t* jack)
{
build_mmc_cmd_map ();
- _receive_device_id = 0;
+ _receive_device_id = 0x7f;
_send_device_id = 0x7f;
-}
-
-void
-MachineControl::set_port (Port* p)
-{
- _port = p;
- port_connections.drop_connections ();
+ _input_port = m->add_port (new JackMIDIPort ("MMC in", Port::IsInput, jack));
+ _output_port = m->add_port (new JackMIDIPort ("MMC out", Port::IsOutput, jack));
- if (_port->input()) {
- _port->input()->mmc.connect_same_thread (port_connections, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3));
- _port->input()->start.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_start, this, _1, _2));
- _port->input()->contineu.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_continue, this, _1, _2));
- _port->input()->stop.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_stop, this, _1, _2));
- } else {
- warning << "MMC connected to a non-input port: useless!" << endmsg;
- }
+ _input_port->parser()->mmc.connect_same_thread (port_connections, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3));
+ _input_port->parser()->start.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_start, this));
+ _input_port->parser()->contineu.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_continue, this));
+ _input_port->parser()->stop.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_stop, this));
}
void
void
MachineControl::send (MachineControlCommand const & c)
{
- if (_port == 0 || !_enable_send) {
+ if (_output_port == 0 || !_enable_send) {
// cerr << "Not delivering MMC " << _mmc->port() << " - " << session_send_mmc << endl;
return;
}
MIDI::byte buffer[32];
MIDI::byte* b = c.fill_buffer (this, buffer);
- if (_port->midimsg (buffer, b - buffer, 0)) {
+ if (_output_port->midimsg (buffer, b - buffer, 0)) {
error << "MMC: cannot send command" << endmsg;
}
}
void
-MachineControl::spp_start (Parser& parser, nframes_t timestamp)
+MachineControl::spp_start ()
{
- SPPStart (parser, timestamp); /* EMIT SIGNAL */
+ SPPStart (); /* EMIT SIGNAL */
}
void
-MachineControl::spp_continue (Parser& parser, nframes_t timestamp)
+MachineControl::spp_continue ()
{
- SPPContinue (parser, timestamp); /* EMIT SIGNAL */
+ SPPContinue (); /* EMIT SIGNAL */
}
void
-MachineControl::spp_stop (Parser& parser, nframes_t timestamp)
+MachineControl::spp_stop ()
{
- SPPStop (parser, timestamp); /* EMIT SIGNAL */
+ SPPStop (); /* EMIT SIGNAL */
}
MachineControlCommand::MachineControlCommand (MachineControl::Command c)