[haiku-development] Re: A true streaming equivalent of BDataIO

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 17 Aug 2010 09:52:18 +0200

Christopher Humphries <redeye4@xxxxxxxxx> wrote:
> However many plug-ins insist on seekable content by accepting only a
> BPositionIO.

Which is unfortunate, but it might be fixable for some add-ons, too.

> The closest solution to the streaming data construct is the
> BBufferIO, which allows the buffering of data, but AFAIK it's missing 
> the
> crucial freeing part: freeing already read data, and avoiding using 
> too much
> memory in the process.

You obviously misunderstand this class. It has a fixed buffer, and will 
only use that one; therefore it can only seek if the underlying class 
can seek, and it will not use much memory (only as much as you tell it 
to use).

> I tried writing my own subclass, where the readat function would 
> return an
> equivalent number of blocks from the disk, but I think the producer 
> should
> really be independent from the consumer in this kind of data 
> interface.

I don't understand what you mean here.

> Now, I think that a class inheriting BPositionIO that directly 
> implements
> the standard iostream class, with the general read and write 
> function, but
> with little or no actual seeking capacity, should do the job. However 
> I
> could be wrong...

The only way to make it work this way would be to have more than one 
connection unless you want to waste lots of memory. And seeking would 
be dead slow, too, as you would need to "ignore" the whole data stream. 
Assume you are streaming a 4 GB HD video over the network. Now, the 
reader checks some chunk at the end of the file -- do you really intend 
to stream the whole 4 GB over the network to allow this? And do you, 
beyond that, also intend to temporarily store the 4 GB on your local 
disk in order to provide seeking capability?

Well, it cannot work this way generally, only for small files it would 
be acceptable.

The only way to make it work reliable is to fix the readers. They should 
as much as possible try to use a BDataIO only, and do additional checks 
only if there is a BPositionIO.
In the end, there is not much point in trying to stream a format that 
is not made for streaming at all, so why should we support this?


Other related posts: