Skip to content

Commit

Permalink
Fix a potential crash
Browse files Browse the repository at this point in the history
SDRSharp was crashing when hitting the stop button if the device has
been lost while sampling. This was due to a loop of exception.
  • Loading branch information
jmichelp committed Jul 28, 2014
1 parent e6d6849 commit f0b781a
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions BladeRF/BladeRFDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public void Dispose()

private unsafe void ReceiveSamples_sync()
{
int status = 0;
while (_isStreaming)
{
uint cur_len, new_len;
Expand All @@ -395,9 +396,8 @@ private unsafe void ReceiveSamples_sync()
_samplesBuffer = UnsafeBuffer.Create((int)(2 * cur_len), sizeof(Int16));
_samplesPtr = (Int16*)_samplesBuffer;
}
if (NativeMethods.bladerf_sync_config(_dev, bladerf_module.BLADERF_MODULE_RX, bladerf_format.BLADERF_FORMAT_SC16_Q11, NumBuffers, cur_len, NumBuffers / 2, SampleTimeoutMs) != 0)
return;
int status = 0;
if ((status = NativeMethods.bladerf_sync_config(_dev, bladerf_module.BLADERF_MODULE_RX, bladerf_format.BLADERF_FORMAT_SC16_Q11, NumBuffers, cur_len, NumBuffers / 2, SampleTimeoutMs)) != 0)
_isStreaming = false;
while (status == 0 && cur_len == new_len)
{
try
Expand Down Expand Up @@ -577,10 +577,10 @@ public void Stop()
if (_isStreaming)
{
int error;
_isStreaming = false;
if ((error = NativeMethods.bladerf_enable_module(_dev, bladerf_module.BLADERF_MODULE_RX, 0)) != 0)
throw new ApplicationException(String.Format("Disabling RX module failed: {0}", NativeMethods.bladerf_strerror(error)));
}
_isStreaming = false;

if (_sampleThread != null)
{
Expand Down
Binary file modified Debug/SDRSharp.BladeRF.dll
Binary file not shown.
Binary file modified Debug/SDRSharp.BladeRF.pdb
Binary file not shown.
Binary file modified Release/SDRSharp.BladeRF.dll
Binary file not shown.
Binary file modified Release/SDRSharp.BladeRF.pdb
Binary file not shown.

0 comments on commit f0b781a

Please sign in to comment.