discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How to know that the last sample has arrived


From: Ruben Undheim
Subject: Re: [Discuss-gnuradio] How to know that the last sample has arrived
Date: Mon, 24 Apr 2017 18:57:33 +0200

So to give an update:

I found a way to do this now (without stream tags). It became a bit
complicated but it feels robust so far.

I have implemented a concatenation block which you can see here:
  
https://github.com/rubund/gnuradio/blob/feature/concatenation_block/gr-blocks/lib/concatenate_impl.cc

The trick is to call this in forecast:
  d_block_detail = this->detail().get()
  gr::thread::scoped_lock
guard(*d_block_detail->input(d_current_input)->mutex());
  ninput_items = d_block_detail->input(d_current_input)->items_available ();
  input_done = d_block_detail->input(d_current_input)->done();

If "input_done" is set, we know the upstream block is complete, and we
just have to make sure that all
"ninput_items" have been processed in general_work. When they have,
all input items from that
particular input have been processed.

Please let me know if you see any potential problems with this approach.

I have a made a pull request to the master branch with the implemented
concatenation block.

Cheers
Ruben


2017-03-31 12:06 GMT+02:00 Ruben Undheim <address@hidden>:
> Hi,
>
> Is there a good way to find out from inside general_work that the last
> sample has arrived? (such as from vector_source_X or file_source)
>
> If I consume (ninput_items[0] - 1) samples every time general_work is
> called, I will eventually get general_work called with ninput_items[0]
> == 1. Would this be a reliable way to do it? Or is there a more
> straightforward way which I cannot see?
>
> The goal is to have a block which reliably appends something specific
> after the last incoming sample. When I detect that the last sample has
> arrived, the following call to forecast will return 0, causing
> general_work to be called again even when ninput_items[0] == 0, and I
> then return -1 when all the appended samples have been produced. That
> seems to work fine, but I am unsure if there is a more straight
> forward way.
>
> Best regards
>
> Ruben



reply via email to

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