discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] how to implement synchronous source block correct


From: Martin Braun (CEL)
Subject: Re: [Discuss-gnuradio] how to implement synchronous source block correctly ?
Date: Tue, 3 Dec 2013 14:03:32 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Dec 03, 2013 at 03:59:34AM -0800, Artem Pisarenko wrote:
> Last few days I tried to implement RTP stream source block (based on
> sync_block) and found that this simple task is not trivial, as it seems to
> be, because GNU Radio scheduler and general data flow are not documented
> (for users).

There's an overview of the scheduler:
http://gnuradio.squarespace.com/blog/2013/9/15/explaining-the-gnu-radio-scheduler.html

"Users", as you say, usually don't need more than this to write GNU
Radio code, and most often don't need to know anything at all about it.

> What mecahisms are allowed to be used in order to achieve producing data
> synchronously and make possible to use block in any flow graph ?
> Blocking/sleeping inside work() function ? I wasted a lot of time to find
> out that my flow graph works crappy not because of my block. Create "signal
> source -> throttle -> complex to float -> audio sink" and you will hear
> jerky sound. Is it because of having more than one synchronous block in
> single flow chain ? If so, do I have to implement two versions of my block
> (sync and async) and user have to be responsible in selecting correct one ?
> Furthermore, there are no correct way to stop graph, instead work() function
> must never block for more than some finite interval of time. How to choose
> it - 10, 50, 100 ms ?.. Also note, that stop() method doesn't allow
> implementing any kind of interruption, it just called after graph finished
> already.
> 
> I consider these issues are fundamental.

A couple of things need clarifying:
- You never use a throttle and a hardware clock in one flow graph (e.g.
  throttle + audio)
- work() should never block. Sources are a bit of an exception, though,
  because blocking might be better than continuously producing no output
  if there's nothing to produce. In this case, it's your job to never
  produce underruns (what you called 'jerky sound'), and produce enough
  items often enough.
- I'm pretty sure you've misunderstood the concept of a "sync block".
  Refer to [1] for an introduction. It merely describes the ratio of
  input and output rates. The opposite of a sync block is *not* an
  'async' block.
- The scheduler does all the work for you regarding calling of work().
  You don't need to interrupt work(). Not sure what you're intentions
  were with using stop().

> Hope, at least, my remarks will help users who read encouraging "writing
> gnuradio blocks is simple !" at wiki and being stuck in practice.

Writing blocks is one of the things we try and document as good as
possible. The corresponding tutorial [1] has received a lot of feedback
and has been continuously updated. It also discusses most of the
questions you had earlier.

I also hope that nothing on gnuradio.org discourages people from using
GNU Radio and writing blocks.

Martin

[1] http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules

-- 
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

Attachment: pgpORqvVb9s6T.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]