On Thu, Nov 01, 2001 at 05:00:39PM +0100, Rudolf Polzer wrote:
> Could you explain this function?
> 
>     /*** For audio streams: ***/
> 
>     /**
>      * Reads and decompresses variable number of frames into
>      * user-supplied buffer.
>      */
>     virtual HRESULT ReadFrames(void* buffer, uint_t bufsize, uint_t samples,
>                                uint_t& samples_read, uint_t& bytes_read) =0;
> 
> It looks like it has to be called like fread(). But it segfaults
> when bufsize or samples are too small!

you are supposed to suply large enough buffer for at least one sample
- you may read this size if you pass  NULL pointer to this call I think
- check source.


> BTW: avifile really needs more documentation. The mistake I done

I also think it needs more documentation - but we also need more
people who will do that :)

> in my previous code was that I changed the CImage * I got from
> GetFrame(). It's not documented that I may not do this - and the
> CImage * is not a const CImage * as it should be in this case.

Probably forgetten - I'll check this - I've tried to add
const to as many places as I could see - but some still may be hidden...

> 
> And the copying semantics of CImage is really brain-dead:
> 
> standard c++                    avifile
> CImage i = ...;                 CImage i = ...;
> CImage i2 = i;                  CImage i2 = &i;
> CImage *j = ...;                CImage *j = ...;
> CImage *j2 = new CImage (*j);   CImage *j2 = new CImage (j);
> 
> Why not add proper C++ copy constructors?

Well I've not created this :) - but it's somewhat more problematic
to store referencies and count the usage - so it is not
as brain-dead as it might look at the first sight.

You really do want to copy just pointer instead of the whole image for
99% case - you may use copy contructor when you need private
copy of image.  If we would be copying image with operator= 
then we would basicaly put the whole work of keeping reference counter
onto the user of library - so I think current solution isn't that bad -
but overloading operators is always somewhat problematic and probably
all programs should be converted later to use some clean&clear methods.

-- 
  .''`.  Which fundamental human right do you want to give up today?
 : :' :      Debian GNU/Linux maintainer - www.debian.{org,cz}
 `. `'  Zdenek Kabelac  kabi@{debian.org, users.sf.net, fi.muni.cz}
   `-         Resistance is futile. You all will be packaged

_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile

Reply via email to