@@ -49,7 +49,7 @@ bool SoapyPlutoSDR::IsValidRxStreamHandle(SoapySDR::Stream* handle) const
49
49
}
50
50
51
51
// handle is an opaque pointer hiding either rx_stream or tx_streamer:
52
- // check that the handle matches one of them, onsistently with direction:
52
+ // check that the handle matches one of them, consistently with direction:
53
53
if (rx_stream) {
54
54
// test if these handles really belong to us:
55
55
if (reinterpret_cast <rx_streamer*>(handle) == rx_stream.get ()) {
@@ -67,7 +67,7 @@ bool SoapyPlutoSDR::IsValidTxStreamHandle(SoapySDR::Stream* handle)
67
67
}
68
68
69
69
// handle is an opaque pointer hiding either rx_stream or tx_streamer:
70
- // check that the handle matches one of them, onsistently with direction:
70
+ // check that the handle matches one of them, consistently with direction:
71
71
if (tx_stream) {
72
72
// test if these handles really belong to us:
73
73
if (reinterpret_cast <tx_streamer*>(handle) == tx_stream.get ()) {
@@ -272,9 +272,9 @@ void rx_streamer::set_buffer_size_by_samplerate(const size_t samplerate) {
272
272
SoapySDR_logf (SOAPY_SDR_INFO, " Auto setting Buffer Size: %lu" , (unsigned long )buffer_size);
273
273
274
274
// Recompute MTU from buffer size change.
275
- // We set MTU size = Buffer Size.
276
- // in the future buffer size may be able to adjust of sample rate,
277
- // in this case MTU can be changed accordingly safely here.
275
+ // We always set MTU size = Buffer Size.
276
+ // On buffer size adjustment to sample rate,
277
+ // MTU can be changed accordingly safely here.
278
278
set_mtu_size (this ->buffer_size );
279
279
}
280
280
@@ -520,11 +520,18 @@ int rx_streamer::stop(const int flags,
520
520
void rx_streamer::set_buffer_size (const size_t _buffer_size){
521
521
522
522
if (!buf || this ->buffer_size != _buffer_size) {
523
- if (buf) {
524
- iio_buffer_destroy (buf);
525
- }
523
+ // cancel first
524
+ if (buf) {
525
+ iio_buffer_cancel (buf);
526
+ }
527
+ // then destroy
528
+ if (buf) {
529
+ iio_buffer_destroy (buf);
530
+ }
526
531
527
532
items_in_buffer = 0 ;
533
+ byte_offset = 0 ;
534
+
528
535
buf = iio_device_create_buffer (dev, _buffer_size, false );
529
536
if (!buf) {
530
537
SoapySDR_logf (SOAPY_SDR_ERROR, " Unable to create buffer!" );
0 commit comments