Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make stream deactivated before a sample-rate change and reactivated afterwards #718

Merged
merged 2 commits into from Mar 15, 2019

Conversation

Projects
None yet
4 participants
@vsonnier
Copy link
Collaborator

vsonnier commented Mar 10, 2019

Origin : #716 where LimeSDR do not like setSampleRate while streaming. This PR changes CubicSDR behaviour to shut-up stream with deactivateStream before doing the sample rate change, then only activateStream again at the end.

I've tested this on RTL-SDR, SDRPlay RSP2, Adalm-PlutoSDR on Windows10 1809 x64. With these, changing sample rates works nor better not worse that before.

I've also tried these devices through a (localhost) SoapyRemote connection, everything is fine.

For these devices at least, the change if not visibly longer on CubicSDR.

@vsonnier vsonnier changed the title Make stream deactivated before a sample-rate chnage and reactivated afterwards Make stream deactivated before a sample-rate change and reactivated afterwards Mar 10, 2019

@vsonnier

This comment has been minimized.

Copy link
Collaborator Author

vsonnier commented Mar 10, 2019

@Dantali0n @juribeparada @guruofquality you can now give it a try with LimeSDR.

@Dantali0n

This comment has been minimized.

Copy link
Contributor

Dantali0n commented Mar 10, 2019

Works great on LimeSDR-USB, time taken between deactivate / activate is significantly decreased as well. Audio & waterfall stutters persist at 65Mhz sampling but that is just a limitation of my computer. MTU seems now to be consistently set to 4080 haven't seen other values.

@juribeparada

This comment has been minimized.

Copy link

juribeparada commented Mar 10, 2019

I can confirm that LimeSDR-USB works great (I also see a significant decrease of deactivate/activate time), but unfortunately this PR breaks LimeSDR-Mini when I try to change the sample rate. It looks like LimeSDR-Mini works OK only when changing sample rate while streaming(!), totally the opposite of LimeSDR-USB. The commit
ed59937 works OK for LimeSDR-Mini because it was specific for LimeSDR-USB. For example, if I change:
device->getHardwareKey() == "LimeSDR-Mini"
it also breaks LimeSDR-Mini support, the same behavior of this PR. Be aware I only tested on macOS Mojave.

@juribeparada

This comment has been minimized.

Copy link

juribeparada commented Mar 10, 2019

OK, now I tested this PR on Ubuntu 18 (run native in other PC), and it works great for LimeSDR-USB and LimeSDR-Mini, even solves the "limitation" of sample rate < 5 MSPS in LimeSDR-Mini.
It seems to me my problem in macOS is related to a known bug with LimeSDR-Mini: when the stream is closed properly, then LimeSDR-Mini will not work for a next re-opened stream, you need to unplug and plug the device. A very ugly bug that only affects macOS and LimeSDR-Mini, not sure if that bug has a solution currently. Also I tried an Ubuntu 18 VM in my Mac, and the problem persists, then seems a hardware related issue (LimeSDR-Mini uses FT601 USB interface, but LimeSDR-USB uses FX3 device).

@vsonnier

This comment has been minimized.

Copy link
Collaborator Author

vsonnier commented Mar 10, 2019

MTU seems now to be consistently set to 4080 haven't seen other values.

also...

It looks like LimeSDR-Mini works OK only when changing sample rate while streaming(!), totally the opposite of LimeSDR-USB.

Well looks like both devices have serious problems of changing samplerates, that somewhat got fixed by accident and broken the other way.
Funny thing, both statements above suggests some things are actually up to date (MTU) only once the streaming has actually started.
Ok let's try this then, which is actually closer to Cubic master:

  1. SoapySDR::Device::deactivateStream : be safe, make the device quiet before changes
  2. SoapySDR::Device::setSampleRate : User command, changing sample rate
  3. SoapySDR::Device::activateStream : back to business.
  4. Re-read SoapySDR::Device::getSampleRate and SoapySDR::Device::getStreamMTU : Re-do buffer setup on Cubic side.
@juribeparada

This comment has been minimized.

Copy link

juribeparada commented Mar 10, 2019

Now tested 3355111 on macOS and Linux, and I get the same results as before, all work great with high/low sample rates, except LimeSDR-Mini on macOS, due to the specific issue commented before (see https://discourse.myriadrf.org/t/limesdr-mini-macbook-pro-a1398-high-sierra-10-13-6-usb-hub-success/3326). I will try to find more information about the LimeSDR-Mini / macOS problem.

@vsonnier vsonnier force-pushed the vso_safer_sample_rate_changes branch from 3355111 to 485edba Mar 10, 2019

@Dantali0n

This comment has been minimized.

Copy link
Contributor

Dantali0n commented Mar 10, 2019

This works as well.

@juribeparada

This comment has been minimized.

Copy link

juribeparada commented Mar 11, 2019

Please look at myriadrf/LimeSuite#254
With a small modification in libusb, LimeSDR-Mini on macOS works great with this PR.

@vsonnier

This comment has been minimized.

Copy link
Collaborator Author

vsonnier commented Mar 11, 2019

Thanks @juribeparada for all your investigation on this problem !
I could commit this PR this master as it is, but I would like to have people try with other supported devices like Airspy, HackRF... to cover the most popular to see if the sample rate sequence change have not broken those devices.

@guruofquality, Charles ( @cjcliffe ) could you give it a try and report if you have such devices ? Thank you.

@vsonnier vsonnier force-pushed the vso_safer_sample_rate_changes branch from 485edba to aeaa9e8 Mar 11, 2019

@vsonnier vsonnier force-pushed the vso_safer_sample_rate_changes branch from aeaa9e8 to d7796f6 Mar 12, 2019

@cjcliffe

This comment has been minimized.

Copy link
Owner

cjcliffe commented Mar 15, 2019

@vsonnier code changes look solid; going to give it a go with AirSpy and HackRF here.

@cjcliffe

This comment has been minimized.

Copy link
Owner

cjcliffe commented Mar 15, 2019

@vsonnier all looks good here with SDRPlay RSP1A & RSP2, Airspy Mini and HackRF on Ubuntu 18.

@vsonnier

This comment has been minimized.

Copy link
Collaborator Author

vsonnier commented Mar 15, 2019

Thanks @cjcliffe and all for your feedback, I think we cover the most used devices now. Time to make these changes live !

@vsonnier vsonnier merged commit c27e1e6 into master Mar 15, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@vsonnier vsonnier deleted the vso_safer_sample_rate_changes branch Mar 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.