summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-25 19:13:03 +0200
committerwm4 <wm4@nowhere>2014-04-25 19:13:03 +0200
commit93de4c81b98cd760530474b71f226729dfa89d31 (patch)
treecfbabfc19f3afe66c2c91c428545489865a8b238 /player/loadfile.c
parente0cf983e53afa6a524821265c7547c11f5c79551 (diff)
downloadmpv-93de4c81b98cd760530474b71f226729dfa89d31.tar.bz2
mpv-93de4c81b98cd760530474b71f226729dfa89d31.tar.xz
stream: make mp_input_check_interrupt thread-safe
The interrupt callback will can be called from another thread if the cache is enabled, and the stream disconnects. Then stream_reconnect() will call this function from within the cache thread. mp_input_check_interrupt() is not thread-safe due to read_events() not being thread-safe. It will call input callbacks added with mp_input_add_fd() - these callbacks lead to code not protected by locks, such as reading X11 events. Solve this by adding a stupid hack, which checks whether the calling thread is the main playback thread (i.e. calling the input callbacks will be safe). We can remove this hack later, but it requires at least moving the VO to its own thread first.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index b8dab59b66..d6ff75d668 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1488,6 +1488,7 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
// Return if all done.
void mp_play_files(struct MPContext *mpctx)
{
+ mp_input_set_main_thread(mpctx->input);
mpctx->quit_player_rc = EXIT_NONE;
for (;;) {
idle_loop(mpctx);