Mercurial > audlegacy
changeset 304:d0e9693d2115 trunk
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
author | chainsaw |
---|---|
date | Sat, 17 Dec 2005 11:11:13 -0800 |
parents | 57d01c5bd39f |
children | edc22c4569ad |
files | Plugins/Input/sid/xmms-sid.c Plugins/Input/sid/xmms-sid.h Plugins/Input/sid/xs_config.c Plugins/Input/sid/xs_config.h Plugins/Input/sid/xs_fileinfo.c Plugins/Input/sid/xs_length.c Plugins/Input/sid/xs_stil.c |
diffstat | 7 files changed, 156 insertions(+), 217 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Input/sid/xmms-sid.c Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xmms-sid.c Sat Dec 17 11:11:13 2005 -0800 @@ -20,6 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "xmms-sid.h" #include "xs_support.h" @@ -85,12 +86,14 @@ * Global variables */ t_xs_status xs_status; -XS_MUTEX(xs_status); -static pthread_t xs_decode_thread; +extern GStaticMutex xs_status_mutex; +extern GStaticMutex xs_cfg_mutex; +GStaticMutex xs_subctrl_mutex = G_STATIC_MUTEX_INIT; + +static GThread *xs_decode_thread; static GtkWidget *xs_subctrl = NULL; static GtkObject *xs_subctrl_adj = NULL; -XS_MUTEX(xs_subctrl); void xs_subctrl_close(void); void xs_subctrl_update(void); @@ -130,12 +133,12 @@ gboolean isInitialized; /* Stop playing, if we are */ - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_stop(); } else { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); } /* Initialize status and sanitize configuration */ @@ -306,10 +309,10 @@ /* Initialize */ XSDEBUG("entering player thread\n"); - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); memcpy(&myStatus, &xs_status, sizeof(t_xs_status)); myTune = xs_status.tuneInfo; - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_memset(&playedTune, 0, sizeof(playedTune)); @@ -335,8 +338,8 @@ doPlay = TRUE; while (xs_status.isPlaying && doPlay) { /* Automatic sub-tune change logic */ - XS_MUTEX_LOCK(xs_cfg); - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_cfg_mutex); + g_static_mutex_lock(&xs_status_mutex); assert(xs_status.currSong >= 1); assert(xs_status.currSong <= XS_STIL_MAXENTRY); myStatus.isPlaying = TRUE; @@ -369,8 +372,8 @@ /* This is the end */ doPlay = FALSE; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_cfg_mutex); continue; /* This is ugly, but ... */ } } @@ -378,8 +381,8 @@ /* Tell that we are initializing, update sub-tune controls */ myStatus.currSong = xs_status.currSong; playedTune[myStatus.currSong] = TRUE; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_cfg_mutex); XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); @@ -408,9 +411,9 @@ XSERR("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); xs_status.isError = TRUE; - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); goto xs_err_exit; } @@ -444,9 +447,9 @@ if (xs_filter_rateconv(audioBuffer, oversampleBuffer, myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) { XSERR("Oversampling rate-conversion pass failed.\n"); - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); xs_status.isError = TRUE; - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); goto xs_err_exit; } } else @@ -513,13 +516,14 @@ * value "not playing" status and XMMS knows to move to * next entry in the playlist .. or whatever it wishes. */ - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); xs_status.isPlaying = FALSE; - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); /* Exit the playing thread */ XSDEBUG("exiting thread, bye.\n"); - pthread_exit(NULL); + g_thread_exit(NULL); + return(NULL); } @@ -554,7 +558,8 @@ xs_status.currSong = xs_status.tuneInfo->startTune; /* Start the playing thread! */ - if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) { + xs_decode_thread = g_thread_create((GThreadFunc)xs_playthread, NULL, TRUE, NULL); + if (xs_decode_thread == NULL) { XSERR("Couldn't start playing thread!\n"); xs_tuneinfo_free(xs_status.tuneInfo); xs_status.tuneInfo = NULL; @@ -587,15 +592,15 @@ xs_subctrl_close(); /* Lock xs_status and stop playing thread */ - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (xs_status.isPlaying) { /* Stop playing */ XSDEBUG("stopping...\n"); xs_status.isPlaying = FALSE; - XS_MUTEX_UNLOCK(xs_status); - pthread_join(xs_decode_thread, NULL); + g_static_mutex_unlock(&xs_status_mutex); + g_thread_join(xs_decode_thread); } else { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); } /* Status is now stopped, update the sub-tune @@ -615,9 +620,9 @@ */ void xs_pause(short pauseState) { - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); /* FIXME FIX ME todo: pause should disable sub-tune controls */ - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_subctrl_close(); xs_fileinfo_update(); @@ -632,8 +637,8 @@ { gint n; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_subctrl); + g_static_mutex_lock(&xs_status_mutex); + g_static_mutex_lock(&xs_subctrl_mutex); if (xs_status.tuneInfo && xs_status.isPlaying) { n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; @@ -641,21 +646,21 @@ xs_status.currSong = n; } - XS_MUTEX_UNLOCK(xs_subctrl); - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_subctrl_mutex); + g_static_mutex_unlock(&xs_status_mutex); } void xs_subctrl_prevsong(void) { - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (xs_status.tuneInfo && xs_status.isPlaying) { if (xs_status.currSong > 1) xs_status.currSong--; } - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_subctrl_update(); } @@ -663,14 +668,14 @@ void xs_subctrl_nextsong(void) { - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (xs_status.tuneInfo && xs_status.isPlaying) { if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) xs_status.currSong++; } - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_subctrl_update(); } @@ -680,8 +685,8 @@ { GtkAdjustment *tmpAdj; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_subctrl); + g_static_mutex_lock(&xs_status_mutex); + g_static_mutex_lock(&xs_subctrl_mutex); /* Check if control window exists, we are currently playing and have a tune */ if (xs_subctrl) { @@ -691,17 +696,17 @@ tmpAdj->value = xs_status.currSong; tmpAdj->lower = 1; tmpAdj->upper = xs_status.tuneInfo->nsubTunes; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_subctrl); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_subctrl_mutex); gtk_adjustment_value_changed(tmpAdj); } else { - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_subctrl); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_subctrl_mutex); xs_subctrl_close(); } } else { - XS_MUTEX_UNLOCK(xs_subctrl); - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_subctrl_mutex); + g_static_mutex_unlock(&xs_status_mutex); } xs_fileinfo_update(); @@ -710,14 +715,14 @@ void xs_subctrl_close(void) { - XS_MUTEX_LOCK(xs_subctrl); + g_static_mutex_lock(&xs_subctrl_mutex); if (xs_subctrl) { gtk_widget_destroy(xs_subctrl); xs_subctrl = NULL; } - XS_MUTEX_UNLOCK(xs_subctrl); + g_static_mutex_unlock(&xs_subctrl_mutex); } @@ -736,9 +741,9 @@ { GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next; - XS_MUTEX_LOCK(xs_subctrl); + g_static_mutex_lock(&xs_subctrl_mutex); if (!xs_status.tuneInfo || !xs_status.isPlaying || xs_subctrl || (xs_status.tuneInfo->nsubTunes <= 1)) { - XS_MUTEX_UNLOCK(xs_subctrl); + g_static_mutex_unlock(&xs_subctrl_mutex); return; } @@ -796,7 +801,7 @@ gtk_widget_show_all(xs_subctrl); - XS_MUTEX_UNLOCK(xs_subctrl); + g_static_mutex_unlock(&xs_subctrl_mutex); } @@ -812,9 +817,9 @@ void xs_seek(gint iTime) { /* Check status */ - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (!xs_status.tuneInfo || !xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); return; } @@ -843,7 +848,7 @@ #endif } - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); } @@ -857,21 +862,21 @@ gint xs_get_time(void) { /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_status_mutex); if (xs_status.isError) { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); return -2; } /* If there is no tune, return -1 */ if (!xs_status.tuneInfo) { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); return -1; } /* If tune has ended, return -1 */ if (!xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); return -1; } @@ -888,7 +893,7 @@ #endif } - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); /* Return output time reported by audio output plugin */ return xs_plugin_ip.output->output_time();
--- a/Plugins/Input/sid/xmms-sid.h Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xmms-sid.h Sat Dec 17 11:11:13 2005 -0800 @@ -34,7 +34,6 @@ #endif #include <glib.h> -#include <pthread.h> #ifdef __cplusplus extern "C" { @@ -56,12 +55,6 @@ */ #undef DEBUG_NP -/* Define to enable non-portable thread and mutex debugging code. - * You need to #define DEBUG also to make this useful. - * (Works probably with GNU/Linux pthreads implementation only) - */ -#undef XS_MUTEX_DEBUG - /* HardSID-support is not working and is untested, thus we disable it here. */ #undef HAVE_HARDSID_BUILDER @@ -98,29 +91,12 @@ #define XS_STIL_MAXENTRY (128) /* Max number of sub-songs in STIL/SLDB node */ -#define XS_CONFIG_IDENT "XMMS-SID" /* Configuration file identifier */ -#define XS_CONFIG_FILE "/.bmp/xmms-sid" /* Use this configfile if autocyrpe fails */ +#define XS_CONFIG_IDENT "sid" /* Configuration file identifier */ #define XS_MIN_OVERSAMPLE (2) /* Minimum oversampling factor */ #define XS_MAX_OVERSAMPLE (8) /* Maximum oversampling factor */ -/* 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); } -#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 - /* Shorthands for linked lists */ #define LPREV (pNode->pPrev) @@ -188,11 +164,7 @@ /* Global variables */ extern InputPlugin xs_plugin_ip; - extern t_xs_status xs_status; -XS_MUTEX_H(xs_status); - - /* Plugin function prototypes */
--- a/Plugins/Input/sid/xs_config.c Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xs_config.c Sat Dec 17 11:11:13 2005 -0800 @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "xs_config.h" -#include "libaudacious/configfile.h" +#include "libaudacious/configdb.h" #include <stdio.h> #include "xs_glade.h" #include "xs_interface.h" @@ -41,7 +41,7 @@ /* * Configuration specific stuff */ -XS_MUTEX(xs_cfg); +GStaticMutex xs_cfg_mutex = G_STATIC_MUTEX_INIT; struct t_xs_cfg xs_cfg; t_xs_cfg_item xs_cfgtable[] = { @@ -162,7 +162,7 @@ { /* Lock configuration mutex */ XSDEBUG("initializing configuration ...\n"); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); /* Initialize values with sensible defaults */ xs_cfg.audioBitsPerSample = XS_RES_16BIT; @@ -244,7 +244,7 @@ /* Unlock the configuration */ - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); } @@ -253,52 +253,36 @@ */ void xs_read_configuration(void) { -#ifdef HAVE_NODEFAULTCFG - gchar *cfgFilename; -#endif gchar *tmpStr; - ConfigFile *cfgFile; + ConfigDb *db; gint i; - /* Try to open the XMMS configuration file */ - XS_MUTEX_LOCK(xs_cfg); + /* Try to open the configuration database */ + g_static_mutex_lock(&xs_cfg_mutex); XSDEBUG("loading from config-file ...\n"); + db = bmp_cfg_db_open(); -#ifdef HAVE_NODEFAULTCFG - cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL); - cfgFile = xmms_cfg_open_file(cfgFilename); - g_free(cfgFilename); -#else - cfgFile = xmms_cfg_open_default_file(); -#endif - - if (cfgFile == NULL) { - XSDEBUG("could not open configuration file, trying to write defaults...\n"); - xs_write_configuration(); - return; - } - - /* Read the new settings from XMMS configuration file */ + /* Read the new settings from configuration database */ for (i = 0; i < xs_cfgtable_max; i++) { switch (xs_cfgtable[i].itemType) { case CTYPE_INT: - xmms_cfg_read_int(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_get_int(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, (gint *) xs_cfgtable[i].itemData); break; case CTYPE_BOOL: - xmms_cfg_read_boolean(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_get_bool(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, (gboolean *) xs_cfgtable[i].itemData); break; case CTYPE_FLOAT: - xmms_cfg_read_float(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_get_float(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, (gfloat *) xs_cfgtable[i].itemData); break; case CTYPE_STR: - if (xmms_cfg_read_string - (cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, (gchar **) & tmpStr)) { + if (bmp_cfg_db_get_string + (db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, (gchar **) & tmpStr)) { /* Read was successfull */ xs_pstrcpy((gchar **) xs_cfgtable[i].itemData, tmpStr); g_free(tmpStr); @@ -312,11 +296,9 @@ } } + bmp_cfg_db_close(db); - /* Free the config file */ - xmms_cfg_free(cfgFile); - - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); XSDEBUG("OK\n"); } @@ -327,46 +309,33 @@ */ gint xs_write_configuration(void) { -#ifdef HAVE_NODEFAULTCFG - gchar *cfgFilename; -#endif - ConfigFile *cfgFile; + ConfigDb *db; gint i; XSDEBUG("writing configuration ...\n"); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); + db = bmp_cfg_db_open(); - /* Try to open the XMMS configuration file */ -#ifdef HAVE_NODEFAULTCFG - cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL); - cfgFile = xmms_cfg_open_file(cfgFilename); -#else - cfgFile = xmms_cfg_open_default_file(); -#endif - - if (!cfgFile) - cfgFile = xmms_cfg_new(); - - /* Write the new settings to XMMS configuration file */ + /* Write the new settings to configuration database */ for (i = 0; i < xs_cfgtable_max; i++) { switch (xs_cfgtable[i].itemType) { case CTYPE_INT: - xmms_cfg_write_int(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_set_int(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, *(gint *) xs_cfgtable[i].itemData); break; case CTYPE_BOOL: - xmms_cfg_write_boolean(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_set_bool(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, *(gboolean *) xs_cfgtable[i].itemData); break; case CTYPE_FLOAT: - xmms_cfg_write_float(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_set_float(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, *(gfloat *) xs_cfgtable[i].itemData); break; case CTYPE_STR: - xmms_cfg_write_string(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, + bmp_cfg_db_set_string(db, XS_CONFIG_IDENT, xs_cfgtable[i].itemName, *(gchar **) xs_cfgtable[i].itemData); break; @@ -377,18 +346,9 @@ } } - /* Flush the file */ -#ifdef HAVE_NODEFAULTCFG - xmms_cfg_write_file(cfgFile, cfgFilename); - g_free(cfgFilename); -#else - xmms_cfg_write_default_file(cfgFile); -#endif + bmp_cfg_db_close(db); - /* Free the memory areas */ - xmms_cfg_free(cfgFile); - - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); return 0; } @@ -510,9 +470,9 @@ } xs_sldb_fileselector = create_xs_sldbfileselector(); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_sldb_fileselector), xs_cfg.songlenDBPath); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); gtk_widget_show(xs_sldb_fileselector); } @@ -551,9 +511,9 @@ } xs_stil_fileselector = create_xs_stilfileselector(); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_stil_fileselector), xs_cfg.stilDBPath); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); gtk_widget_show(xs_stil_fileselector); } @@ -592,9 +552,9 @@ } xs_hvsc_pathselector = create_xs_hvscpathselector(); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_hvsc_pathselector), xs_cfg.hvscPath); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); gtk_widget_show(xs_hvsc_pathselector); } @@ -821,7 +781,7 @@ xs_configwin = create_xs_configwin(); /* Get lock on configuration */ - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); /* Based on available optional parts, gray out options */ #ifndef HAVE_SIDPLAY1 @@ -916,7 +876,7 @@ } /* Release the configuration */ - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); /* Show the widget */ gtk_widget_show(xs_configwin);
--- a/Plugins/Input/sid/xs_config.h Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xs_config.h Sat Dec 17 11:11:13 2005 -0800 @@ -115,8 +115,6 @@ gint subAutoMinTime; } xs_cfg; -XS_MUTEX_H(xs_cfg); - /* * Configuration-file */
--- a/Plugins/Input/sid/xs_fileinfo.c Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xs_fileinfo.c Sat Dec 17 11:11:13 2005 -0800 @@ -32,7 +32,9 @@ static GtkWidget *xs_fileinfowin = NULL; static t_xs_stil_node *xs_fileinfostil = NULL; -XS_MUTEX(xs_fileinfowin); +GStaticMutex xs_fileinfowin_mutex = G_STATIC_MUTEX_INIT; +GStaticMutex xs_status_mutex = G_STATIC_MUTEX_INIT; +extern t_xs_status xs_status; #define LUW(x) lookup_widget(xs_fileinfowin, x) @@ -42,8 +44,8 @@ gboolean isEnabled; GtkAdjustment *tmpAdj; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); + g_static_mutex_lock(&xs_status_mutex); + g_static_mutex_lock(&xs_fileinfowin_mutex); /* Check if control window exists, we are currently playing and have a tune */ if (xs_fileinfowin) { @@ -53,11 +55,11 @@ tmpAdj->value = xs_status.currSong; tmpAdj->lower = 1; tmpAdj->upper = xs_status.tuneInfo->nsubTunes; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_fileinfowin); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_fileinfowin_mutex); gtk_adjustment_value_changed(tmpAdj); - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); + g_static_mutex_lock(&xs_status_mutex); + g_static_mutex_lock(&xs_fileinfowin_mutex); isEnabled = TRUE; } else isEnabled = FALSE; @@ -68,8 +70,8 @@ gtk_widget_set_sensitive(LUW("fileinfo_subctrl_next"), isEnabled); } - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_fileinfowin); + g_static_mutex_unlock(&xs_status_mutex); + g_static_mutex_unlock(&xs_fileinfowin_mutex); } @@ -77,8 +79,8 @@ { gint n; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); + g_static_mutex_lock(&xs_status_mutex); + g_static_mutex_lock(&xs_fileinfowin_mutex); if (xs_status.tuneInfo && xs_status.isPlaying) { n = (gint) gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))->value; @@ -86,19 +88,19 @@ xs_status.currSong = n; } - XS_MUTEX_UNLOCK(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_fileinfowin_mutex); + g_static_mutex_unlock(&xs_status_mutex); } void xs_fileinfo_ok(void) { - XS_MUTEX_LOCK(xs_fileinfowin); + g_static_mutex_lock(&xs_fileinfowin_mutex); if (xs_fileinfowin) { gtk_widget_destroy(xs_fileinfowin); xs_fileinfowin = NULL; } - XS_MUTEX_UNLOCK(xs_fileinfowin); + g_static_mutex_unlock(&xs_fileinfowin_mutex); } @@ -170,14 +172,14 @@ */ /* Get new tune information */ - XS_MUTEX_LOCK(xs_fileinfowin); - XS_MUTEX_LOCK(xs_status); + g_static_mutex_lock(&xs_fileinfowin_mutex); + g_static_mutex_lock(&xs_status_mutex); if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) { - XS_MUTEX_UNLOCK(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_fileinfowin_mutex); + g_static_mutex_unlock(&xs_status_mutex); return; } - XS_MUTEX_UNLOCK(xs_status); + g_static_mutex_unlock(&xs_status_mutex); xs_fileinfostil = xs_stil_get(pcFilename); @@ -246,7 +248,7 @@ /* Show the window */ gtk_widget_show(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_fileinfowin); + g_static_mutex_unlock(&xs_fileinfowin_mutex); xs_fileinfo_update(); }
--- a/Plugins/Input/sid/xs_length.c Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xs_length.c Sat Dec 17 11:11:13 2005 -0800 @@ -528,18 +528,19 @@ * These should be moved out of this module some day ... */ static t_xs_sldb *xs_sldb_db = NULL; -XS_MUTEX(xs_sldb_db); +extern GStaticMutex xs_cfg_mutex; +GStaticMutex xs_sldb_db_mutex = G_STATIC_MUTEX_INIT; gint xs_songlen_init(void) { - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); if (!xs_cfg.songlenDBPath) { - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); return -1; } - XS_MUTEX_LOCK(xs_sldb_db); + g_static_mutex_lock(&xs_sldb_db_mutex); /* Check if already initialized */ if (xs_sldb_db) @@ -548,8 +549,8 @@ /* Allocate database */ xs_sldb_db = (t_xs_sldb *) g_malloc0(sizeof(t_xs_sldb)); if (!xs_sldb_db) { - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_sldb_db_mutex); return -2; } @@ -557,8 +558,8 @@ if (xs_sldb_read(xs_sldb_db, xs_cfg.songlenDBPath) != 0) { xs_sldb_free(xs_sldb_db); xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_sldb_db_mutex); return -3; } @@ -566,23 +567,23 @@ if (xs_sldb_index(xs_sldb_db) != 0) { xs_sldb_free(xs_sldb_db); xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_sldb_db_mutex); return -4; } - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_sldb_db_mutex); return 0; } void xs_songlen_close(void) { - XS_MUTEX_LOCK(xs_sldb_db); + g_static_mutex_lock(&xs_sldb_db_mutex); xs_sldb_free(xs_sldb_db); xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_sldb_db_mutex); } @@ -590,14 +591,14 @@ { t_xs_sldb_node *pResult; - XS_MUTEX_LOCK(xs_sldb_db); + g_static_mutex_lock(&xs_sldb_db_mutex); if (xs_cfg.songlenDBEnable && xs_sldb_db) pResult = xs_sldb_get(xs_sldb_db, pcFilename); else pResult = NULL; - XS_MUTEX_UNLOCK(xs_sldb_db); + g_static_mutex_unlock(&xs_sldb_db_mutex); return pResult; }
--- a/Plugins/Input/sid/xs_stil.c Sat Dec 17 08:42:26 2005 -0800 +++ b/Plugins/Input/sid/xs_stil.c Sat Dec 17 11:11:13 2005 -0800 @@ -368,18 +368,19 @@ * These should be moved out of this module some day ... */ static t_xs_stildb *xs_stildb_db = NULL; -XS_MUTEX(xs_stildb_db); +GStaticMutex xs_stildb_db_mutex = G_STATIC_MUTEX_INIT; +extern GStaticMutex xs_cfg_mutex; gint xs_stil_init(void) { - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_cfg_mutex); if (!xs_cfg.stilDBPath) { - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_cfg_mutex); return -1; } - XS_MUTEX_LOCK(xs_stildb_db); + g_static_mutex_lock(&xs_stildb_db_mutex); /* Check if already initialized */ if (xs_stildb_db) @@ -388,8 +389,8 @@ /* Allocate database */ xs_stildb_db = (t_xs_stildb *) g_malloc0(sizeof(t_xs_stildb)); if (!xs_stildb_db) { - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_stildb_db_mutex); return -2; } @@ -397,8 +398,8 @@ if (xs_stildb_read(xs_stildb_db, xs_cfg.stilDBPath) != 0) { xs_stildb_free(xs_stildb_db); xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_stildb_db_mutex); return -3; } @@ -406,23 +407,23 @@ if (xs_stildb_index(xs_stildb_db) != 0) { xs_stildb_free(xs_stildb_db); xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_stildb_db_mutex); return -4; } - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); + g_static_mutex_unlock(&xs_cfg_mutex); + g_static_mutex_unlock(&xs_stildb_db_mutex); return 0; } void xs_stil_close(void) { - XS_MUTEX_LOCK(xs_stildb_db); + g_static_mutex_lock(&xs_stildb_db_mutex); xs_stildb_free(xs_stildb_db); xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_stildb_db); + g_static_mutex_unlock(&xs_stildb_db_mutex); } @@ -431,8 +432,8 @@ t_xs_stil_node *pResult; gchar *tmpFilename; - XS_MUTEX_LOCK(xs_stildb_db); - XS_MUTEX_LOCK(xs_cfg); + g_static_mutex_lock(&xs_stildb_db_mutex); + g_static_mutex_lock(&xs_cfg_mutex); if (xs_cfg.stilDBEnable && xs_stildb_db) { if (xs_cfg.hvscPath) { @@ -454,8 +455,8 @@ } else pResult = NULL; - XS_MUTEX_UNLOCK(xs_stildb_db); - XS_MUTEX_UNLOCK(xs_cfg); + g_static_mutex_unlock(&xs_stildb_db_mutex); + g_static_mutex_unlock(&xs_cfg_mutex); return pResult; }