mirror of
https://github.com/mpv-player/mpv
synced 2025-03-07 14:47:53 +00:00
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.
This commit is contained in:
parent
ed116e8b06
commit
d8f993705c
14
player/osd.c
14
player/osd.c
@ -293,10 +293,9 @@ 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;
|
||||
@ -308,7 +307,6 @@ void set_osd_bar(struct MPContext *mpctx, int type,
|
||||
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,19 +314,22 @@ 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) {
|
||||
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);
|
||||
@ -341,7 +342,6 @@ static void set_osd_bar_chapters(struct MPContext *mpctx, int type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user