summaryrefslogtreecommitdiffstats
path: root/player/misc.c
diff options
context:
space:
mode:
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;
-}