Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid modifying the audio device configuration without the user explicitly doing so. #735

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Show green line indicating RX frequency. (PR #725)
* Update configuration of the Voice Keyer feature based on user feedback. (PR #730)
* Add monitor volume adjustment. (PR #733)
* Avoid modifying the audio device configuration without the user explicitly doing so. (PR #735)
3. Build system:
* Allow overrriding the version tag when building. (PR #727)
* Update wxWidgets to 3.2.5. (PR #731)
Expand Down
87 changes: 11 additions & 76 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3094,99 +3094,28 @@ bool MainFrame::validateSoundCardSetup()
auto soundCard2InDevice = engine->getAudioDevice(wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName, IAudioEngine::AUDIO_ENGINE_IN, wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate, 1);
auto soundCard2OutDevice = engine->getAudioDevice(wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName, IAudioEngine::AUDIO_ENGINE_OUT, wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate, 1);

wxString failedDeviceName;
if (wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName != "none" && !soundCard1InDevice)
{
wxMessageBox(wxString::Format(
"Your %s device cannot be found and may have been removed from your system. Please go to Tools->Audio Config... to confirm your audio setup.",
wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName.get()), wxT("Sound Device Removed"), wxOK, this);
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName.get();
canRun = false;
}
else if (canRun && wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName != "none" && !soundCard1OutDevice)
{
wxMessageBox(wxString::Format(
"Your %s device cannot be found and may have been removed from your system. Please go to Tools->Audio Config... to confirm your audio setup.",
wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName.get()), wxT("Sound Device Removed"), wxOK, this);
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName.get();
canRun = false;
}
else if (canRun && wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName != "none" && !soundCard2InDevice)
{
wxMessageBox(wxString::Format(
"Your %s device cannot be found and may have been removed from your system. Please go to Tools->Audio Config... to confirm your audio setup.",
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName.get()), wxT("Sound Device Removed"), wxOK, this);
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName.get();
canRun = false;
}
else if (canRun && wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName != "none" && !soundCard2OutDevice)
{
wxMessageBox(wxString::Format(
"Your %s device cannot be found and may have been removed from your system. Please go to Tools->Audio Config... to confirm your audio setup.",
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName.get()), wxT("Sound Device Removed"), wxOK, this);
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName.get();
canRun = false;
}

if (!canRun)
{
if (g_nSoundCards == 1)
{
if (!soundCard1OutDevice && defaultOutputDevice.isValid())
{
wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName = defaultOutputDevice.name;
wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.sampleRate = defaultOutputDevice.defaultSampleRate;
}
else
{
wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName = "none";
wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.sampleRate = 0;
}
}
else if (g_nSoundCards == 2)
{
if (!soundCard2InDevice && defaultInputDevice.isValid())
{
// If we're not already using the default input device as the radio input device, use that instead.
if (defaultInputDevice.name != wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName)
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName = defaultInputDevice.name;
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate = defaultInputDevice.defaultSampleRate;
}
else
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName = "none";
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate = 0;
}
}
else
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName = "none";
wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate = 0;
}

if (!soundCard2OutDevice && defaultOutputDevice.isValid())
{
// If we're not already using the default output device as the radio input device, use that instead.
if (defaultOutputDevice.name != wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName)
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName = defaultOutputDevice.name;
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate = defaultOutputDevice.defaultSampleRate;
}
else
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName = "none";
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate = 0;
}
}
else
{
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName = "none";
wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate = 0;
}

if (wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName == "none" && wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName == "none")
{
g_nSoundCards = 1;
}
}
}

if (canRun && g_nSoundCards == 0)
{
// Initial setup. Display Easy Setup dialog.
Expand Down Expand Up @@ -3215,6 +3144,12 @@ bool MainFrame::validateSoundCardSetup()
});
canRun = false;
}
else if (!canRun)
{
wxMessageBox(wxString::Format(
"Your %s device cannot be found and may have been removed from your system. Please reattach this device, close this message box and retry. If this fails, go to Tools->Audio Config... to check your settings.",
failedDeviceName), wxT("Sound Device Not Found"), wxOK, this);
}

engine->stop();
engine->setOnEngineError(nullptr, nullptr);
Expand Down
Loading