1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-16 07:31:16 +02:00

bug 29/11 - add rescan capability for devices.

This is a workaround for the portaudio issue where changing the default device in xp will corrupt the portaudio device indecies.
This combined with the portmixer fix (earlier today) should address bug 29.
This commit is contained in:
mchinen
2011-02-13 23:00:43 +00:00
parent 271c4b0112
commit 4a762fc936
5 changed files with 63 additions and 36 deletions

View File

@@ -9,9 +9,11 @@
#include "portaudio.h"
#include "portmixer.h"
#include "../Audacity.h"
#include "Audacity.h"
#include "AudioIO.h"
#include "DeviceManager.h"
#include "toolbars/DeviceToolBar.h"
DeviceManager DeviceManager::dm;
@@ -30,13 +32,13 @@ void DeviceManager::Destroy()
std::vector<DeviceSourceMap> &DeviceManager::GetInputDeviceMaps()
{
if (!m_inited)
Rescan();
Init();
return mInputDeviceSourceMaps;
}
std::vector<DeviceSourceMap> &DeviceManager::GetOutputDeviceMaps()
{
if (!m_inited)
Rescan();
Init();
return mOutputDeviceSourceMaps;
}
@@ -190,8 +192,18 @@ void DeviceManager::Rescan()
// if we are doing a second scan then restart portaudio to get new devices
if (m_inited) {
// check to see if there is a stream open - can happen if monitoring,
// but otherwise Rescan() should not be available to the user.
// but otherwise Rescan() should not be available to the user.
if (gAudioIO) {
if (gAudioIO->IsMonitoring())
{
gAudioIO->StopStream();
while (gAudioIO->IsBusy())
wxMilliSleep(100);
}
gAudioIO->HandleDeviceChange();
}
// restart portaudio - this updates the device list
Pa_Terminate();
Pa_Initialize();
}
@@ -213,6 +225,15 @@ void DeviceManager::Rescan()
}
}
// If this was not an initial scan update each device toolbar.
// Hosts may have disappeared or appeared so a complete repopulate is needed.
if (m_inited) {
DeviceToolBar *dt;
for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
dt = gAudacityProjects[i]->GetDeviceToolBar();
dt->RefillCombos();
}
}
m_inited = true;
}