#include <midi++/port.h>
#include <midi++/manager.h>
#include <pbd/error.h>
-#include <pbd/lockmonitor.h>
+#include <glibmm/thread.h>
#include <pbd/pthread_utils.h>
#include <ardour/configuration.h>
poke_midi_thread ();
if (_midi_port) {
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
+ Glib::RWLock::ReaderLock guard (route_lock);
for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
(*i)->reset_midi_control (_midi_port, midi_control);
}
ControlChanged (SendMMC); /* EMIT SIGNAL */
}
+void
+Session::set_midi_feedback (bool yn)
+{
+}
+
+bool
+Session::get_midi_feedback () const
+{
+ return false;
+}
+
bool
Session::get_send_mtc () const
{
}
_midi_port = port;
+
+ /* XXX need something to forward this to control protocols ? or just
+ use the signal below
+ */
Config->set_midi_port_name (port_tag);
}
-
-void
-Session::set_midi_feedback (bool yn)
-{
- if (_midi_port == 0) {
- return;
- }
-
- midi_feedback = yn;
- set_dirty();
-
- if (yn) {
- /* make sure the feedback thread is alive */
- start_feedback ();
- } else {
- /* maybe put the feedback thread to sleep */
- stop_feedback ();
- }
-
- ControlChanged (MidiFeedback); /* EMIT SIGNAL */
-
- send_all_midi_feedback ();
-}
-
-void
-Session::send_all_midi_feedback ()
-{
- if (midi_feedback) {
- // send out current state of all routes
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
- for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
- (*i)->send_all_midi_feedback ();
- }
- }
-}
-
void
Session::setup_midi_control ()
{
*/
save_state ("", true);
- atomic_set (&_record_status, Enabled);
- RecordEnabled (); /* EMIT SIGNAL */
+ g_atomic_int_set (&_record_status, Enabled);
+ RecordStateChanged (); /* EMIT SIGNAL */
request_transport_speed (1.0);
Session::mmc_record_exit (MIDI::MachineControl &mmc)
{
if (mmc_control) {
- disable_record ();
+ disable_record (false);
}
}
{
if (mmc_control) {
- /* don't take route or diskstream lock: if using dynamic punch,
- this could cause a dropout. XXX is that really OK?
- or should we queue a rec-enable request?
- */
-
- size_t n;
RouteList::iterator i;
-
- for (n = 0, i = routes.begin(); i != routes.end(); ++i) {
+ Glib::RWLock::ReaderLock guard (route_lock);
+
+ for (i = routes.begin(); i != routes.end(); ++i) {
AudioTrack *at;
if ((at = dynamic_cast<AudioTrack*>(*i)) != 0) {
- if (n++ == trk) {
+ if (trk == at->remote_control_id()) {
at->set_record_enable (enabled, &mmc);
break;
}
}
}
+ // Compensate for audio latency
+ outbound_mtc_smpte_frame += _worst_output_latency;
+
next_quarter_frame_to_send = 0;
// Sync slave to the same smpte time as we are on (except if negative, see above)
msg[8] = smpte.frames;
{
- LockMonitor lm (midi_lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (midi_lock);
if (_mtc_port->midimsg (msg, sizeof (msg))) {
error << _("Session: could not send full MIDI time code") << endmsg;
// Send quarter frames up to current time
{
- LockMonitor lm (midi_lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (midi_lock);
switch(next_quarter_frame_to_send) {
case 0:
smpte_increment( transmitting_smpte_time );
// Re-calculate timing of first quarter frame
smpte_to_sample( transmitting_smpte_time, outbound_mtc_smpte_frame, true /* use_offset */, false );
+ // Compensate for audio latency
+ outbound_mtc_smpte_frame += _worst_output_latency;
}
}
}
mmc_buffer[nbytes++] = 0xf7; // terminate SysEx/MMC message
- LockMonitor lm (midi_lock, __LINE__, __FILE__);
+ Glib::Mutex::Lock lm (midi_lock);
if (_mmc_port->write (mmc_buffer, nbytes) != nbytes) {
error << string_compose(_("MMC: cannot send command %1%2%3"), &hex, cmd, &dec) << endmsg;
bool restart;
vector<MIDI::Port*> ports;
- PBD::ThreadCreated (pthread_self(), X_("MIDI"));
+ PBD::ThreadCreatedWithRequestSize (pthread_self(), X_("MIDI"), 2048);
memset (&rtparam, 0, sizeof (rtparam));
rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */
tmp = i;
++tmp;
- if (!(*i)) {
+ if (!(*i)()) {
midi_timeouts.erase (i);
}
{
return mmc_control;
}
-bool
-Session::get_midi_feedback () const
-{
- /* since this a "write" function we have to check the port as well
- as the control toggle.
- */
- return _midi_port && midi_feedback;
-}
+
bool
Session::get_midi_control () const
{