summaryrefslogtreecommitdiffstats
path: root/find_sub.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-10-06 04:28:59 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-10-06 04:48:00 +0300
commit7fd3eb0f74e7986e07556077ed654bad7869add8 (patch)
tree8d293145c0ef2bc31ca63f79dccb4e3b57294c82 /find_sub.c
parentef438b3a6b5bc714d521dd46d3ccb798ecd31eed (diff)
parentcbbc886820e981f488660708678f528e1d243121 (diff)
downloadmpv-7fd3eb0f74e7986e07556077ed654bad7869add8.tar.bz2
mpv-7fd3eb0f74e7986e07556077ed654bad7869add8.tar.xz
Merge svn changes up to r29752
As part of merging subtitle-in-terminal changes make update_subtitles() only clear existing subtitles if called with the reset argument, and not try to set new ones. Later calls should set the needed new subtitles, and this change avoids some problems with trying to set subtitles when mp_property_sub() in command.c gets called from initialization code before full initialization.
Diffstat (limited to 'find_sub.c')
-rw-r--r--find_sub.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/find_sub.c b/find_sub.c
index 07d91d7e55..dcd4c4cd77 100644
--- a/find_sub.c
+++ b/find_sub.c
@@ -12,6 +12,7 @@
#include "mp_msg.h"
#include "help_mp.h"
+#include "mpcommon.h"
static int current_sub=0;
@@ -52,8 +53,9 @@ void step_sub(sub_data *subd, float pts, int movement) {
sub_delay = subs[current_sub].start / (subd->sub_uses_time ? 100 : sub_fps) - pts;
}
-void find_sub(sub_data* subd,int key){
+void find_sub(struct MPContext *mpctx, sub_data* subd,int key){
subtitle *subs;
+ subtitle *new_sub = NULL;
int i,j;
if ( !subd || subd->sub_num == 0) return;
@@ -77,8 +79,8 @@ void find_sub(sub_data* subd,int key){
vo_osd_changed(OSDTYPE_SUBTITLE);
if(key<=0){
- vo_sub=NULL; // no sub here
- return;
+ // no sub here
+ goto update;
}
// printf("\r---- sub changed ----\n");
@@ -89,13 +91,12 @@ void find_sub(sub_data* subd,int key){
// no sub
nosub_range_start=subs[current_sub].end;
nosub_range_end=subs[current_sub+1].start;
- vo_sub=NULL;
- return;
+ goto update;
}
// next sub?
++current_sub;
- vo_sub=&subs[current_sub];
- if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
+ new_sub=&subs[current_sub];
+ if(key>=new_sub->start && key<=new_sub->end) goto update; // OK!
}
// printf("\r---- sub log search... ----\n");
@@ -106,22 +107,22 @@ void find_sub(sub_data* subd,int key){
// printf("Searching %d in %d..%d\n",key,subs[i].start,subs[j].end);
while(j>=i){
current_sub=(i+j+1)/2;
- vo_sub=&subs[current_sub];
- if(key<vo_sub->start) j=current_sub-1;
- else if(key>vo_sub->end) i=current_sub+1;
- else return; // found!
+ new_sub=&subs[current_sub];
+ if(key<new_sub->start) j=current_sub-1;
+ else if(key>new_sub->end) i=current_sub+1;
+ else goto update; // found!
}
-// if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
+// if(key>=new_sub->start && key<=new_sub->end) return; // OK!
// check where are we...
- if(key<vo_sub->start){
+ if(key<new_sub->start){
if(current_sub<=0){
// before the first sub
nosub_range_start=key-1; // tricky
- nosub_range_end=vo_sub->start;
-// printf("FIRST... key=%d end=%d \n",key,vo_sub->start);
- vo_sub=NULL;
- return;
+ nosub_range_end=new_sub->start;
+// printf("FIRST... key=%d end=%d \n",key,new_sub->start);
+ new_sub=NULL;
+ goto update;
}
--current_sub;
if(key>subs[current_sub].end && key<subs[current_sub+1].start){
@@ -129,31 +130,33 @@ void find_sub(sub_data* subd,int key){
nosub_range_start=subs[current_sub].end;
nosub_range_end=subs[current_sub+1].start;
// printf("No sub... 1 \n");
- vo_sub=NULL;
- return;
+ new_sub=NULL;
+ goto update;
}
printf("HEH???? ");
} else {
- if(key<=vo_sub->end) printf("JAJJ! "); else
+ if(key<=new_sub->end) printf("JAJJ! "); else
if(current_sub+1 >= subd->sub_num){
// at the end?
- nosub_range_start=vo_sub->end;
+ nosub_range_start=new_sub->end;
nosub_range_end=0x7FFFFFFF; // MAXINT
// printf("END!?\n");
- vo_sub=NULL;
- return;
+ new_sub=NULL;
+ goto update;
} else
if(key>subs[current_sub].end && key<subs[current_sub+1].start){
// no sub
nosub_range_start=subs[current_sub].end;
nosub_range_end=subs[current_sub+1].start;
// printf("No sub... 2 \n");
- vo_sub=NULL;
- return;
+ new_sub=NULL;
+ goto update;
}
}
- mp_msg(MSGT_FIXME,MSGL_FIXME,"SUB ERROR: %d ? %d --- %d [%d] \n",key,(int)vo_sub->start,(int)vo_sub->end,current_sub);
+ mp_msg(MSGT_FIXME,MSGL_FIXME,"SUB ERROR: %d ? %d --- %d [%d] \n",key,(int)new_sub->start,(int)new_sub->end,current_sub);
- vo_sub=NULL; // no sub here
+ new_sub=NULL; // no sub here
+update:
+ set_osd_subtitle(mpctx, new_sub);
}