add locks around port read/write. Much more stable on startup now.
authorJohn Anderson <ardour@semiosix.com>
Fri, 2 Mar 2007 20:51:39 +0000 (20:51 +0000)
committerJohn Anderson <ardour@semiosix.com>
Fri, 2 Mar 2007 20:51:39 +0000 (20:51 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1549 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/TODO
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/surface_port.cc
libs/surfaces/mackie/surface_port.h

index a61b43f605abbd90e2cfff9769dae73deaf668d7..39a75dc8e283fa223659e7cc06f92891e8ee5030 100644 (file)
@@ -2,26 +2,26 @@
   where ENSURE_CORRECT_THREAD is a macro that is modelled on ENSURE_GUI_THREAD
   if the handler is not called in the "correct thread", it will use a pseudo-RT-safe-enough technique to get the correct thread to recall "handler" later on, and return.
 
-* automation feedback not working
+* automation feedback not working. gtk2_ardour seems to poll.
+* jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work.
 * finish button mapping
 * discuss button mapping for Ardour
 * concurrency for bank switching? And make sure "old" events aren't sent to "new" faders
-* concurrency in write( bytes ). Queueing?
 * TODOs in code
 * removal of a route results in a strip that isn't dead, but doesn't have any effect on the session
-* bulk remote id changes cause too many surface updates
 * use i18n. see string_compose
-* MackieControlProtocol in namespace Mackie?
-* Generic surface code to common location
-* power-cycling of surface. fd_midiport doesn't close.
 * remove couts
-* jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work.
 * docs in manual, including button assignment diagram
 
 Later
 -----
+* Queueing of writes?
+* Generic surface code to common location
+* bulk remote id changes cause too many surface updates
 * which bank switching - overlap or dead faders? Option?
 * signals for buttons?
+* MackieControlProtocol in namespace Mackie?
+* power-cycling of surface. fd_midiport doesn't close.
 * mix busses and/or a "bus-only" bank/mode
 * what about surfaces like Mackie C4 and BCR2000?
 
index d82c837c115f20772226637fbf8484b43a41fa87..3f54da88a5fd92fddd2f3d9a71c72a9197773729 100644 (file)
@@ -866,11 +866,8 @@ void MackieControlProtocol::handle_control_event( SurfacePort & port, Control &
                                                next = session->current_end_frame();
                                        }
                                        
-                                       // moves jerkily and doesn't really work. eventually core-dumps
+                                       // doesn't work very well
                                        session->request_locate( next, session->transport_rolling() );
-                                       // ditto
-                                       // ScrollTimeline( state.ticks );
-                                       // mtaht says maybe snap-to code has some ideas
                                        
                                        // turn off the led ring, for bcf emulation mode
                                        port.write( builder.build_led_ring( dynamic_cast<Pot &>( control ), off ) );
index a6f10f92433bd2b007e37bda5310915157c43cad..0cbfa23caef2e50e81e8ca8259a7935b5ea347bc 100644 (file)
@@ -43,6 +43,11 @@ MidiByteArray SurfacePort::read()
        MIDI::byte buf[max_buf_size];
        MidiByteArray retval;
 
+       // return nothing read if the lock isn't acquired
+       Glib::RecMutex::Lock lock( _rwlock, Glib::TRY_LOCK );
+       if ( !lock.locked() ) return retval;
+       
+       // read port and copy to return value
        int nread = port().read( buf, sizeof (buf) );
 
        if (nread >= 0) {
@@ -65,8 +70,9 @@ MidiByteArray SurfacePort::read()
 
 void SurfacePort::write( const MidiByteArray & mba )
 {
-       if ( mba[0] == 0xf0 ) cout << "SurfacePort::write: " << mba << endl;
+       //if ( mba[0] == 0xf0 ) cout << "SurfacePort::write: " << mba << endl;
        //cout << "SurfacePort::write: " << mba << endl;
+       Glib::RecMutex::Lock lock( _rwlock );
        int count = port().write( mba.bytes().get(), mba.size() );
        if ( count != (int)mba.size() )
        {
index c481d023212af08f181e1c1a7a9cd97471ff95ad..c060e52d935fee59570b90cd65a5891c37c592ad 100644 (file)
@@ -19,6 +19,7 @@
 #define surface_port_h
 
 #include <sigc++/signal.h>
+#include <glibmm/thread.h>
 
 #include "midi_byte_array.h"
 #include "types.h"
@@ -86,6 +87,8 @@ private:
        MIDI::Port & _port;
        int _number;
        bool _active;
+
+       Glib::RecMutex _rwlock;
 };     
 
 std::ostream & operator << ( std::ostream & , const SurfacePort & port );