changeset 3543:5a11cbf8791f

some small sub bug fix
author pontscho
date Mon, 17 Dec 2001 00:07:20 +0000
parents 465329581ad8
children 61b89c10e4e8
files find_sub.c mplayer.c subreader.c subreader.h
diffstat 4 files changed, 34 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/find_sub.c	Mon Dec 17 00:03:50 2001 +0000
+++ b/find_sub.c	Mon Dec 17 00:07:20 2001 +0000
@@ -25,6 +25,9 @@
 
 void find_sub(subtitle* subtitles,int key){
     int i,j;
+    
+    if ( !subtitles ) return;
+    
     if(vo_sub){
       if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
     } else {
--- a/mplayer.c	Mon Dec 17 00:03:50 2001 +0000
+++ b/mplayer.c	Mon Dec 17 00:07:20 2001 +0000
@@ -663,13 +663,17 @@
 	usleep(20000);
 	EventHandling();
       }
-      if(mplShMem->FilenameChanged){
-        filename=mplShMem->Filename;
-      }
+      
 #ifdef USE_SUB
-      sub_name=NULL;
-      if ( mplShMem->SubtitleChanged ) sub_name=mplShMem->Subtitlename;
+      if ( mplShMem->SubtitleChanged || !mplShMem->FilenameChanged )
+       { sub_name=mplShMem->Subtitlename; mplShMem->SubtitleChanged=0; }
 #endif
+
+      if ( mplShMem->FilenameChanged || !filename )
+       {
+        filename=mplShMem->Filename;
+	mplShMem->FilenameChanged=0;
+       }
     }
 #endif
 
@@ -2178,7 +2182,15 @@
 
   current_module="free_stream";
   if(stream) free_stream(stream);
-
+  
+  current_module="sub_free";
+  if ( subtitles ) 
+   {
+    sub_free( subtitles );
+    sub_name=NULL;
+    vo_sub=NULL;
+   }
+  
   video_out=NULL;
   audio_out=NULL;
 
--- a/subreader.c	Mon Dec 17 00:03:50 2001 +0000
+++ b/subreader.c	Mon Dec 17 00:07:20 2001 +0000
@@ -802,7 +802,18 @@
 	printf ("Subtitles dumped in \'dump.mpsub\'.\n");
 }
 
-
+void sub_free( subtitle * subs )
+{
+ int i;
+ 
+ if ( !subs ) return;
+ 
+ sub_num=0;
+ sub_errs=0;
+ for ( i=0;i<subs->lines;i++ ) free( subs->text[i] );
+ free( subs );
+ subs=NULL;
+}
 
 #ifdef DUMPSUBS
 int main(int argc, char **argv) {  // for testing
--- a/subreader.h	Mon Dec 17 00:03:50 2001 +0000
+++ b/subreader.h	Mon Dec 17 00:07:20 2001 +0000
@@ -37,5 +37,6 @@
 subtitle* sub_read_file (char *filename);
 char * sub_filename(char *path, char * fname );
 void list_sub_file(subtitle* subs);
+void sub_free( subtitle * subs );
 
 #endif