[Live-devel] DeviceSource "not so clean" fix

Ross Finlayson finlayson at live.com
Tue May 25 14:19:22 PDT 2004


>Only one question: how come the following code exists in
>ByteStreamFileSource::doGetNextFrame()
>         if (fPreferredFrameSize > 0) && fPreferredFrameSize < fMaxSize){
>                 fMaxSize = fPreferredFrameSize;
>         }
>         fFrameSize = fread(fTo, 1, fMaxSize, fFid);

The above code is equivalent to:
         unsigned numBytesToRead = fMaxSize;
         if (fPreferredFrameSize > 0) && fPreferredFrameSize < 
numBytesToRead ){
                 numBytesToRead = fPreferredFrameSize;
         }
         fFrameSize = fread(fTo, 1, numBytesToRead, fFid);

but 1 line shorter.

>The above code sets the value of fMaxSize.

It's actually OK to change the value of "fMaxSize" (or "fTo"), *once you've 
already read it*.  Any changes that you make to these fields won't go back 
to the caller, though.


	Ross Finlayson
	LIVE.COM
	<http://www.live.com/>



More information about the live-devel mailing list