Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Commit

Permalink
(WIP) Destroy LMS stream on flow-graph stop
Browse files Browse the repository at this point in the history
  • Loading branch information
axilirator committed Jan 21, 2019
1 parent 445b78c commit 1aad0cd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
14 changes: 11 additions & 3 deletions lib/sink_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ bool sink_impl::stop(void) {
std::unique_lock<std::recursive_mutex> lock(device_handler::getInstance().block_mutex);
// Stop stream for channel 0 (if channel_mode is SISO)
if (stored.channel_mode < 3) {
LMS_StopStream(&streamId[stored.channel]);
this->release_stream(stored.device_number, &streamId[stored.channel]);
// LMS_StopStream(&streamId[stored.channel]);
}
// Stop streams for channels 0 & 1 (if channel_mode is MIMO)
else if (stored.channel_mode == 3) {
LMS_StopStream(&streamId[LMS_CH_0]);
LMS_StopStream(&streamId[LMS_CH_1]);
this->release_stream(stored.device_number, &streamId[LMS_CH_0]);
this->release_stream(stored.device_number, &streamId[LMS_CH_1]);
// LMS_StopStream(&streamId[LMS_CH_0]);
// LMS_StopStream(&streamId[LMS_CH_1]);
}
std::unique_lock<std::recursive_mutex> unlock(device_handler::getInstance().block_mutex);
return true;
Expand Down Expand Up @@ -305,6 +308,11 @@ void sink_impl::init_stream(int device_number, int channel, float samp_rate) {
<< device_number << ") stream setup done." << std::endl;
}

void sink_impl::release_stream(int device_number, lms_stream_t *stream) {
LMS_StopStream(stream);
LMS_DestroyStream(device_handler::getInstance().get_device(device_number), stream);
}

// Return io_signature to manage module input count
// based on SISO (one input) and MIMO (two inputs) modes
inline gr::io_signature::sptr sink_impl::args_to_io_signature(int channel_number, int device_type) {
Expand Down
1 change: 1 addition & 0 deletions lib/sink_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class sink_impl : public sink {
inline gr::io_signature::sptr args_to_io_signature(int channel_number, int device_number);

void init_stream(int device_number, int channel, float samp_rate);
void release_stream(int device_number, lms_stream_t *stream);

double set_center_freq(double freq, size_t chan = 0);

Expand Down
14 changes: 11 additions & 3 deletions lib/source_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,15 @@ bool source_impl::stop(void) {
std::unique_lock<std::recursive_mutex> lock(device_handler::getInstance().block_mutex);
// Stop stream for channel 0 (if channel_mode is SISO)
if (stored.channel_mode < 3) {
LMS_StopStream(&streamId[stored.channel]);
this->release_stream(stored.device_number, &streamId[stored.channel]);
// LMS_StopStream(&streamId[stored.channel]);
}
// Stop streams for channels 0 & 1 (if channel_mode is MIMO)
else if (stored.channel_mode == 3) {
LMS_StopStream(&streamId[LMS_CH_0]);
LMS_StopStream(&streamId[LMS_CH_1]);
this->release_stream(stored.device_number, &streamId[LMS_CH_0]);
this->release_stream(stored.device_number, &streamId[LMS_CH_1]);
// LMS_StopStream(&streamId[LMS_CH_0]);
// LMS_StopStream(&streamId[LMS_CH_1]);
}
std::unique_lock<std::recursive_mutex> unlock(device_handler::getInstance().block_mutex);
return true;
Expand Down Expand Up @@ -245,6 +248,11 @@ void source_impl::init_stream(int device_number, int channel, float samp_rate) {
<< device_number << ") stream setup done." << std::endl;
}

void source_impl::release_stream(int device_number, lms_stream_t *stream) {
LMS_StopStream(stream);
LMS_DestroyStream(device_handler::getInstance().get_device(device_number), stream);
}

// Print stream status
void source_impl::print_stream_stats(lms_stream_status_t status) {
t2 = std::chrono::high_resolution_clock::now();
Expand Down
1 change: 1 addition & 0 deletions lib/source_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class source_impl : public source {
inline gr::io_signature::sptr args_to_io_signature(int channel_number, int device_number);

void init_stream(int device_number, int channel, float samp_rate);
void release_stream(int device_number, lms_stream_t *stream);

double set_center_freq(double freq, size_t chan = 0);

Expand Down

0 comments on commit 1aad0cd

Please sign in to comment.