summaryrefslogtreecommitdiffstats
path: root/player/misc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-18 19:02:50 +0100
committerwm4 <wm4@nowhere>2017-01-18 19:02:50 +0100
commite277fadd60350caad1fc31e92a5076692e61dcc9 (patch)
tree715593fc3cb52fee1daffa7e4fe6712a8de97777 /player/misc.c
parentc54c3b6991ac0273e6b7a42dc42c5103f87ff9f1 (diff)
downloadmpv-e277fadd60350caad1fc31e92a5076692e61dcc9.tar.bz2
mpv-e277fadd60350caad1fc31e92a5076692e61dcc9.tar.xz
player: add prefetching of the next playlist entry
Since for mpv CLI, the player state is a singleton, full prefetching is a bit tricky. We do it only on the demuxer layer. The implementation reuses the old "open thread". This means there is significant potential for regressions even if the new option is not used. This is made worse by the fact that I barely tested this code. The generic mpctx_run_reentrant() wrapper is also removed - this was its only user, and its remains become part of the new implementation.
Diffstat (limited to 'player/misc.c')
-rw-r--r--player/misc.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/player/misc.c b/player/misc.c
index 032342e84a..2c160aef73 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -17,7 +17,6 @@
#include <stddef.h>
#include <stdbool.h>
-#include <pthread.h>
#include <assert.h>
#include "config.h"
@@ -251,51 +250,3 @@ void merge_playlist_files(struct playlist *pl)
playlist_add_file(pl, edl);
talloc_free(edl);
}
-
-struct wrapper_args {
- struct MPContext *mpctx;
- void (*thread_fn)(void *);
- void *thread_arg;
- pthread_mutex_t mutex;
- bool done;
-};
-
-static void *thread_wrapper(void *pctx)
-{
- struct wrapper_args *args = pctx;
- mpthread_set_name("opener");
- args->thread_fn(args->thread_arg);
- pthread_mutex_lock(&args->mutex);
- args->done = true;
- pthread_mutex_unlock(&args->mutex);
- mp_wakeup_core(args->mpctx); // this interrupts mp_idle()
- return NULL;
-}
-
-// Run the thread_fn in a new thread. Wait until the thread returns, but while
-// waiting, process input and input commands.
-int mpctx_run_reentrant(struct MPContext *mpctx, void (*thread_fn)(void *arg),
- void *thread_arg)
-{
- struct wrapper_args args = {mpctx, thread_fn, thread_arg};
- pthread_mutex_init(&args.mutex, NULL);
- bool success = false;
- pthread_t thread;
- if (pthread_create(&thread, NULL, thread_wrapper, &args))
- goto done;
- while (!success) {
- mp_idle(mpctx);
-
- if (mpctx->stop_play)
- mp_abort_playback_async(mpctx);
-
- pthread_mutex_lock(&args.mutex);
- success |= args.done;
- pthread_mutex_unlock(&args.mutex);
- }
- pthread_join(thread, NULL);
-done:
- pthread_mutex_destroy(&args.mutex);
- mp_wakeup_core(mpctx); // avoid lost wakeups during waiting
- return success ? 0 : -1;
-}