Calling rtlsdr_* while receiving in async mode

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Oliver Jowett oliver.jowett at gmail.com
Sun Feb 15 13:38:44 UTC 2015


What's the "right way" to call rtlsdr_* functions while receiving samples
via rtlsdr_read_async()?
e.g. to change frequency or gain mid-run.

You can't call them directly from the async callback as you're within a
libusb callback at that point and libusb will self-deadlock if you do
anything that needs a synchronous transfer. Plus even without the
self-deadlock you really don't want a recursive callback happening if
another bulk transfer turns up..

You can't call them from a separate thread because librtlsdr isn't
threadsafe.

The only way I've found that's reliable is to call rtlsdr_cancel_async()
from within the async callback, wait for rtlsdr_read_async() to return, do
your work, then call rtlsdr_read_async() again. This is ugly and can drop
samples. rtlsdr_read_async() is also a bit buggy in that sometimes it will
take up to a second after cancellation has completed before it returns (it
calls into libusb to handle more events even if all xfers have completed
cancellation, and then you've got to wait for that to time out..)

What's the right way to do this?

Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20150215/fbac8f47/attachment.htm>


More information about the osmocom-sdr mailing list