changeset 532:bc548249464a

Audacious glue.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Feb 2007 22:03:01 +0000
parents 92b6496c73b5
children 9ca430524698
files src/xmms-sid.c src/xmms-sid.h src/xs_support.h
diffstat 3 files changed, 48 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmms-sid.c	Tue Feb 20 20:48:01 2007 +0000
+++ b/src/xmms-sid.c	Tue Feb 20 22:03:01 2007 +0000
@@ -90,7 +90,7 @@
  */
 t_xs_status xs_status;
 XS_MUTEX(xs_status);
-static pthread_t xs_decode_thread;
+static XS_THREAD_T xs_decode_thread;
 
 static GtkWidget *xs_subctrl = NULL;
 static GtkObject *xs_subctrl_adj = NULL;
@@ -558,7 +558,7 @@
 
 	/* Exit the playing thread */
 	XSDEBUG("exiting thread, bye.\n");
-	pthread_exit(NULL);
+	XS_THREAD_EXIT(NULL);
 }
 
 
@@ -593,7 +593,13 @@
 	xs_status.currSong = xs_status.tuneInfo->startTune;
 
 	/* Start the playing thread! */
-	if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) {
+#ifdef AUDACIOUS_PLUGIN
+	xs_decode_thread = g_thread_create((GThreadFunc) xs_playthread, NULL, TRUE, NULL);
+	if (xs_decode_thread == NULL)
+#else
+	if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0)
+#endif
+	{
 		xs_error(_("Couldn't create playing thread!\n"));
 		xs_tuneinfo_free(xs_status.tuneInfo);
 		xs_status.tuneInfo = NULL;
@@ -631,7 +637,7 @@
 		XSDEBUG("stopping...\n");
 		xs_status.isPlaying = FALSE;
 		XS_MUTEX_UNLOCK(xs_status);
-		pthread_join(xs_decode_thread, NULL);
+		XS_THREAD_JOIN(xs_decode_thread);
 	} else {
 		XS_MUTEX_UNLOCK(xs_status);
 	}
--- a/src/xmms-sid.h	Tue Feb 20 20:48:01 2007 +0000
+++ b/src/xmms-sid.h	Tue Feb 20 22:03:01 2007 +0000
@@ -53,8 +53,6 @@
 #endif
 
 
-#include <xmms/plugin.h>
-
 /*
  * Some constants and defines
  */
@@ -120,17 +118,31 @@
 /* Macros for mutexes and threads. These exist to be able to
  * easily change from pthreads to glib threads, etc, if necessary.
  */
-#define XS_MPP(M)	M ## _mutex
-#if XS_MUTEX_DEBUG
-#define XS_MUTEX(M)		pthread_mutex_t	XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int M ## _qq;
-#define XS_MUTEX_H(M)		extern pthread_mutex_t XS_MPP(M); extern int M ## _qq
-#define XS_MUTEX_LOCK(M)	{ M ## _qq = pthread_mutex_lock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_LOCK(" #M ") == %i\n", M ## _qq); }
-#define XS_MUTEX_UNLOCK(M)	{ M ## _qq = pthread_mutex_unlock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_UNLOCK(" #M ") == %i\n", M ## _qq); }
+#ifdef AUDACIOUS_PLUGIN
+#  define XS_THREAD_T		GThread *
+#  define XS_THREAD_EXIT(M)	g_thread_exit(M)
+#  define XS_THREAD_JOIN(M)	g_thread_join(M)
+#  define XS_MPP(M)		M ## _mutex
+#  define XS_MUTEX(M)		GStaticMutex	XS_MPP(M) = G_STATIC_MUTEX_INIT
+#  define XS_MUTEX_H(M)		extern GstaticMutex XS_MPP(M)
+#  define XS_MUTEX_LOCK(M)	g_static_mutex_lock(&XS_MPP(M))
+#  define XS_MUTEX_UNLOCK(M)	g_static_mutex_unlock(&XS_MPP(M))
 #else
-#define XS_MUTEX(M)		pthread_mutex_t	XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER
-#define XS_MUTEX_H(M)		extern pthread_mutex_t XS_MPP(M)
-#define XS_MUTEX_LOCK(M)	pthread_mutex_lock(&XS_MPP(M))
-#define XS_MUTEX_UNLOCK(M)	pthread_mutex_unlock(&XS_MPP(M))
+#  define XS_THREAD_T		pthread_t
+#  define XS_THREAD_EXIT(M)	pthread_exit(M)
+#  define XS_THREAD_JOIN(M)	pthread_join(M, NULL)
+#  define XS_MPP(M)		M ## _mutex
+#  if XS_MUTEX_DEBUG
+#    define XS_MUTEX(M)		pthread_mutex_t	XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int M ## _qq;
+#    define XS_MUTEX_H(M)		extern pthread_mutex_t XS_MPP(M); extern int M ## _qq
+#    define XS_MUTEX_LOCK(M)	{ M ## _qq = pthread_mutex_lock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_LOCK(" #M ") == %i\n", M ## _qq); }
+#    define XS_MUTEX_UNLOCK(M)	{ M ## _qq = pthread_mutex_unlock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_UNLOCK(" #M ") == %i\n", M ## _qq); }
+#  else
+#    define XS_MUTEX(M)		pthread_mutex_t	XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER
+#    define XS_MUTEX_H(M)		extern pthread_mutex_t XS_MPP(M)
+#    define XS_MUTEX_LOCK(M)	pthread_mutex_lock(&XS_MPP(M))
+#    define XS_MUTEX_UNLOCK(M)	pthread_mutex_unlock(&XS_MPP(M))
+#  endif
 #endif
 
 /* Shorthands for linked lists
@@ -200,11 +212,11 @@
 #ifndef DEBUG_NP
 void	XSDEBUG(const char *, ...);
 #else
-#ifdef DEBUG
-#define XSDEBUG(...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); }
-#else
-#define XSDEBUG(...) /* stub */
-#endif
+#  ifdef DEBUG
+#    define XSDEBUG(...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); }
+#  else
+#    define XSDEBUG(...) /* stub */
+#  endif
 #endif
 
 #ifdef __cplusplus
--- a/src/xs_support.h	Tue Feb 20 20:48:01 2007 +0000
+++ b/src/xs_support.h	Tue Feb 20 22:03:01 2007 +0000
@@ -12,6 +12,14 @@
 #include <glib.h>
 #include <stdio.h>
 
+#ifdef AUDACIOUS_PLUGIN
+#include <audacious/plugin.h>
+#include <audacious/output.h>
+#include <audacious/util.h>  
+#else
+#include <xmms/plugin.h>
+#endif
+
 #ifdef HAVE_ASSERT_H
 #include <assert.h>
 #else
@@ -30,15 +38,11 @@
 #include <memory.h>
 #endif
 
-#ifndef HAVE_FSEEKO
-#define fseeko fseek
-#define ftello ftell
-#endif
-
 
 /* VFS replacement functions
  */
 #ifdef __AUDACIOUS_NEWVFS__
+#include <audacious/vfs.h>
 #define t_xs_file VFSFile
 #define xs_fopen(a,b) vfs_fopen(a,b)
 #define xs_fclose(a) vfs_fclose(a)