-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Change to async SDR acquire thread #1978
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
Conversation
Well as long as local playback (-r) is single threaded then this is fine. Any embedded platform we target has the required functionality. |
Yes, this is all with best compatibility in mind. But really I only know that SoapySDR and rtlsdr (via libusb) use threads, so we should be fine. To quickly summarize the overall architecture: The program will stay single threaded and unaware of threads, just the live inputs will deliver frames as events, replacing the blocking and abuse of the SDR callback to run a (actually very short) event loop. Rather silly, but that means we could service multiple SDR sources from one program instance ;) |
8c5a20a
to
6ed19f3
Compare
6ed19f3
to
d329e7d
Compare
d329e7d
to
90e27fe
Compare
I'd like to see this finished/merged (but have not read it yet). NetBSD doesn't have async usb read, which is a missing feature to be added, but it does have a streaming ugen read that I added back in 2006 for USRP, where the kernel reads another chunk ahead so that the user process doesn't block. Or rather, as soon as the thing you read is available, the kernel starts the next read and then returns, so that after you do whatever and call read again, there is no gap in read activity on the bus, so you can stream. With a thread doing the reading, it should be easy to use the read-ahead method instead. And yes, I know I should just implement USB async anyway. |
Broadly speaking this change just runs the acquire loop (to the RTL-SDR or SoapySDR lib) in a thread which uses The most visible benefit of this untangling would be the option to start/crash/restart/switch/stop the inputs at leisure. |
I don't follow no true concurrency; this lets the read thread and the process thread be indepdent. I get it that it does not allow paralllel reads or multiple CPUs for decoding. I agree that this decoupling is good; I see it as a bug that rtl_433 exists with a rtl dongle hiccup rather than retrying. I also think it woudl be easier to add in the NetBSD read method. I hope |
I should have said: no actual concurrency is desired or purposefully enabled with this. The acquire thread blocks until a buffer is available, then notifies the main thread (which is likely blocked in the event loop) with that data. We expect the processing to usually finish before the acquire thread gets unblocked with the next buffer, but that's not a hard limit anymore. But as a bonus we could run on smaller CPUs as long as accumulated processing keeps up with the incoming data (e.g. with frames "squelch"ed others can take longer to process). Currently every single frame needs to be faster than the acquire loop. But really I just wanted to say that this feature goes towards decoupling not a new execution logic model. As you noted decoupling is the value here. Yes, |
c3b421a
to
9c14fe1
Compare
I've now added the idea of restartable SDR devices to this, quick and dirty hack, but it just works. |
9c14fe1
to
099f684
Compare
099f684
to
2d3bd38
Compare
2d3bd38
to
83e4635
Compare
83e4635
to
6cd6553
Compare
6cd6553
to
c0bbe27
Compare
ccb555f
to
7435cd0
Compare
7435cd0
to
e44433e
Compare
Hi Christian, I encountered a failure with this commit.
|
This changes the SDR data acquisition to run in a thread.
The idea is: if using live inputs we already depend on threads (vie SoapySDR or libusb). Currently the main event loop "lives" in the SDR callback, this is awkward and the event loop can't run while gathering a frame (which is almost always).
The benefits include:
alarm()
signal with fine grained timersThoughts and comments much welcome!