changeset 29484:be1d733d84e8

Add some protection to the rawaudio GET_LENGTH/GET_PERCENT_POS in case the file length is not known (streaming).
author reimar
date Sun, 16 Aug 2009 22:44:29 +0000
parents 13e5a54aa671
children d252912eaf5b
files libmpdemux/demux_rawaudio.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rawaudio.c	Sun Aug 16 22:39:10 2009 +0000
+++ b/libmpdemux/demux_rawaudio.c	Sun Aug 16 22:44:29 2009 +0000
@@ -117,11 +117,12 @@
   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;
+    if (!sh_audio->i_bps || demuxer->movi_start >= demuxer->movi_end) 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:
+    if (demuxer->movi_start >= demuxer->movi_end) return DEMUXER_CTRL_DONTKNOW;
     *(int *)arg = (stream_tell(demuxer->stream) - demuxer->movi_start) * 100 / (demuxer->movi_end - demuxer->movi_start);
     return DEMUXER_CTRL_GUESS;
   }