예제 #1
0
static void frame_queue_drop_all(struct mpv_opengl_cb_context *ctx)
{
    int frames = ctx->queued_frames;
    frame_queue_clear(ctx);
    if (ctx->active && frames > 0)
        vo_increment_drop_count(ctx->active, frames);
}
예제 #2
0
static void frame_queue_drop(struct mpv_opengl_cb_context *ctx)
{
    struct mp_image *mpi = frame_queue_pop(ctx);
    if (mpi) {
        talloc_free(mpi);
        if (ctx->active)
            vo_increment_drop_count(ctx->active, 1);
    }
}
예제 #3
0
static void frame_queue_drop(struct mpv_opengl_cb_context *ctx)
{
    struct vo_frame *frame = frame_queue_pop(ctx);
    if (frame) {
        talloc_free(frame);
        if (ctx->active)
            vo_increment_drop_count(ctx->active, 1);
        pthread_cond_broadcast(&ctx->wakeup);
    }
}
예제 #4
0
파일: vo_opengl_cb.c 프로젝트: AddictXQ/mpv
static void flip_page(struct vo *vo)
{
    struct vo_priv *p = vo->priv;
    struct timespec ts = mp_rel_time_to_timespec(0.2);

    pthread_mutex_lock(&p->ctx->lock);

    // Wait until frame was rendered
    while (p->ctx->next_frame) {
        if (pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) {
            MP_VERBOSE(vo, "mpv_opengl_cb_draw() not being called or stuck.\n");
            goto done;
        }
    }

    // Unblock mpv_opengl_cb_draw().
    p->ctx->present_count += 1;
    pthread_cond_signal(&p->ctx->wakeup);

    if (p->ctx->redrawing)
        goto done; // do not block for redrawing

    // Wait until frame was presented
    while (p->ctx->expected_flip_count > p->ctx->flip_count) {
        // mpv_opengl_cb_report_flip() is declared as optional API.
        // Assume the user calls it consistently _if_ it's called at all.
        if (!p->ctx->flip_count)
            break;
        if (pthread_cond_timedwait(&p->ctx->wakeup, &p->ctx->lock, &ts)) {
            MP_VERBOSE(vo, "mpv_opengl_cb_report_flip() not being called.\n");
            goto done;
        }
    }

done:

    // Cleanup after the API user is not reacting, or is being unusually slow.
    if (p->ctx->next_frame) {
        talloc_free(p->ctx->next_frame);
        p->ctx->next_frame = NULL;
        p->ctx->present_count += 2;
        pthread_cond_signal(&p->ctx->wakeup);
        vo_increment_drop_count(vo, 1);
    }

    pthread_mutex_unlock(&p->ctx->lock);
}