Dummy audio thread to keep display responsive when no audio device.

This commit is contained in:
Robin Davies
2024-08-26 22:42:15 -04:00
parent 150ca25491
commit 179d1aa025
18 changed files with 972 additions and 332 deletions
+1 -61
View File
@@ -54,15 +54,6 @@ using namespace pipedal;
#endif
bool HasAlsaDevice(const std::vector<AlsaDeviceInfo> devices, const std::string &deviceId)
{
for (auto &device : devices)
{
if (device.id_ == deviceId)
return true;
}
return false;
}
class application_category : public boost::system::error_category
{
@@ -250,58 +241,7 @@ int main(int argc, char *argv[])
(unsigned long)getpid());
}
auto serverSettings = model.GetJackServerSettings();
{
// Wait for selected audio device to be initialized.
// It may take some time for ALSA to publish all available devices when rebooting.
if (serverSettings.IsValid())
{
// wait up to 15 seconds for the midi device to come online.
auto devices = model.GetAlsaDevices();
bool found = false;
if (HasAlsaDevice(devices, serverSettings.GetAlsaInputDevice()))
{
Lv2Log::info(SS("Found ALSA device " << serverSettings.GetAlsaInputDevice() << "."));
}
else
{
for (int i = 0; i < 5; ++i)
{
sleep(3);
devices = model.GetAlsaDevices();
if (HasAlsaDevice(devices, serverSettings.GetAlsaInputDevice()))
{
found = true;
break;
}
if (g_SigBreak)
exit(1);
if (!systemd)
{
break;
}
Lv2Log::info(SS("Waiting for ALSA device " << serverSettings.GetAlsaInputDevice() << " to come online..."));
}
if (found)
{
Lv2Log::info(SS("Found ALSA device " << serverSettings.GetAlsaInputDevice() << "."));
}
else
{
Lv2Log::info(SS("ALSA device " << serverSettings.GetAlsaInputDevice() << " not found."));
}
}
}
else
{
Lv2Log::info("No ALSA device selected.");
}
// pre-cache device info before we let audio services run.
model.GetAlsaDevices();
}
model.WaitForAudioDeviceToComeOnline();
// only accept signals on the main thread.
int sig;