# HG changeset patch
# User Albert Lee <[EMAIL PROTECTED]>
# Date 1178752346 14400
# Node ID 89f1486b006f0023853f6d40d724045c3ecc3d6b
# Parent  9e82239118b8719b4e3d3860cf39993c4025f6b5
# Parent  9adb97680e39138cd3822c9aafaf19542e76e236
Merge.

diff -r 89f1486b006f0023853f6d40d724045c3ecc3d6b -r 
9e82239118b8719b4e3d3860cf39993c4025f6b5 ChangeLog
--- a/ChangeLog Wed May 09 19:12:26 2007 -0400
+++ b/ChangeLog Fri May 04 10:28:25 2007 -0400
@@ -72,8 +72,10 @@ 0.5.900:2007/??/??
          stream does not reflect the specified duration.
        * Use PNG versions of various icons if SVG support isn't present.
          [Bug 1708332]
-       * Fix the default audio visualisation setting (should always be goom).
-       * Fix parsing of negative times.
+       * Fixed the default audio visualisation setting (should always be goom).
+       * Fixed parsing of negative times.
+       * Improved the locking in the stream-opening thread. This makes it
+         easier to stop the stream while it's still being opened.
 
 0.5.11:        2007/02/01
        [dsalt]
diff -r 89f1486b006f0023853f6d40d724045c3ecc3d6b -r 
9e82239118b8719b4e3d3860cf39993c4025f6b5 src/player.c
--- a/src/player.c      Wed May 09 19:12:26 2007 -0400
+++ b/src/player.c      Fri May 04 10:28:25 2007 -0400
@@ -66,9 +66,14 @@ static __attribute__ ((noreturn)) void *
   xine_cfg_entry_t entry;
   char *hash, *mrl = NULL;
 
+  pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
+  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
   /*pthread_mutex_lock (&engine_lock);*/
   pthread_mutex_lock (&widgets_update_lock);
+  pthread_cleanup_push (pthread_mutex_unlock, &widgets_update_lock);
   gdk_threads_enter();
+  pthread_cleanup_push (gdk_threads_leave, NULL);
 
   gxineinfo_clear (infobars);
   gxineinfo_update_line (infobars, 0, "%s", _("opening..."));
@@ -134,11 +139,13 @@ static __attribute__ ((noreturn)) void *
     }
   }
 
-  gdk_threads_leave ();
-  if (!xine_open (stream, mrl ? : cur_mrl))
+  pthread_cleanup_pop (TRUE);
+  int ret = xine_open (stream, mrl ? : cur_mrl);
+  gdk_threads_enter ();
+  pthread_cleanup_push (gdk_threads_leave, NULL);
+  if (!ret)
   {
     int error;
-    gdk_threads_enter ();
     switch (error = xine_get_error (stream))
     {
     case XINE_ERROR_NO_INPUT_PLUGIN:
@@ -192,10 +199,9 @@ static __attribute__ ((noreturn)) void *
     goto done; /* will call gdk_threads_leave */
   }
 
-  gdk_threads_enter ();
   ui_set_status (playlist_showing_logo () ? UI_STOP : UI_PLAY);
   infobar_show_metadata (infobars);
-  gdk_threads_leave ();
+  pthread_cleanup_pop (TRUE);
 
   xine_play (stream, goto_pos, goto_time);
   gtk_video_set_end_time (gtv, end_time);
@@ -205,14 +211,15 @@ static __attribute__ ((noreturn)) void *
 
   /* correct for possible stream changes */
   gdk_threads_enter ();
+  pthread_cleanup_push (gdk_threads_leave, NULL);
   ui_set_status (playlist_showing_logo () ? UI_STOP : UI_PLAY);
   infobar_show_metadata (infobars);
   playlist_check_set_title ();
 
 done:
   free (mrl);
-  gdk_threads_leave ();
-  pthread_mutex_unlock (&widgets_update_lock);
+  pthread_cleanup_pop (TRUE);
+  pthread_cleanup_pop (TRUE);
   /*pthread_mutex_unlock (&engine_lock);*/
   pthread_exit (NULL);
 }
@@ -255,6 +262,12 @@ void player_wait (void)
 void player_wait (void)
 {
   pthread_join (play_thread, NULL);
+}
+
+void player_stop (void)
+{
+  pthread_cancel (play_thread);
+  xine_stop (stream);
 }
 
 static void set_mute (int mute)
@@ -500,7 +513,7 @@ static JSBool controls_stop (JSContext *
                             jsval *argv, jsval *rval)
 {
   se_log_fncall_checkinit ("stop");
-  xine_stop (stream);
+  player_stop ();
   playlist_logo (NULL);
   ui_set_control_adjustment (Control_SEEKER, 0);
   return JS_TRUE;
@@ -511,7 +524,7 @@ static JSBool controls_eject (JSContext 
 {
   se_log_fncall_checkinit ("eject");
   if (xine_get_status (stream) == XINE_STATUS_PLAY)
-    xine_stop (stream);
+    player_stop ();
   gdk_threads_leave (); /* need to do this to allow play_exec() to proceed */
   playlist_logo (cx); /* doesn't matter so long as it's not NULL */
   gdk_threads_enter ();
diff -r 89f1486b006f0023853f6d40d724045c3ecc3d6b -r 
9e82239118b8719b4e3d3860cf39993c4025f6b5 src/player.h
--- a/src/player.h      Wed May 09 19:12:26 2007 -0400
+++ b/src/player.h      Fri May 04 10:28:25 2007 -0400
@@ -29,6 +29,7 @@ void player_launch (const char *title, c
 void player_launch (const char *title, const char *mrl,
                    int pos, int pos_time, int duration);
 void player_wait (void);
+void player_stop (void);
 
 int player_live_stream (void);
 
diff -r 89f1486b006f0023853f6d40d724045c3ecc3d6b -r 
9e82239118b8719b4e3d3860cf39993c4025f6b5 src/script_engine.c
--- a/src/script_engine.c       Wed May 09 19:12:26 2007 -0400
+++ b/src/script_engine.c       Fri May 04 10:28:25 2007 -0400
@@ -47,6 +47,7 @@
 #include "log_window.h"
 #include "stream_info.h"
 #include "open_mrl.h"
+#include "player.h"
 #include "server.h"
 #include "wizards.h"
 #include "snapshot.h"
@@ -259,7 +260,7 @@ static JSBool controls_exit (JSContext *
 
   se_log_fncall_checkinit ("controls.exit");
 
-  xine_stop (stream);
+  player_stop ();
 
   if (gtk_main_level() < 1)
   {

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog

Reply via email to