Skip to content

Commit

Permalink
Disallow sample rates lower than 16000 in audio config.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Sep 6, 2024
1 parent 3c6080f commit dd575ff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/audio/IAudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

int IAudioEngine::StandardSampleRates[] =
{
8000, 9600,
11025, 12000,
16000, 22050,
24000, 32000,
44100, 48000,
Expand Down
38 changes: 38 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3166,6 +3166,44 @@ bool MainFrame::validateSoundCardSetup()
"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);
}
else
{
const int MIN_SAMPLE_RATE = 16000;
int failedSampleRate = 0;

// Validate sample rates
if (wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName != "none" && wxGetApp().appConfiguration.audioConfiguration.soundCard1In.sampleRate < MIN_SAMPLE_RATE)
{
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard1In.deviceName.get();
failedSampleRate = wxGetApp().appConfiguration.audioConfiguration.soundCard1In.sampleRate;
canRun = false;
}
else if (wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName != "none" && wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.sampleRate < MIN_SAMPLE_RATE)
{
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.deviceName.get();
failedSampleRate = wxGetApp().appConfiguration.audioConfiguration.soundCard1Out.sampleRate;
canRun = false;
}
else if (wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName != "none" && wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate < MIN_SAMPLE_RATE)
{
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard2In.deviceName.get();
failedSampleRate = wxGetApp().appConfiguration.audioConfiguration.soundCard2In.sampleRate;
canRun = false;
}
else if (wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName != "none" && wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate < MIN_SAMPLE_RATE)
{
failedDeviceName = wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.deviceName.get();
failedSampleRate = wxGetApp().appConfiguration.audioConfiguration.soundCard2Out.sampleRate;
canRun = false;
}

if (!canRun)
{
wxMessageBox(wxString::Format(
"Your %s device is set to use a sample rate of %d, which is less than the minimum of %d. Please go to Tools->Audio Config... to check your settings.",
failedDeviceName, failedSampleRate, MIN_SAMPLE_RATE), wxT("Sample Rate Too Low"), wxOK, this);
}
}

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

0 comments on commit dd575ff

Please sign in to comment.