summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-16 17:38:58 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-16 19:40:45 +0200
commit43c3a07f5812bfe32b1d65cced7f4d07213e1c72 (patch)
tree39802fb5ff9e0f3b849c333700dbc8d4b81797b8 /mplayer.c
parent6ead3e936b8344d13c56567142d95cff0d4d8c90 (diff)
downloadmpv-43c3a07f5812bfe32b1d65cced7f4d07213e1c72.tar.bz2
mpv-43c3a07f5812bfe32b1d65cced7f4d07213e1c72.tar.xz
subtitles: avoid running subreader.c parser when using libass
When loading external subtitle files, the code always tried parsing the file with subreader.c sub_read_file() first, even if libass was then used to parse and render the file (the results of the first parsing would be ignored in that case). This could cause problems like unnecessary error messages. Change the code to try libass parsing first if enabled, and skip subreader.c parsing if that succeeds.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/mplayer.c b/mplayer.c
index 2668bd07f0..90317dcbc1 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1049,39 +1049,42 @@ static int playtree_add_playlist(struct MPContext *mpctx, play_tree_t* entry)
void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr)
{
struct MPOpts *opts = &mpctx->opts;
- sub_data *subd;
-#ifdef CONFIG_ASS
- ASS_Track *asst = 0;
-#endif
+ sub_data *subd = NULL;
+ struct ass_track *asst = NULL;
if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES) {
return;
}
- subd = sub_read_file(filename, fps);
#ifdef CONFIG_ASS
- if (opts->ass_enabled)
+ if (opts->ass_enabled) {
#ifdef CONFIG_ICONV
asst = ass_read_file(ass_library, filename, sub_cp);
#else
asst = ass_read_file(ass_library, filename, 0);
#endif
- if (opts->ass_enabled && subd && !asst)
- asst = ass_read_subdata(ass_library, subd, fps);
-
- if (!asst && !subd)
-#else
- if(!subd)
+ if (!asst) {
+ subd = sub_read_file(filename, fps);
+ if (subd) {
+ asst = ass_read_subdata(ass_library, subd, fps);
+ if (asst) {
+ sub_free(subd);
+ subd = NULL;
+ }
+ }
+ }
+ } else
#endif
- mp_tmsg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR, "Cannot load subtitles: %s\n",
- filename_recode(filename));
+ subd = sub_read_file(filename, fps);
+
+
+ if (!asst && !subd) {
+ mp_tmsg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR,
+ "Cannot load subtitles: %s\n", filename_recode(filename));
+ return;
+ }
-#ifdef CONFIG_ASS
- if (!asst && !subd) return;
mpctx->set_of_ass_tracks[mpctx->set_of_sub_size] = asst;
-#else
- if (!subd) return;
-#endif
mpctx->set_of_subtitles[mpctx->set_of_sub_size] = subd;
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_ID=%d\n", mpctx->set_of_sub_size);
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n",