From c5346f5c15e0709c6c24e7d64d1aea18272b7cd7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 5 May 2019 18:06:37 +0200 Subject: [PATCH] Fix add/remove ALSA-MIDI ports bug --- libs/backends/alsa/alsa_audiobackend.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc index 56fa82f24a..15ae6f2817 100644 --- a/libs/backends/alsa/alsa_audiobackend.cc +++ b/libs/backends/alsa/alsa_audiobackend.cc @@ -692,9 +692,10 @@ AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable assert (_rmidi_out.size() > i); AlsaMidiOut *rm = _rmidi_out.at(i); if (rm->name () != device) { ++it; ++i; continue; } - it = _system_midi_out.erase (it); unregister_port (*it); + it = _system_midi_out.erase (it); rm->stop(); + assert (rm == *(_rmidi_out.begin() + i)); _rmidi_out.erase (_rmidi_out.begin() + i); delete rm; } @@ -704,9 +705,10 @@ AlsaAudioBackend::set_midi_device_enabled (std::string const device, bool enable assert (_rmidi_in.size() > i); AlsaMidiIn *rm = _rmidi_in.at(i); if (rm->name () != device) { ++it; ++i; continue; } - it = _system_midi_in.erase (it); unregister_port (*it); + it = _system_midi_in.erase (it); rm->stop(); + assert (rm == *(_rmidi_in.begin() + i)); _rmidi_in.erase (_rmidi_in.begin() + i); delete rm; }