Skip to content

Commit

Permalink
Merge pull request #11 from opensatelliteproject/FixWinLeak
Browse files Browse the repository at this point in the history
Fixed memory leak on windows for Demodulator.
  • Loading branch information
racerxdl authored Feb 21, 2017
2 parents a70598f + 924cab3 commit c1dfa0b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions decoder/xritDecoder.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
Expand All @@ -144,7 +144,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
Expand All @@ -161,7 +161,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
Expand All @@ -180,7 +180,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
Expand Down
6 changes: 6 additions & 0 deletions demodulator/src/SymbolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ void SymbolManager::add(float *data, int length) {

void SymbolManager::add(std::complex<float> *data, int length) {
dataMutex.lock();

if (dataQueue.size() >= SM_MAX_SYMBOL_BUFFER) {
std::cerr << "SymbolManager Buffer is full!!! Dropping samples." << std::endl;
return;
}

for (int i = 0; i < length; i++) {
dataQueue.push(data[i].imag()); // M&M Outputs the data in imaginary
}
Expand Down
3 changes: 2 additions & 1 deletion demodulator/src/SymbolManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace OpenSatelliteProject {

// Number of symbols
#define SM_SOCKET_BUFFER_SIZE 1024
#define SM_SOCKET_BUFFER_SIZE 16384
#define SM_MAX_SYMBOL_BUFFER (1024 * 1024)

class SymbolManager {
private:
Expand Down
6 changes: 1 addition & 5 deletions demodulator/src/demodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,11 @@ int main(int argc, char **argv) {
std::cerr << "Failed to open Airspy Device: " << e.reason() << std::endl;
exit(1);
}
bool isMini = false;
bool sampleRateSet = false;

std::vector<uint32_t> sampleRates = device->GetAvailableSampleRates();
for (uint32_t asSR : sampleRates) {
if (asSR == sampleRate) {
isMini = true;
device->SetSampleRate(sampleRate);
sampleRateSet = true;
break;
Expand All @@ -326,9 +324,7 @@ int main(int argc, char **argv) {
return 1;
}

std::cout << "Airspy " << (isMini ? "Mini " : "R2 ")
<< "detected. Sample rate set to " << device->GetSampleRate()
<< std::endl;
std::cout << "Airspy sample rate set to " << device->GetSampleRate() << std::endl;

} else if (parser[CFG_DEVICE_TYPE] == "cfile") {
if (!parser.hasKey(CFG_FILENAME)) {
Expand Down
8 changes: 4 additions & 4 deletions demodulator/xritDemodulator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
Expand All @@ -116,7 +116,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
Expand All @@ -133,7 +133,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -151,7 +151,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=1;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
<PreprocessorDefinitions>_USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;MAJOR_VERSION=1;MINOR_VERSION=0;MAINT_VERSION=2;GIT_SHA1=Microsoft Visual C++ Compiler</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down

0 comments on commit c1dfa0b

Please sign in to comment.