1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioDeviceManager: Fix MidiOutput dangling pointer

Changed the lifetime of the default MIDI oputput.
Removed the need for Timer workaround in AudioDeviceSelectorComponent.
This commit is contained in:
Oli 2022-05-10 15:44:30 +01:00 committed by Tom Poole
parent 319da1608d
commit 2bca60e52c
3 changed files with 4 additions and 16 deletions

View file

@ -1088,6 +1088,7 @@ void AudioDeviceManager::setDefaultMidiOutputDevice (const String& identifier)
{
if (defaultMidiOutputDeviceInfo.identifier != identifier)
{
std::unique_ptr<MidiOutput> oldMidiPort;
Array<AudioIODeviceCallback*> oldCallbacks;
{
@ -1099,7 +1100,7 @@ void AudioDeviceManager::setDefaultMidiOutputDevice (const String& identifier)
for (int i = oldCallbacks.size(); --i >= 0;)
oldCallbacks.getUnchecked (i)->audioDeviceStopped();
defaultMidiOutput.reset();
std::swap (oldMidiPort, defaultMidiOutput);
if (identifier.isNotEmpty())
defaultMidiOutput = MidiOutput::openDevice (identifier);
@ -1119,7 +1120,7 @@ void AudioDeviceManager::setDefaultMidiOutputDevice (const String& identifier)
}
updateXml();
sendChangeMessage();
sendSynchronousChangeMessage();
}
}