summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-04 15:43:12 +0200
committerwm4 <wm4@nowhere>2016-09-04 18:05:36 +0200
commit2619d8eff4e2c1cf54574acfbd0cd5895e362e45 (patch)
treed7ae05f444c26314464b72e890874ba08394ee44 /player
parentd889d1fbaa28abec6b71d2ee0d9b9f8e62c09c04 (diff)
downloadmpv-2619d8eff4e2c1cf54574acfbd0cd5895e362e45.tar.bz2
mpv-2619d8eff4e2c1cf54574acfbd0cd5895e362e45.tar.xz
client API: implement mpv_suspend/resume slightly differently
Why do these API calls even still exist? I don't know, and maybe they don't make any sense anymore. But whether they should be removed or not is not a decision I want to make now. I want to get rid of mp_dispatch_suspend/resume(), though. So implement the client APIs slightly differently.
Diffstat (limited to 'player')
-rw-r--r--player/client.c21
-rw-r--r--player/core.h1
-rw-r--r--player/playloop.c2
3 files changed, 18 insertions, 6 deletions
diff --git a/player/client.c b/player/client.c
index 81b94abd22..ac89d3a141 100644
--- a/player/client.c
+++ b/player/client.c
@@ -330,8 +330,11 @@ void mpv_suspend(mpv_handle *ctx)
}
pthread_mutex_unlock(&ctx->lock);
- if (do_suspend)
- mp_dispatch_suspend(ctx->mpctx->dispatch);
+ if (do_suspend) {
+ mp_dispatch_lock(ctx->mpctx->dispatch);
+ ctx->mpctx->suspend_count++;
+ mp_dispatch_unlock(ctx->mpctx->dispatch);
+ }
}
void mpv_resume(mpv_handle *ctx)
@@ -347,8 +350,11 @@ void mpv_resume(mpv_handle *ctx)
}
pthread_mutex_unlock(&ctx->lock);
- if (do_resume)
- mp_dispatch_resume(ctx->mpctx->dispatch);
+ if (do_resume) {
+ mp_dispatch_lock(ctx->mpctx->dispatch);
+ ctx->mpctx->suspend_count--;
+ mp_dispatch_unlock(ctx->mpctx->dispatch);
+ }
}
void mp_resume_all(mpv_handle *ctx)
@@ -358,8 +364,11 @@ void mp_resume_all(mpv_handle *ctx)
ctx->suspend_count = 0;
pthread_mutex_unlock(&ctx->lock);
- if (do_resume)
- mp_dispatch_resume(ctx->mpctx->dispatch);
+ if (do_resume) {
+ mp_dispatch_lock(ctx->mpctx->dispatch);
+ ctx->mpctx->suspend_count--;
+ mp_dispatch_unlock(ctx->mpctx->dispatch);
+ }
}
static void lock_core(mpv_handle *ctx)
diff --git a/player/core.h b/player/core.h
index 25eb8b71a8..bdf19a815a 100644
--- a/player/core.h
+++ b/player/core.h
@@ -224,6 +224,7 @@ enum playback_status {
typedef struct MPContext {
bool initialized;
bool autodetach;
+ int suspend_count;
struct mpv_global *global;
struct MPOpts *opts;
struct mp_log *log;
diff --git a/player/playloop.c b/player/playloop.c
index 079d3a952a..449813c777 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -70,6 +70,8 @@ void mp_process_input(struct MPContext *mpctx)
mp_cmd_free(cmd);
mp_dispatch_queue_process(mpctx->dispatch, 0);
}
+ while (mpctx->suspend_count)
+ mp_dispatch_queue_process(mpctx->dispatch, 100);
}
double get_relative_time(struct MPContext *mpctx)