Update of /cvsroot/xine/xine-plugin/src
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21726
Modified Files:
plugin.c
Log Message:
Avoid canceling the player thread (it's a bit buggy with libxine).
Index: plugin.c
===================================================================
RCS file: /cvsroot/xine/xine-plugin/src/plugin.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- plugin.c 31 Oct 2006 09:50:15 -0000 1.38
+++ plugin.c 18 Nov 2006 16:40:20 -0000 1.39
@@ -94,6 +94,7 @@
pthread_mutex_t mutex;
pthread_t thread;
+ int playing;
} xine_plugin_t;
#define OSD_WIDTH 384
@@ -200,12 +201,12 @@
}
return "unknown error";
-}
+}
static void *player_thread (void *data) {
xine_plugin_t *this = data;
- while (this->track) {
+ while (this->track && this->playing) {
playlist_entry_t *track = this->track;
const char *error;
char buf[4096];
@@ -223,6 +224,11 @@
if (xine_open (this->stream, buf)) {
log ("... stream opened ...");
NPN_Status (this->instance, "xine-plugin: ... stream opened ...");
+
+ if (!this->playing) {
+ xine_close (this->stream);
+ return (void *) 0;
+ }
if (xine_play (this->stream, 0, 0 )) {
log ("... playback started.");
@@ -231,8 +237,6 @@
}
}
- pthread_testcancel ();
-
error = stream_error (this->stream);
log ("%s!", error);
snprintf (buf, sizeof(buf), "xine-plugin: %s!", error);
@@ -246,13 +250,11 @@
xine_usec_sleep (1000);
}
- while (1) {
+ while (this->playing) {
XEvent evt;
int got = 0;
int key;
- pthread_testcancel ();
-
pthread_mutex_lock (&this->mutex);
if (this->window) {
XLockDisplay (this->display);
@@ -263,10 +265,8 @@
}
pthread_mutex_unlock (&this->mutex);
- pthread_testcancel ();
-
if (!got) {
- xine_usec_sleep (20000);
+ xine_usec_sleep (5000);
continue;
}
@@ -459,20 +459,21 @@
break;
}
}
+
+ log ("stopping playback...");
+ xine_stop (this->stream);
+ log ("...playback stopped.");
+ log ("closing stream...");
+ xine_close (this->stream);
+ log ("...stream closed.");
return (void *) 0;
}
static void playback_stop (xine_plugin_t *this) {
if (this->thread) {
- log ("closing stream...");
- xine_stop (this->stream);
- xine_close (this->stream);
- log ("...stream closed.");
log ("stopping player...");
- pthread_mutex_lock (&this->mutex);
- pthread_cancel (this->thread);
- pthread_mutex_unlock (&this->mutex);
+ this->playing = 0;
pthread_join (this->thread, NULL);
this->thread = 0;
log ("...player stopped.");
@@ -481,8 +482,11 @@
static void playback_start (xine_plugin_t *this) {
log ("starting player...");
- if (pthread_create (&this->thread, NULL, player_thread, this))
+ this->playing = 1;
+ if (pthread_create (&this->thread, NULL, player_thread, this)) {
log ("pthread_create() failed!");
+ this->playing = 0;
+ }
}
/*****************************************************************************/
@@ -516,7 +520,7 @@
switch (event->type) {
case XINE_EVENT_UI_PLAYBACK_FINISHED:
- if (this->thread && this->track) {
+ if (this->playing && this->track) {
playlist_entry_t *next = this->track->next;
log ("playback finished.");
@@ -1046,7 +1050,7 @@
}
XCloseDisplay (this->display);
}
-
+
playlist_free (&this->list);
pthread_mutex_destroy (&this->mutex);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog