[vlc-devel] Stream read algorithm (input/stream.c)

Laurent Aimar fenrir at via.ecp.fr
Sun Mar 8 15:03:43 CET 2009


On Mon, Feb 23, 2009, Sébastien Escudier wrote:
> There may be a problem in stream reading.
> I noticed that I had some delay when I was reading a network stream. Then I
> looked at stream reading in src/intput/stream.c and I noticed that VLC wasn't
> reading at the end of the stream cache. It was ok at the beginning, but it was
> shifting more and more.
> I think the problem is with these lines in AStreamReadStream:
> line 1104 in stream.c
> why is this needed ? :
> if( p_sys->stream.i_used < i_read - i_data )
>     p_sys->stream.i_used = __MIN( i_read - i_data, STREAM_READ_ATONCE * 10 );
> If we are in this case, AStreamRefillStream will read (i_read - i_data) instead
> of (i_copy = i_data).
> And we are in a loop :  while( i_data < i_read ), so it will read again
> i_data-i_read just after (because this is what is left to read).
> Finally we refilled (i_read - i_data)*2 but we really read less. Here is the
> shift in this cache.
> With these two lines I had like 30 secs of delay after several hours of network
> stream reading.
> When I commented these lines, no delay anymore.
 [4b6976c1c0ca48a74a04b83b45554cbb932638d7] should fix the issue.
Could you confirm it ?

 Thanks for the investigation :)



More information about the vlc-devel mailing list