changeset 20851:6602a90a06ec

consistency fix: STREAM_CTRL_GET_TIME_LENGTH and STREAM_CTRL_GET_CURRENT_TIME now return time in (double) seconds
author nicodvb
date Sun, 12 Nov 2006 17:19:56 +0000
parents fa032dca75f8
children c0d75a7315bf
files libmpdemux/demux_mpg.c libmpdemux/demuxer.c stream/stream_dvd.c stream/stream_dvdnav.c
diffstat 4 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mpg.c	Sun Nov 12 16:44:54 2006 +0000
+++ b/libmpdemux/demux_mpg.c	Sun Nov 12 17:19:56 2006 +0000
@@ -802,15 +802,11 @@
 
 int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
     mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
-    int msec = 0;
 
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
-            msec = stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, arg);
-            if(msec != STREAM_UNSUPORTED) {
-              msec = *((unsigned int*)arg);
-              *((double *)arg)=(double)msec/1000.0f;
-              mp_msg(MSGT_DEMUXER,MSGL_DBG2,"\r\nDEMUX_MPG_CTRL, stream len: %d (%.3lf)\r\n", msec, *((double*)arg));
+            if(stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, arg) != STREAM_UNSUPORTED) {
+              mp_msg(MSGT_DEMUXER,MSGL_DBG2,"\r\nDEMUX_MPG_CTRL, (%.3lf)\r\n", *((double*)arg));
               return DEMUXER_CTRL_GUESS;
             }
             if (mpg_d && mpg_d->has_valid_timestamps) {
--- a/libmpdemux/demuxer.c	Sun Nov 12 16:44:54 2006 +0000
+++ b/libmpdemux/demuxer.c	Sun Nov 12 17:19:56 2006 +0000
@@ -881,7 +881,7 @@
     demux_stream_t *d_video=demuxer->video;
     sh_audio_t *sh_audio=d_audio->sh;
     sh_video_t *sh_video=d_video->sh;
-    unsigned int tmp = 0;
+    double tmp = 0;
     double pts;
 
 if(!demuxer->seekable){
@@ -916,13 +916,13 @@
     else {
       if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME, &tmp) == STREAM_UNSUPORTED)
         goto dmx_seek;
-      pts = (double)tmp / 1000.0f;
+      pts = tmp;
     }
 
     if(flags & 2) {  // percent seek
       if(stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, &tmp) == STREAM_UNSUPORTED)
         goto dmx_seek;
-      pts += (double)tmp / 1000.0f * rel_seek_secs;
+      pts += tmp * rel_seek_secs;
     } else
       pts += rel_seek_secs;
 
@@ -1032,10 +1032,10 @@
  */
 int demuxer_get_current_time(demuxer_t *demuxer){
     double get_time_ans = 0;
-    unsigned tm;
+    double tm;
     sh_video_t *sh_video = demuxer->video->sh;
     if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME,(void *)&tm)!=STREAM_UNSUPORTED) {
-        get_time_ans = (double) tm / 1000.0f;
+        get_time_ans = tm;
     } else if(sh_video) get_time_ans = sh_video->pts;
     return (int) get_time_ans;
 }
--- a/stream/stream_dvd.c	Sun Nov 12 16:44:54 2006 +0000
+++ b/stream/stream_dvd.c	Sun Nov 12 17:19:56 2006 +0000
@@ -633,7 +633,7 @@
     {
         case STREAM_CTRL_GET_TIME_LENGTH:
         {
-            *((unsigned int *)arg) = mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1);
+            *((double *)arg) = (double) mp_get_titleset_length(d->vts_file, d->tt_srpt, d->cur_title-1)/1000.0;
             return 1;
         }
         case STREAM_CTRL_GET_NUM_CHAPTERS:
@@ -663,8 +663,7 @@
             if(stream_cache_size > 0) return STREAM_UNSUPORTED;
             tm = dvd_get_current_time(stream, 0);
             if(tm != -1) {
-              tm *= 1000.0f;
-              *((unsigned int *)arg) = (unsigned int) tm;
+              *((double *)arg) = tm;
               return 1;
             }
             break;
--- a/stream/stream_dvdnav.c	Sun Nov 12 16:44:54 2006 +0000
+++ b/stream/stream_dvdnav.c	Sun Nov 12 17:19:56 2006 +0000
@@ -279,7 +279,7 @@
     {
       if(priv->duration)
       {
-        *((unsigned int *)arg) = priv->duration;
+        *((double *)arg) = (double)priv->duration / 1000.0;
         return 1;
       }
       break;