0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02: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:
wm4 2014-09-25 21:23:33 +02:00
parent ed116e8b06
commit d8f993705c

View File

@ -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);
}
}
}