[MPlayer-dev-eng] [PATCH] get_percent_pos support in demux_audio.c
ROSEN Jeremy
jeremy.rosen at c-s.fr
Wed Aug 20 11:55:50 CEST 2003
Hello people.
I use mplayer in slave mode to play audio files, and I had problems to
get the song length and position
After some inquiery in the mplayer source, I found that there was no
demux_audio_control function, and that demux_audio was, thus, unable to
report song length and song position
the attached patch will add that.
It is mainly copied from the equivalent code in demux_real, so it should
follow the mplayer coding convention.
feel free to apply/correct/flame/whatever
hope this helps
Jeremy
-------------- next part --------------
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.21
diff -u -r1.21 demux_audio.c
--- libmpdemux/demux_audio.c 4 Jun 2003 10:52:58 -0000 1.21
+++ libmpdemux/demux_audio.c 28 Jul 2003 21:17:41 -0000
@@ -363,3 +363,24 @@
free(priv);
}
+int demux_audio_control(demuxer_t *demuxer,int cmd, void *arg){
+ sh_audio_t *sh_audio=demuxer->audio->sh;
+ int audio_length = demuxer->movi_end / sh_audio->i_bps;
+ da_priv_t* priv = demuxer->priv;
+
+ switch(cmd) {
+ case DEMUXER_CTRL_GET_TIME_LENGTH:
+ if (audio_length<=0) return DEMUXER_CTRL_DONTKNOW;
+ *((unsigned long *)arg)=(unsigned long)audio_length;
+ return DEMUXER_CTRL_GUESS;
+
+ case DEMUXER_CTRL_GET_PERCENT_POS:
+ if (audio_length<=0)
+ return DEMUXER_CTRL_DONTKNOW;
+ *((int *)arg)=(int)( (priv->last_pts*100) / audio_length);
+ return DEMUXER_CTRL_OK;
+
+ default:
+ return DEMUXER_CTRL_NOTIMPL;
+ }
+}
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.149
diff -u -r1.149 demuxer.c
--- libmpdemux/demuxer.c 19 Jul 2003 17:39:47 -0000 1.149
+++ libmpdemux/demuxer.c 28 Jul 2003 21:17:45 -0000
@@ -1525,6 +1525,7 @@
extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg);
extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg);
extern int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg);
+extern int demux_audio_control(demuxer_t *demuxer, int cmd, void *arg);
int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
switch(demuxer->type) {
@@ -1540,6 +1541,8 @@
case DEMUXER_TYPE_AVI_NI:
case DEMUXER_TYPE_AVI_NINI:
return demux_avi_control(demuxer,cmd,arg);
+ case DEMUXER_TYPE_AUDIO:
+ return demux_audio_control(demuxer,cmd,arg);
#ifdef HAVE_XMMS
case DEMUXER_TYPE_XMMS:
return demux_xmms_control(demuxer,cmd,arg);
More information about the MPlayer-dev-eng
mailing list