[MPlayer-dev-eng] [PATCH] libmpdemux/demux_ts.c: Add DEMUXER_CTRL_GET_PERCENT_POS command

Scott W. Larson scowl at wballphotos.com
Wed Nov 10 17:48:24 CET 2010


Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:
>On Mon, Nov 08, 2010 at 08:21:29PM -0800, Scott W. Larson wrote:
>>  	switch(cmd)
>>  	{
>> +		case DEMUXER_CTRL_GET_PERCENT_POS:
>> +		{
>> +			struct stat stream_stat;
>> +			fstat(demuxer->stream->fd, &stream_stat);
>> +			
>> +			*(int *)arg=(demuxer->filepos*100) / stream_stat.st_size;
>> +			return DEMUXER_CTRL_OK;
>> +		}
>
>Isn't there a generic fallback function for GET_PERCENT_POS
>that does something like this, and if so could/should that one
>be fixed or reused here?

The fallback behavior tests the size of the file once when mplayer starts, incorrectly assuming that the size of the file won't change. If it does change (i.e. a program is being timeshifted), mplayer will incorrectly display a progress bar of 100% when it reaches that point in the file.


More information about the MPlayer-dev-eng mailing list