Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH] refresh end_pos in stream_file.c




On 05/20/2014 01:03 PM, Reimar Döffinger wrote:
This came up before: It should not be necessary. The end_pos will be ignored/updated if we do not actually reach EOF at that point.

The OSD will show that you've reached EOF which is misleading if the file has grown since mplayer has started. I've been applying the attached patch for years to display the correct percentage of the remaining file but it only works for MPEG TS streams. There's probably a more general solution.


Index: demux_ts.c
===================================================================
--- demux_ts.c	(revision 29962)
+++ demux_ts.c	(working copy)
@@ -25,7 +25,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 
+
 #include "config.h"
 #include "mp_msg.h"
 #include "help_mp.h"
@@ -3343,6 +3345,15 @@
 
 	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;
+		}
+
 		case DEMUXER_CTRL_SWITCH_AUDIO:
 		case DEMUXER_CTRL_SWITCH_VIDEO:
 		{
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng