Fix FP8 shutdown sequence (amend d421e56fc)

This commit is contained in:
Robin Gareus 2017-07-06 16:55:02 +02:00
parent 7bb48aaa3f
commit d5d297c407
2 changed files with 14 additions and 14 deletions

View file

@ -147,19 +147,21 @@ FaderPort8::FaderPort8 (Session& s)
FaderPort8::~FaderPort8 () FaderPort8::~FaderPort8 ()
{ {
cerr << "~FP8\n"; /* this will be called from the main UI thread. during Session::destroy().
disconnected (); * There can be concurrent activity from BaseUI::main_thread -> AsyncMIDIPort
close (); * -> MIDI::Parser::signal -> ... to any of the midi_connections
*
* stop event loop early and join thread */
stop ();
if (_input_port) { if (_input_port) {
DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering input port %1\n", boost::shared_ptr<ARDOUR::Port>(_input_port)->name())); DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering input port %1\n", boost::shared_ptr<ARDOUR::Port>(_input_port)->name()));
_input_port->disconnect_all ();
_input_port->drain (5000, 50000);
_input_port->clear ();
AudioEngine::instance()->unregister_port (_input_port); AudioEngine::instance()->unregister_port (_input_port);
_input_port.reset (); _input_port.reset ();
} }
disconnected (); // zero faders, turn lights off, clear strips
if (_output_port) { if (_output_port) {
_output_port->drain (10000, 250000); /* check every 10 msecs, wait up to 1/4 second for the port to drain */ _output_port->drain (10000, 250000); /* check every 10 msecs, wait up to 1/4 second for the port to drain */
DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering output port %1\n", boost::shared_ptr<ARDOUR::Port>(_output_port)->name())); DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering output port %1\n", boost::shared_ptr<ARDOUR::Port>(_output_port)->name()));
@ -168,10 +170,6 @@ FaderPort8::~FaderPort8 ()
} }
tear_down_gui (); tear_down_gui ();
/* stop event loop */
DEBUG_TRACE (DEBUG::FaderPort8, "BaseUI::quit ()\n");
BaseUI::quit ();
} }
/* **************************************************************************** /* ****************************************************************************
@ -196,13 +194,16 @@ FaderPort8::do_request (FaderPort8Request* req)
call_slot (MISSING_INVALIDATOR, req->the_slot); call_slot (MISSING_INVALIDATOR, req->the_slot);
} else if (req->type == Quit) { } else if (req->type == Quit) {
stop (); stop ();
disconnected ();
} }
} }
int void
FaderPort8::stop () FaderPort8::stop ()
{ {
DEBUG_TRACE (DEBUG::FaderPort8, "BaseUI::quit ()\n");
BaseUI::quit (); BaseUI::quit ();
close (); // drop references, disconnect from session signals
return 0; return 0;
} }
@ -277,8 +278,7 @@ FaderPort8::set_active (bool yn)
BaseUI::run (); BaseUI::run ();
connect_session_signals (); connect_session_signals ();
} else { } else {
BaseUI::quit (); stop ();
close ();
} }
ControlProtocol::set_active (yn); ControlProtocol::set_active (yn);

View file

@ -99,7 +99,7 @@ public:
bool twolinetext () const { return _two_line_text; } bool twolinetext () const { return _two_line_text; }
bool auto_pluginui () const { return _auto_pluginui; } bool auto_pluginui () const { return _auto_pluginui; }
int stop (); void stop ();
void do_request (FaderPort8Request*); void do_request (FaderPort8Request*);
void thread_init (); void thread_init ();