MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / handleAudioDeviceListChanged

Method handleAudioDeviceListChanged

src/gui/MainWindow.cpp:3596–3709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3594}
3595
3596void MainWindow::handleAudioDeviceListChanged()
3597{
3598 if (!m_audio || m_shuttingDown)
3599 return;
3600
3601 if (m_audioDeviceDialogOpen) {
3602 m_audioDeviceChangeTimer.start();
3603 return;
3604 }
3605
3606 const QList<QAudioDevice> inputDevices = QMediaDevices::audioInputs();
3607 const QList<QAudioDevice> outputDevices = QMediaDevices::audioOutputs();
3608 const QAudioDevice defaultInput = QMediaDevices::defaultAudioInput();
3609 const QAudioDevice defaultOutput = QMediaDevices::defaultAudioOutput();
3610 const QByteArray currentDefaultInputId = defaultInput.id();
3611 const QByteArray currentDefaultOutputId = defaultOutput.id();
3612 const QList<QByteArray> currentInputIds = audioDeviceIds(inputDevices);
3613 const QList<QByteArray> currentOutputIds = audioDeviceIds(outputDevices);
3614 const QList<QByteArray> addedInputIds =
3615 newlyAddedAudioDeviceIds(inputDevices, m_knownAudioInputIds);
3616 const QList<QByteArray> addedOutputIds =
3617 newlyAddedAudioDeviceIds(outputDevices, m_knownAudioOutputIds);
3618 const QList<QByteArray> removedInputIds =
3619 removedAudioDeviceIds(m_knownAudioInputIds, currentInputIds);
3620 const QList<QByteArray> removedOutputIds =
3621 removedAudioDeviceIds(m_knownAudioOutputIds, currentOutputIds);
3622
3623 m_knownAudioInputIds = currentInputIds;
3624 m_knownAudioOutputIds = currentOutputIds;
3625 const bool defaultInputChanged =
3626 currentDefaultInputId != m_knownDefaultAudioInputId;
3627 const bool defaultOutputChanged =
3628 currentDefaultOutputId != m_knownDefaultAudioOutputId;
3629 m_knownDefaultAudioInputId = currentDefaultInputId;
3630 m_knownDefaultAudioOutputId = currentDefaultOutputId;
3631
3632 const QAudioDevice currentInput = m_audio->inputDevice();
3633 const QAudioDevice currentOutput = m_audio->outputDevice();
3634 const bool resetInputToDefault =
3635 !currentInput.isNull() && !audioDevicePresent(inputDevices, currentInput);
3636 const bool resetOutputToDefault =
3637 !currentOutput.isNull() && !audioDevicePresent(outputDevices, currentOutput);
3638 const bool defaultInputNeedsRestart =
3639 currentInput.isNull() && (!removedInputIds.isEmpty() || defaultInputChanged);
3640 const bool defaultOutputNeedsRestart =
3641 currentOutput.isNull() && (!removedOutputIds.isEmpty() || defaultOutputChanged);
3642 const bool resetInput = resetInputToDefault || defaultInputNeedsRestart;
3643 const bool resetOutput = resetOutputToDefault || defaultOutputNeedsRestart;
3644 const bool reinitializePcInput = resetInput
3645 && m_radioModel.isConnected()
3646 && m_radioModel.transmitModel().micSelection() == "PC";
3647
3648 const bool deviceAdded = !addedInputIds.isEmpty() || !addedOutputIds.isEmpty();
3649 // Only prompt when the user's existing selection is no longer usable;
3650 // a new arrival while both selections still work is platform-audio
3651 // churn, not an actionable change (issue #2864).
3652 const bool currentSelectionStillValid =
3653 audioDevicePresent(inputDevices, currentInput)

Callers

nothing calls this directly

Calls 15

audioDeviceIdsFunction · 0.85
newlyAddedAudioDeviceIdsFunction · 0.85
removedAudioDeviceIdsFunction · 0.85
audioDevicePresentFunction · 0.85
sameAudioDeviceSelectionFunction · 0.85
idMethod · 0.80
inputDeviceMethod · 0.80
outputDeviceMethod · 0.80
isNullMethod · 0.80
micSelectionMethod · 0.80
dontAskAgainCheckedMethod · 0.80
selectedInputDeviceMethod · 0.80

Tested by

no test coverage detected