summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Anderson <ardour@semiosix.com>2007-03-10 21:54:18 +0000
committerJohn Anderson <ardour@semiosix.com>2007-03-10 21:54:18 +0000
commit3c4cdadfd7a7a407431b9e56803c67782712f67b (patch)
tree435bb69747309f815a8052b0a8612f66102e911f
parent45e61c210d0efb0bc72bc3061e2b8b886547161d (diff)
clean up shutdown
git-svn-id: svn://localhost/ardour2/trunk@1571 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/surfaces/mackie/TODO4
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc32
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.h1
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol_poll.cc11
4 files changed, 30 insertions, 18 deletions
diff --git a/libs/surfaces/mackie/TODO b/libs/surfaces/mackie/TODO
index 903a8bb23d..92593e3345 100644
--- a/libs/surfaces/mackie/TODO
+++ b/libs/surfaces/mackie/TODO
@@ -2,6 +2,10 @@
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.
+* On shutdown, sometimes: GThread-ERROR **: file gthread-posix.c: line 160 (): error 'Device or resource busy' during 'pthread_mutex_destroy ((pthread_mutex_t *) mutex)'
+aborting...
+Aborted
+
* jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work.
* finish button mapping.
* concurrency for bank switching? And make sure "old" events aren't sent to "new" faders
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 0eff534f63..4ff69d1acc 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -94,6 +94,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
, connections_back( _connections )
, _surface( 0 )
, _ports_changed( false )
+ , _polling( true )
, pfd( 0 )
, nfds( 0 )
{
@@ -542,7 +543,7 @@ void MackieControlProtocol::connect_session_signals()
Sorted sorted = get_sorted_routes();
for ( Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it )
{
- (*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
+ connections_back = (*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
}
}
@@ -645,7 +646,7 @@ void MackieControlProtocol::initialize_surface()
// Connect events. Must be after route table otherwise there will be trouble
for( MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it )
{
- (*it)->control_event.connect( ( mem_fun (*this, &MackieControlProtocol::handle_control_event) ) );
+ connections_back = (*it)->control_event.connect( ( mem_fun (*this, &MackieControlProtocol::handle_control_event) ) );
}
}
@@ -654,6 +655,16 @@ void MackieControlProtocol::close()
// TODO disconnect port active/inactive signals
// Or at least put a lock here
+ // disconnect global signals from Session
+ // TODO Since *this is a sigc::trackable, this shouldn't be necessary
+ // but it is for some reason
+#if 0
+ for( vector<sigc::connection>::iterator it = _connections.begin(); it != _connections.end(); ++it )
+ {
+ it->disconnect();
+ }
+#endif
+
if ( _surface != 0 )
{
// These will fail if the port has gone away.
@@ -687,19 +698,15 @@ void MackieControlProtocol::close()
}
}
- // disconnect global signals from Session
- // TODO Since *this is a sigc::trackable, this shouldn't be necessary
- for( vector<sigc::connection>::iterator it = _connections.begin(); it != _connections.end(); ++it )
- {
- it->disconnect();
- }
-
// disconnect routes from strips
clear_route_signals();
+
+ delete _surface;
+ _surface = 0;
}
// stop polling, and wait for it...
- pthread_cancel_one( thread );
+ _polling = false;
pthread_join( thread, 0 );
// shut down MackiePorts
@@ -709,7 +716,10 @@ void MackieControlProtocol::close()
}
_ports.clear();
+ // this is done already in monitor_work. But it's here so we know.
delete[] pfd;
+ pfd = 0;
+ nfds = 0;
}
void* MackieControlProtocol::_monitor_work (void* arg)
@@ -1145,7 +1155,7 @@ void MackieControlProtocol::notify_route_added( ARDOUR::Session::RouteList & rl
typedef ARDOUR::Session::RouteList ARS;
for ( ARS::iterator it = rl.begin(); it != rl.end(); ++it )
{
- (*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
+ connections_back = (*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
}
}
diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h
index ffaf368c9c..ab773d4fb6 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.h
+++ b/libs/surfaces/mackie/mackie_control_protocol.h
@@ -296,6 +296,7 @@ class MackieControlProtocol
/// true until the port configuration is updated;
bool _ports_changed;
+ bool _polling;
struct pollfd * pfd;
int nfds;
};
diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc
index 875b19705e..1c5c67ba55 100644
--- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc
@@ -41,7 +41,7 @@ void * MackieControlProtocol::monitor_work()
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
// read from midi ports
- while ( true )
+ while ( _polling )
{
try
{
@@ -61,15 +61,12 @@ void * MackieControlProtocol::monitor_work()
{
cout << "caught exception in MackieControlProtocol::monitor_work " << e.what() << endl;
}
-
- // provide a cancellation point
- pthread_testcancel();
}
- // these never get called because of cancellation point above
- cout << "MackieControlProtocol::poll_ports exiting" << endl;
-
+ // TODO ports and pfd and nfds should be in a separate class
delete[] pfd;
+ pfd = 0;
+ nfds = 0;
return (void*) 0;
}