Coder Social home page Coder Social logo

Comments (7)

guruofquality avatar guruofquality commented on June 14, 2024

I think you are right. The setupStream spawns the handler threads for both endpoints. For transmit, this isnt an issue, the transmit thread will never actually call writeStream() until the client provides data. But for receive, the thread immediately starts calling readStream(), before active stream can be called by the client.

However, I think most of the implementations basically timeout in the read/writeStream() calls if activateStream() has not been called. activateStream() was supposed to be a comparatively lightweight call to enable streaming after setupStream() did all of the heavy lifting.

So SoapyRemote might be acting "rude" by calling readStream prematurely, but SoapySDRPlay might be doing way too much in activate. I'm still thinking about... Its not like I declared in the documentation ahead of time that this particular order of calls should be safe :-)

from soapyremote.

cjcliffe avatar cjcliffe commented on June 14, 2024

I think this is ok if I know I should return timeout in this case; I think that would solve the issue we're seeing. It's possible I have some things in the wrong place and I'll review/compare that as well.

from soapyremote.

guruofquality avatar guruofquality commented on June 14, 2024

Keep in mind the timeout implementation is going to actually have to wait or sleep or it will end up with a 100% cpu loop in the stream thread.

from soapyremote.

guruofquality avatar guruofquality commented on June 14, 2024

Thinking about this more, if we couldn’t guarantee that it was safe to call readStream() before activateStream(), then its not super clear when the readStream() thread should be allowed to run -- because the activate/deactivate calls can handle advanced stream control like timed bursts. Even though there is an obvious answer in this case for SoapySDRPlay.

Also, we would loose the ability to have the threads setup ahead of time to be ready to go when the stream is activated. Its along the same lines of "setup stream does the costly setup and heavy lifting", "activate stream is doing lightweight minimal work enable/control the stream". And FWIW, SoapyRemote may not be the only instance where the stream API gets used like this because of how the user sets up threads for example.

So I think its best if SoapySDRPlay was robust against being read even before activation happens. And for that matter, any others if this issue also comes up.

from soapyremote.

guruofquality avatar guruofquality commented on June 14, 2024

Hopefully this wasn't too much of a "cop-out" coming up with the readStream() timeout before activate, but I think its for the best.

from soapyremote.

cjcliffe avatar cjcliffe commented on June 14, 2024

Aye, seems to work ok here now; I don't have a problem with it just might want to document it somewhere.

from soapyremote.

guruofquality avatar guruofquality commented on June 14, 2024

Good idea. I added some comments about it: pothosware/SoapySDR@9e7e528

from soapyremote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.