Browse Source

Added a small pause when switching between audio device types.

tags/2021-05-28
jules 13 years ago
parent
commit
d117e0adaa
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp

+ 12
- 3
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -373,6 +373,13 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type,
if (availableDeviceTypes.getUnchecked(i)->getTypeName() == type if (availableDeviceTypes.getUnchecked(i)->getTypeName() == type
&& currentDeviceType != type) && currentDeviceType != type)
{ {
if (currentAudioDevice != nullptr)
{
closeAudioDevice();
Thread::sleep (1500); // allow a moment for OS devices to sort themselves out, to help
// avoid things like DirectSound/ASIO clashes
}
currentDeviceType = type; currentDeviceType = type;
AudioDeviceSetup s (*lastDeviceTypeConfigs.getUnchecked(i)); AudioDeviceSetup s (*lastDeviceTypeConfigs.getUnchecked(i));
@@ -389,8 +396,8 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type,
AudioIODeviceType* AudioDeviceManager::getCurrentDeviceTypeObject() const AudioIODeviceType* AudioDeviceManager::getCurrentDeviceTypeObject() const
{ {
for (int i = 0; i < availableDeviceTypes.size(); ++i) for (int i = 0; i < availableDeviceTypes.size(); ++i)
if (availableDeviceTypes[i]->getTypeName() == currentDeviceType)
return availableDeviceTypes[i];
if (availableDeviceTypes.getUnchecked(i)->getTypeName() == currentDeviceType)
return availableDeviceTypes.getUnchecked(i);
return availableDeviceTypes[0]; return availableDeviceTypes[0];
} }
@@ -446,7 +453,9 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup
currentAudioDevice = type->createDevice (newOutputDeviceName, newInputDeviceName); currentAudioDevice = type->createDevice (newOutputDeviceName, newInputDeviceName);
if (currentAudioDevice == nullptr) if (currentAudioDevice == nullptr)
error = "Can't open the audio device!\n\nThis may be because another application is currently using the same device - if so, you should close any other applications and try again!";
error = "Can't open the audio device!\n\n"
"This may be because another application is currently using the same device - "
"if so, you should close any other applications and try again!";
else else
error = currentAudioDevice->getLastError(); error = currentAudioDevice->getLastError();


Loading…
Cancel
Save