Set stream handle to 0 in LMS_DestroyStream()
should handle attempts to use stream after closing in nicer manner
@@ -731,12 +731,19 @@ API_EXPORT int CALL_CONV LMS_DestroyStream(lms_device_t *device, lms_stream_t *s
{
if(stream == nullptr)
{
- lime::error("stream cannot be NULL.");
+ lime::error("Stream cannot be NULL.");
+ return -1;
+ }
+ if (stream->handle == 0)
+ {
+ lime::error("Invalid stream handle");
return -1;
}
- lime::LMS7_Device* lms = (lime::LMS7_Device*)device;
- return lms->DestroyStream((lime::StreamChannel*)stream->handle);
+ lime::LMS7_Device* lms = CheckDevice(device);
+ lms->DestroyStream((lime::StreamChannel*)stream->handle);
+ stream->handle = 0;
+ return 0;
}
API_EXPORT int CALL_CONV LMS_StartStream(lms_stream_t *stream)
