File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
source_modules/file_source/src Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1010#include < regex>
1111#include < gui/tuner.h>
1212#include < algorithm>
13+ #include < stdexcept>
1314
1415// TODO: figure out where exactly these macros are from (only happens on windows so probably from Windows.h somewhere)
1516#ifdef min
@@ -130,7 +131,13 @@ class FileSourceModule : public ModuleManager::Instance {
130131 }
131132 try {
132133 _this->reader = new WavReader (_this->fileSelect .path );
133- _this->sampleRate = std::max (_this->reader ->getSampleRate (), (uint32_t )1 );
134+ if (_this->reader ->getSampleRate () == 0 ) {
135+ _this->reader ->close ();
136+ delete _this->reader ;
137+ _this->reader = NULL ;
138+ throw std::runtime_error (" Sample rate may not be zero" );
139+ }
140+ _this->sampleRate = _this->reader ->getSampleRate ();
134141 core::setInputSampleRate (_this->sampleRate );
135142 std::string filename = std::filesystem::path (_this->fileSelect .path ).filename ().string ();
136143 _this->centerFreq = _this->getFrequency (filename);
@@ -139,7 +146,7 @@ class FileSourceModule : public ModuleManager::Instance {
139146 // gui::freqSelect.maxFreq = _this->centerFreq + (_this->sampleRate/2);
140147 // gui::freqSelect.limitFreq = true;
141148 }
142- catch (std::exception e) {
149+ catch (std::exception& e) {
143150 flog::error (" Error: {0}" , e.what ());
144151 }
145152 config.acquire ();
You can’t perform that action at this time.
0 commit comments