[MPlayer-dev-eng] Re: [PACTH] get_byte_pos slave command

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Apr 20 00:59:36 CEST 2006


Hi,
On Wed, Apr 19, 2006 at 11:58:59PM +0200, Alban Bedel wrote:
> So regarding your patch all it need is a few if(!arg) return NULL;

It's already there in the second line. None of the implemented functions
work when arg is NULL, so that seemed like the best place.

> Dunno if set make much sense, althought it could be a good way to
> test the error resistance of our demuxers i suppose :)

It works fine with MPEG2. Didn't test anything else.

> > Does all this property stuff really have to be in mplayer.c??
> 
> Probably not all. Some could be moved elsewhere, but where ? Some will
> have to stay i fear, making sh_video, sh_audio, etc globals sound really
> too bad to me.

right, that's what the problem was.

> > Not even a simple list of supported
> > properties?
> 
> Their is -list-properties ;)

Maybe slave.txt should at least mention that *g* (though a more thorough
description of the properties wouldn't be bad).

> > Shouldn't those property commands also be active in idle mode?
> 
> That's the plan, some could probably work in paused mode too.

Well, they should I think. For frontends I guess it is quite bad to get no
response at all...

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.930
diff -u -r1.930 mplayer.c
--- mplayer.c	17 Apr 2006 16:31:42 -0000	1.930
+++ mplayer.c	19 Apr 2006 22:57:59 -0000
@@ -1361,6 +1391,25 @@
     return m_property_string_ro(prop,action,arg,(char*)demuxer->desc->name);
 }
 
+static int mp_property_bytepos(m_option_t* prop,int action,void* arg) {
+  if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE;
+  if (!arg) return M_PROPERTY_ERROR;
+  switch (action) {
+    case M_PROPERTY_GET: {
+      off_t *val = (off_t *)arg;
+      *val = stream_tell(demuxer->stream);
+      return M_PROPERTY_OK;
+    }
+    case M_PROPERTY_SET: {
+      off_t *val = (off_t *)arg;
+      if (*val < 0) *val = 0;
+      stream_seek(demuxer->stream, *val);
+      return M_PROPERTY_OK;
+    }
+  }
+  return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
 static int mp_property_length(m_option_t* prop,int action,void* arg) {
     double len;
     
@@ -1962,6 +2011,8 @@
       0, 0, 0, NULL },
     { "length", mp_property_length, CONF_TYPE_DOUBLE,
       0, 0, 0, NULL },
+    { "bytepos", mp_property_bytepos, CONF_TYPE_POSITION,
+      M_OPT_MIN, 0, 0, NULL },
 
     // Audio
     { "volume", mp_property_volume, CONF_TYPE_FLOAT,


More information about the MPlayer-dev-eng mailing list