mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 09:00:52 +02:00
Allow capture retries if time since Rescan() < 10s
The time since Rescan() of recording device is the important factor, not the "newness" of the project.
This commit is contained in:
parent
aeba34b152
commit
11da92d668
@ -408,7 +408,7 @@ TimeTrack and AudioIOListener and whether the playback is looped.
|
|||||||
#include "Experimental.h"
|
#include "Experimental.h"
|
||||||
#include "AudioIO.h"
|
#include "AudioIO.h"
|
||||||
#include "float_cast.h"
|
#include "float_cast.h"
|
||||||
#include "UndoManager.h"
|
#include "DeviceManager.h"
|
||||||
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -1780,11 +1780,12 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
|
|||||||
int userData = 24;
|
int userData = 24;
|
||||||
int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : NULL;
|
int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : NULL;
|
||||||
|
|
||||||
// (Linux, bug 1885) On first use, the device may not be ready in time, so allow retries.
|
// (Linux, bug 1885) After scanning devices it takes a little time for the
|
||||||
|
// ALSA device to be available, so allow retries.
|
||||||
// On my test machine, no more than 3 attempts are required.
|
// On my test machine, no more than 3 attempts are required.
|
||||||
unsigned int maxTries = 1;
|
unsigned int maxTries = 1;
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
if (!mOwningProject->GetUndoManager()->UnsavedChanges())
|
if (DeviceManager::Instance()->GetTimeSinceRescan() < 10)
|
||||||
maxTries = 5;
|
maxTries = 5;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -306,8 +306,17 @@ void DeviceManager::Rescan()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_inited = true;
|
m_inited = true;
|
||||||
|
mRescanTime = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float DeviceManager::GetTimeSinceRescan() {
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
auto dur = std::chrono::duration_cast<std::chrono::duration<float>>(now - mRescanTime);
|
||||||
|
return dur.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//private constructor - Singleton.
|
//private constructor - Singleton.
|
||||||
DeviceManager::DeviceManager()
|
DeviceManager::DeviceManager()
|
||||||
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
|
#if defined(EXPERIMENTAL_DEVICE_CHANGE_HANDLER)
|
||||||
@ -317,6 +326,7 @@ DeviceManager::DeviceManager()
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_inited = false;
|
m_inited = false;
|
||||||
|
mRescanTime = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::~DeviceManager()
|
DeviceManager::~DeviceManager()
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Experimental.h"
|
#include "Experimental.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "wx/wx.h"
|
#include "wx/wx.h"
|
||||||
|
|
||||||
@ -55,6 +56,9 @@ class DeviceManager final
|
|||||||
/// Assumes that DeviceManager is only used on the main thread.
|
/// Assumes that DeviceManager is only used on the main thread.
|
||||||
void Rescan();
|
void Rescan();
|
||||||
|
|
||||||
|
// Time since devices scanned in seconds.
|
||||||
|
float GetTimeSinceRescan();
|
||||||
|
|
||||||
DeviceSourceMap* GetDefaultOutputDevice(int hostIndex);
|
DeviceSourceMap* GetDefaultOutputDevice(int hostIndex);
|
||||||
DeviceSourceMap* GetDefaultInputDevice(int hostIndex);
|
DeviceSourceMap* GetDefaultInputDevice(int hostIndex);
|
||||||
|
|
||||||
@ -68,6 +72,9 @@ class DeviceManager final
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock> mRescanTime;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//private constructor - Singleton.
|
//private constructor - Singleton.
|
||||||
DeviceManager();
|
DeviceManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user