]> git.sesse.net Git - vlc/commitdiff
* Fix the vobsub length.
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 21 Sep 2004 22:16:35 +0000 (22:16 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 21 Sep 2004 22:16:35 +0000 (22:16 +0000)
  fen: any suggestions for the other Control() stuff?

modules/demux/vobsub.c

index 2f458d7cdace681b3efe7c42d1d6de386c6de89d..3fc782788422ae00ea5563b2368a9f7c8a2b7ec3 100644 (file)
@@ -113,11 +113,13 @@ static int Open ( vlc_object_t *p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
-    int i_max;
+    int i_len;
+    char *psz_vobname;
 
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    p_sys->i_length = 0;
     p_sys->p_vobsub_file = NULL;
     p_sys->i_tracks = 0;
     p_sys->track = (vobsub_track_t*)malloc( sizeof( vobsub_track_t ) );
@@ -156,8 +158,22 @@ static int Open ( vlc_object_t *p_this )
     /* Unload */
     TextUnload( &p_sys->txt );
 
-    int i_len = strlen( p_demux->psz_path );
-    char *psz_vobname = strdup( p_demux->psz_path );
+    /* Find the total length of the vobsubs */
+    if( p_sys->i_tracks > 0 )
+    {
+        int i;
+        for( i = 0; i < p_sys->i_tracks )
+        {
+            if( p_sys->track[i]->i_subtitles > 1 )
+            {
+                if( p_sys->track[i]->p_subtitles[p_sys->track[i]->i_subtitles-1]->i_start > p_sys->i_length )
+                    p_sys->i_length = (mtime_t) p_sys->track[i]->p_subtitles[p_sys->track[i]->i_subtitles-1]->i_start + 1 * 1000 * 1000;
+            }
+        }
+    }
+
+    i_len = strlen( p_demux->psz_path );
+    psz_vobname = strdup( p_demux->psz_path );
 
     strcpy( psz_vobname + i_len - 4, ".sub" );
 
@@ -203,7 +219,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     {
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            //*pi64 = p_sys->i_length;
+            *pi64 = p_sys->i_length;
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME: