changeset 29483:13e5a54aa671

Implement DEMUXER_CTRL_GET_TIME_LENGTH and DEMUXER_CTRL_GET_PERCENT_POS for rawaudio demuxer.
author reimar
date Sun, 16 Aug 2009 22:39:10 +0000
parents bb2eaf7331e5
children be1d733d84e8
files libmpdemux/demux_rawaudio.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rawaudio.c	Sun Aug 16 21:37:07 2009 +0000
+++ b/libmpdemux/demux_rawaudio.c	Sun Aug 16 22:39:10 2009 +0000
@@ -112,6 +112,23 @@
 //  printf("demux_rawaudio: streamtell=%d\n",(int)stream_tell(demuxer->stream));
 }
 
+static int demux_rawaudio_control(demuxer_t *demuxer,int cmd, void *arg)
+{
+  sh_audio_t *sh_audio = demuxer->audio->sh;
+  switch(cmd) {
+  case DEMUXER_CTRL_GET_TIME_LENGTH:
+    if (!sh_audio->i_bps) return DEMUXER_CTRL_DONTKNOW;
+    *(double *)arg = (double)(demuxer->movi_end - demuxer->movi_start) / sh_audio->i_bps;
+    return DEMUXER_CTRL_GUESS;
+
+  case DEMUXER_CTRL_GET_PERCENT_POS:
+    *(int *)arg = (stream_tell(demuxer->stream) - demuxer->movi_start) * 100 / (demuxer->movi_end - demuxer->movi_start);
+    return DEMUXER_CTRL_GUESS;
+  }
+  return DEMUXER_CTRL_NOTIMPL;
+}
+
+
 
 const demuxer_desc_t demuxer_desc_rawaudio = {
   "Raw audio demuxer",
@@ -126,5 +143,5 @@
   demux_rawaudio_open,
   NULL,
   demux_rawaudio_seek,
-  NULL
+  demux_rawaudio_control
 };