ALSA|Dummy Backend: do as jack does:

when the backend is closed, unregister all ports.
This commit is contained in:
Robin Gareus 2014-09-07 22:50:57 +02:00
parent 330f5fdf2e
commit dc318e6e74
4 changed files with 13 additions and 8 deletions

View file

@ -646,7 +646,7 @@ AlsaAudioBackend::stop ()
delete m;
}
unregister_system_ports();
unregister_ports();
delete _pcmi; _pcmi = 0;
release_device();
@ -1057,7 +1057,7 @@ AlsaAudioBackend::register_system_midi_ports()
}
void
AlsaAudioBackend::unregister_system_ports()
AlsaAudioBackend::unregister_ports (bool system_only)
{
size_t i = 0;
_system_inputs.clear();
@ -1066,8 +1066,9 @@ AlsaAudioBackend::unregister_system_ports()
_system_midi_out.clear();
while (i < _ports.size ()) {
AlsaPort* port = _ports[i];
if (port->is_physical () && port->is_terminal ()) {
if (! system_only || (port->is_physical () && port->is_terminal ())) {
port->disconnect_all ();
delete port;
_ports.erase (_ports.begin() + i);
} else {
++i;

View file

@ -366,7 +366,7 @@ class AlsaAudioBackend : public AudioBackend {
PortHandle add_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags);
int register_system_audio_ports ();
int register_system_midi_ports ();
void unregister_system_ports ();
void unregister_ports (bool system_only = false);
std::vector<AlsaPort *> _ports;
std::vector<AlsaPort *> _system_inputs;

View file

@ -317,6 +317,9 @@ DummyAudioBackend::_start (bool /*for_latency_measurement*/)
if (_ports.size()) {
PBD::warning << _("DummyAudioBackend: recovering from unclean shutdown, port registry is not empty.") << endmsg;
for (std::vector<DummyPort*>::const_iterator it = _ports.begin (); it != _ports.end (); ++it) {
PBD::info << _("DummyAudioBackend: port '") << (*it)->name () << "' exists." << endmsg;
}
_system_inputs.clear();
_ports.clear();
}
@ -366,7 +369,7 @@ DummyAudioBackend::stop ()
PBD::error << _("DummyAudioBackend: failed to terminate.") << endmsg;
return -1;
}
unregister_system_ports();
unregister_ports();
return 0;
}
@ -709,14 +712,15 @@ DummyAudioBackend::register_system_ports()
}
void
DummyAudioBackend::unregister_system_ports()
DummyAudioBackend::unregister_ports (bool system_only)
{
size_t i = 0;
_system_inputs.clear();
while (i < _ports.size ()) {
DummyPort* port = _ports[i];
if (port->is_physical () && port->is_terminal ()) {
if (! system_only || (port->is_physical () && port->is_terminal ())) {
port->disconnect_all ();
delete port;
_ports.erase (_ports.begin() + i);
} else {
++i;

View file

@ -370,7 +370,7 @@ class DummyAudioBackend : public AudioBackend {
/* port engine */
PortHandle add_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags);
int register_system_ports ();
void unregister_system_ports ();
void unregister_ports (bool system_only = false);
std::vector<DummyAudioPort *> _system_inputs;
std::vector<DummyPort *> _ports;