From c4ef31142425708cd43d8d02709fc2536b889277 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Tue, 9 Oct 2001 03:06:24 +0000 Subject: finished with that old deadlock CVS patchset: 772 CVS date: 2001/10/09 03:06:24 --- src/xine-engine/xine.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index bd37285b3..1cbdfcf66 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.66 2001/10/07 17:08:23 guenter Exp $ + * $Id: xine.c,v 1.67 2001/10/09 03:06:24 miguelfreitas Exp $ * * top-level xine functions * @@ -31,6 +31,7 @@ #include #include #include +#include #include #if defined (__linux__) #include @@ -59,13 +60,36 @@ /* debugging purposes only */ uint32_t xine_debug; -void xine_notify_stream_finished (xine_t *this) { +void * xine_notify_stream_finished_thread (void * this_gen) { + xine_t *this = this_gen; xine_stop (this); if (this->stream_end_cb) this->stream_end_cb (this->status); + return NULL; +} + +void xine_notify_stream_finished (xine_t *this) { + pthread_t finished_thread; + int err; + + /* This thread will just execute xine_stop and (possibly) xine_play then die. + It might look useless but i need to detach this code from the current + thread to make sure that video_decoder and audio_decoder are running and + freeing buffers. Free buffers might be needed by the main thread during + a xine_play, for example. + + This is not a theorical situation: i was able to trigger it with simple + user actions (play,seek,etc). [MF] + */ + if ((err = pthread_create (&finished_thread, + NULL, xine_notify_stream_finished_thread, this)) != 0) { + fprintf (stderr, "xine_notify_stream_finished: can't create new thread (%s)\n", + strerror(err)); + exit (1); + } } void xine_stop (xine_t *this) { -- cgit v1.2.3