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
This commit is contained in:
John Anderson
2007-03-02 20:51:39 +00:00
parent abea2e5083
commit a38e2aff78
4 changed files with 18 additions and 12 deletions

View 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?

View 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 ) );

View 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() )
{

View 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 );