discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] File seek - 1st attempt


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] File seek - 1st attempt
Date: Tue, 1 Feb 2005 09:52:39 -0800
User-agent: Mutt/1.5.6i

On Tue, Feb 01, 2005 at 11:26:56AM -0500, cswiger wrote:
> Since it's my itch to scratch, I made a (w)hack at it and
> got promising results. Using as an example gr_freq_xlating_fir_filter
> method set_center_freq, we add to

Looks good.  I'd offer these suggestions:

> gr_file_source.cc:
> 
> void
> gr_file_source::seek(long seek_point)
> {
>     fseek ((FILE *) d_fp, seek_point, SEEK_SET);
> }

bool
gr_file_source::seek(long seek_point, int whence)
{
  return fseek ((FILE *) d_fp, seek_point * d_sizeof_item, whence) == 0;
}

No reason to limit the user to SEEK_SET or SEEK_CUR, give them the
choice.  Multplying by d_sizeof_item turns the seek point into a
sample count.  This means if you know your sample rate, you can seek
to an absolute time.

Then in gr_file_source.i add this in front of GR_SWIG_BLOCK_MAGIC:


%constant int SEEK_SET = 0;     /* Seek from beginning of file. */
%constant int SEEK_CUR = 1;     /* Seek from current position.  */
%constant int SEEK_END = 2;     /* Seek from end of file.       */

These should then be visible as gr.SEEK_SET, etc.


Eric




reply via email to

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