video: don't assume query_format is thread-safe

Although it's probably safe for most VOs, there's no guarantee.
This commit is contained in:
wm4
2014-08-20 21:35:45 +02:00
parent 09897bed7f
commit 7758c15e95
4 changed files with 19 additions and 6 deletions

View File

@@ -771,7 +771,7 @@ void handle_force_window(struct MPContext *mpctx, bool reconfig)
// Pick whatever works
int config_format = 0;
for (int fmt = IMGFMT_START; fmt < IMGFMT_END; fmt++) {
if (vo->driver->query_format(vo, fmt)) {
if (vo_query_format(vo, fmt)) {
config_format = fmt;
break;
}

View File

@@ -91,10 +91,8 @@ void update_fps(struct MPContext *mpctx)
static void set_allowed_vo_formats(struct vf_chain *c, struct vo *vo)
{
for (int fmt = IMGFMT_START; fmt < IMGFMT_END; fmt++) {
c->allowed_output_formats[fmt - IMGFMT_START] =
vo->driver->query_format(vo, fmt);
}
for (int fmt = IMGFMT_START; fmt < IMGFMT_END; fmt++)
c->allowed_output_formats[fmt - IMGFMT_START] = vo_query_format(vo, fmt);
}
static int try_filter(struct MPContext *mpctx, struct mp_image_params params,
@@ -575,7 +573,6 @@ static int update_video(struct MPContext *mpctx, double endpts)
}
//bool vo_framedrop = !!mpctx->video_out->driver->flip_page_timed;
bool vo_framedrop = !!(mpctx->opts->frame_dropping & 1);
int min_frames = vo_framedrop ? 2 : 1; // framedrop needs duration

View File

@@ -748,6 +748,21 @@ bool vo_has_frame(struct vo *vo)
return vo->in->hasframe;
}
static void run_query_format(void *p)
{
void **pp = p;
struct vo *vo = pp[0];
*(int *)pp[2] = vo->driver->query_format(vo, *(int *)pp[1]);
}
int vo_query_format(struct vo *vo, int format)
{
int ret;
void *p[] = {vo, &format, &ret};
mp_dispatch_run(vo->in->dispatch, run_query_format, p);
return ret;
}
// Calculate the appropriate source and destination rectangle to
// get a correctly scaled picture, including pan-scan.
// out_src: visible part of the video

View File

@@ -288,6 +288,7 @@ void vo_seek_reset(struct vo *vo);
void vo_destroy(struct vo *vo);
void vo_set_paused(struct vo *vo, bool paused);
int64_t vo_get_drop_count(struct vo *vo);
int vo_query_format(struct vo *vo, int format);
void vo_set_flip_queue_offset(struct vo *vo, int64_t us);
int64_t vo_get_vsync_interval(struct vo *vo);