From d8f993705c8403c527990cce961073c91143d1e7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 25 Sep 2014 21:23:33 +0200 Subject: player: do not wrongly clear OSD bar stops, reindent set_osd_bar_chapters() always cleared the OSD bar stops, even if the current bar was not the seek bar. Obviously it should leave the state of the bar alone in this case. Also change the function control flow so that we can drop one indentation level, and do the equivalent change for the other OSD bar functions. --- player/osd.c | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'player/osd.c') diff --git a/player/osd.c b/player/osd.c index 8bada12bb7..f1495a21a9 100644 --- a/player/osd.c +++ b/player/osd.c @@ -293,22 +293,20 @@ void set_osd_bar(struct MPContext *mpctx, int type, double min, double max, double neutral, double val) { struct MPOpts *opts = mpctx->opts; - if (opts->osd_level < 1 || !opts->osd_bar_visible) + if (opts->osd_level < 1 || !opts->osd_bar_visible || !mpctx->video_out) return; - if (mpctx->video_out) { - mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0; - mpctx->sleeptime = 0; - mpctx->osd_progbar.type = type; - mpctx->osd_progbar.value = (val - min) / (max - min); - mpctx->osd_progbar.num_stops = 0; - if (neutral > min && neutral < max) { - float pos = (neutral - min) / (max - min); - MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops, - mpctx->osd_progbar.num_stops, pos); - } - osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); + mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0; + mpctx->sleeptime = 0; + mpctx->osd_progbar.type = type; + mpctx->osd_progbar.value = (val - min) / (max - min); + mpctx->osd_progbar.num_stops = 0; + if (neutral > min && neutral < max) { + float pos = (neutral - min) / (max - min); + MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops, + mpctx->osd_progbar.num_stops, pos); } + osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); } // Update a currently displayed bar of the same type, without resetting the @@ -316,29 +314,31 @@ void set_osd_bar(struct MPContext *mpctx, int type, static void update_osd_bar(struct MPContext *mpctx, int type, double min, double max, double val) { - if (mpctx->osd_progbar.type == type) { - float new_value = (val - min) / (max - min); - if (new_value != mpctx->osd_progbar.value) { - mpctx->osd_progbar.value = new_value; - osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); - } + if (mpctx->osd_progbar.type != type) + return; + + float new_value = (val - min) / (max - min); + if (new_value != mpctx->osd_progbar.value) { + mpctx->osd_progbar.value = new_value; + osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); } } static void set_osd_bar_chapters(struct MPContext *mpctx, int type) { + if (mpctx->osd_progbar.type != type) + return; + mpctx->osd_progbar.num_stops = 0; - if (mpctx->osd_progbar.type == type) { - double len = get_time_length(mpctx); - if (len > 0) { - int num = get_chapter_count(mpctx); - for (int n = 0; n < num; n++) { - double time = chapter_start_time(mpctx, n); - if (time >= 0) { - float pos = time / len; - MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops, - mpctx->osd_progbar.num_stops, pos); - } + double len = get_time_length(mpctx); + if (len > 0) { + int num = get_chapter_count(mpctx); + for (int n = 0; n < num; n++) { + double time = chapter_start_time(mpctx, n); + if (time >= 0) { + float pos = time / len; + MP_TARRAY_APPEND(mpctx, mpctx->osd_progbar.stops, + mpctx->osd_progbar.num_stops, pos); } } } -- cgit v1.2.3