diff options
author | John Anderson <ardour@semiosix.com> | 2007-03-02 20:51:39 +0000 |
---|---|---|
committer | John Anderson <ardour@semiosix.com> | 2007-03-02 20:51:39 +0000 |
commit | a38e2aff788a61c15405100c3be444cf2f5767d2 (patch) | |
tree | 0be09ad3f7b998e34c45c76d98c8f814c98fa63b /libs/surfaces | |
parent | abea2e50835f107fcc030f73b7d1c0be4ce1f3fb (diff) |
add locks around port read/write. Much more stable on startup now.
git-svn-id: svn://localhost/ardour2/trunk@1549 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/mackie/TODO | 14 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 5 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface_port.cc | 8 | ||||
-rw-r--r-- | libs/surfaces/mackie/surface_port.h | 3 |
4 files changed, 18 insertions, 12 deletions
diff --git a/libs/surfaces/mackie/TODO b/libs/surfaces/mackie/TODO index a61b43f605..39a75dc8e2 100644 --- a/libs/surfaces/mackie/TODO +++ b/libs/surfaces/mackie/TODO @@ -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? diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index d82c837c11..3f54da88a5 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -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 ) ); diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc index a6f10f9243..0cbfa23cae 100644 --- a/libs/surfaces/mackie/surface_port.cc +++ b/libs/surfaces/mackie/surface_port.cc @@ -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() ) { diff --git a/libs/surfaces/mackie/surface_port.h b/libs/surfaces/mackie/surface_port.h index c481d02321..c060e52d93 100644 --- a/libs/surfaces/mackie/surface_port.h +++ b/libs/surfaces/mackie/surface_port.h @@ -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 ); |