diff options
author | waker <wakeroid@gmail.com> | 2012-01-26 19:52:46 +0100 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-01-26 19:52:46 +0100 |
commit | 1deb0ab80baa6882ae97388c3a69135b33ec74d3 (patch) | |
tree | d3415ab87a3eae2cb77d4b9436f478b7a5ab5a21 | |
parent | 0e50936b25a6aeb3bb7c13614c48865d16f4fc79 (diff) |
attemp to fix fabort race condition in streamer
-rw-r--r-- | streamer.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -145,6 +145,7 @@ streamer_unlock (void) { static void streamer_abort_files (void) { trace ("\033[0;33mstreamer_abort_files\033[37;0m\n"); + mutex_lock (decodemutex); if (fileinfo && fileinfo->file) { deadbeef->fabort (fileinfo->file); } @@ -154,6 +155,7 @@ streamer_abort_files (void) { if (streamer_file) { deadbeef->fabort (streamer_file); } + mutex_unlock (decodemutex); } @@ -893,11 +895,15 @@ m3u_error: } if (dec) { trace ("\033[0;33minit decoder for %s (%s)\033[37;0m\n", pl_find_meta (it, ":URI"), decoder_id); + mutex_lock (decodemutex); new_fileinfo = dec->open (0); + mutex_unlock (decodemutex); if (new_fileinfo && dec->init (new_fileinfo, DB_PLAYITEM (it)) != 0) { - trace ("\033[0;31mfailed to init decoder\033[37;0m\n") + trace ("\033[0;31mfailed to init decoder\033[37;0m\n"); + mutex_lock (decodemutex); dec->free (new_fileinfo); new_fileinfo = NULL; + mutex_unlock (decodemutex); // goto error; } } @@ -1294,12 +1300,17 @@ streamer_thread (void *ctx) { pl_unlock (); if (dec) { fileinfo = dec->open (0); + mutex_unlock (decodemutex); if (fileinfo && dec->init (fileinfo, DB_PLAYITEM (streaming_track)) != 0) { + mutex_lock (decodemutex); dec->free (fileinfo); fileinfo = NULL; + mutex_unlock (decodemutex); } } - mutex_unlock (decodemutex); + else { + mutex_unlock (decodemutex); + } if (!dec || !fileinfo) { if (streaming_track) { |