*** NEW CODING POLICY ***
[ardour.git] / libs / ardour / session_midi.cc
index dd927a3add97a3e8be01864af4eff05a82df98c3..b0d6ed93472aba7b0485abec7232002deac80ee2 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
-#include <midi++/mmc.h>
-#include <midi++/port.h>
-#include <midi++/manager.h>
-#include <pbd/error.h>
+#include "midi++/mmc.h"
+#include "midi++/port.h"
+#include "midi++/manager.h"
+#include "pbd/error.h"
 #include <glibmm/thread.h>
-#include <pbd/pthread_utils.h>
-
-#include <ardour/configuration.h>
-#include <ardour/audioengine.h>
-#include <ardour/session.h>
-#include <ardour/audio_track.h>
-#include <ardour/midi_track.h>
-#include <ardour/audio_diskstream.h>
-#include <ardour/slave.h>
-#include <ardour/cycles.h>
-#include <ardour/smpte.h>
+#include "pbd/pthread_utils.h"
+
+#include "ardour/configuration.h"
+#include "ardour/audioengine.h"
+#include "ardour/session.h"
+#include "ardour/audio_track.h"
+#include "ardour/midi_track.h"
+#include "ardour/audio_diskstream.h"
+#include "ardour/slave.h"
+#include "ardour/cycles.h"
+#include "ardour/smpte.h"
 
 #include "i18n.h"
 
@@ -317,10 +317,6 @@ Session::set_midi_clock_port (string port_tag)
 
        Config->set_midi_clock_port_name (port_tag);
 
-       _midi_clock_port->input()->start.connect (mem_fun (*this, &Session::midi_clock_start));
-       _midi_clock_port->input()->contineu.connect (mem_fun (*this, &Session::midi_clock_continue));
-       _midi_clock_port->input()->stop.connect (mem_fun (*this, &Session::midi_clock_stop));
-
   out:
        MIDIClock_PortChanged(); /* EMIT SIGNAL */
        change_midi_ports ();
@@ -496,7 +492,7 @@ Session::setup_midi_control ()
 }
 
 void
-Session::spp_start (Parser& ignored)
+Session::spp_start (Parser& ignored, nframes_t timestamp)
 {
        if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
                request_transport_speed (1.0);
@@ -504,40 +500,41 @@ Session::spp_start (Parser& ignored)
 }
 
 void
-Session::spp_continue (Parser& ignored)
+Session::spp_continue (Parser& ignored, nframes_t timestamp)
 {
-       spp_start (ignored);
+       spp_start (ignored, timestamp);
 }
 
 void
-Session::spp_stop (Parser& ignored)
+Session::spp_stop (Parser& ignored, nframes_t timestamp)
 {
        if (Config->get_mmc_control()) {
                request_stop ();
        }
 }
-
+/*
 void
-Session::midi_clock_start (Parser& ignored)
+Session::midi_clock_start (Parser& ignored, nframes_t timestamp)
 {
-       if (Config->get_midi_clock_control() && (Config->get_slave_source() == MIDIClock)) {
+       if (Config->get_slave_source() == MIDIClock) {
                request_transport_speed (1.0);
        }
 }
 
 void
-Session::midi_clock_continue (Parser& ignored)
+Session::midi_clock_continue (Parser& parser, nframes_t timestamp)
 {
-       midi_clock_start (ignored);
+       midi_clock_start (parser, 0);
 }
 
 void
-Session::midi_clock_stop (Parser& ignored)
+Session::midi_clock_stop (Parser& ignored, nframes_t timestamp)
 {
-       if (Config->get_midi_clock_control()) {
+       if (Config->get_slave_source() == MIDIClock) {
                request_stop ();
        }
 }
+*/
 
 void
 Session::mmc_deferred_play (MIDI::MachineControl &mmc)
@@ -780,7 +777,6 @@ Session::change_midi_ports ()
  * This resets the MTC code, the next quarter frame message that is sent will be
  * the first one with the beginning of this cycle as the new start point.
  */
-
 int
 Session::send_full_time_code(nframes_t nframes)
 {
@@ -838,8 +834,7 @@ Session::send_full_time_code(nframes_t nframes)
        return 0;
 }
 
-
-/** Sends MTC (quarter-frame) messages for this cycle.
+/** Send MTC (quarter-frame) messages for this cycle.
  * Must be called exactly once per cycle from the audio thread.  Realtime safe.
  * This function assumes the state of full SMPTE is sane, eg. the slave is
  * expecting quarter frame messages and has the right frame of reference (any
@@ -1123,7 +1118,7 @@ Session::midi_thread_work ()
        bool restart;
        vector<MIDI::Port*> ports;
 
-       PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("MIDI"), 2048);
+       PBD::notify_gui_about_thread_creation (pthread_self(), X_("MIDI"), 2048);
 
        memset (&rtparam, 0, sizeof (rtparam));
        rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */
@@ -1148,6 +1143,7 @@ Session::midi_thread_work ()
                        pfd[nfds].fd = _mmc_port->selectable();
                        pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
                        ports[nfds] = _mmc_port;
+                       //cerr << "MIDI port " << nfds << " = MMC @ " << _mmc_port << endl;
                        nfds++;
                }
 
@@ -1160,6 +1156,7 @@ Session::midi_thread_work ()
                        pfd[nfds].fd = _mtc_port->selectable();
                        pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
                        ports[nfds] = _mtc_port;
+                       //cerr << "MIDI port " << nfds << " = MTC @ " << _mtc_port << endl;
                        nfds++;
                }
 
@@ -1178,6 +1175,7 @@ Session::midi_thread_work ()
                        pfd[nfds].fd = _midi_port->selectable();
                        pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
                        ports[nfds] = _midi_port;
+                       // cerr << "MIDI port " << nfds << " = MIDI @ " << _midi_port << endl;
                        nfds++;
                }