Mercurial > hg > xmms-sid
changeset 228:a9a5924eb10c
Have and use a mutex for xs_cfg configuration structure.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 19 Dec 2004 16:54:04 +0000 |
parents | 92bad4c7b998 |
children | 7bb9e20e3092 |
files | src/xs_config.c src/xs_config.h |
diffstat | 2 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xs_config.c Sun Dec 19 16:53:05 2004 +0000 +++ b/src/xs_config.c Sun Dec 19 16:54:04 2004 +0000 @@ -40,6 +40,9 @@ /* * Configuration specific stuff */ +XS_MUTEX(xs_cfg); +struct t_xs_cfg xs_cfg; + t_xs_cfg_item xs_cfgtable[] = { {CTYPE_INT, &xs_cfg.audioBitsPerSample, "audioBitsPerSample"}, {CTYPE_INT, &xs_cfg.audioChannels, "audioChannels"}, @@ -81,7 +84,7 @@ {CTYPE_STR, &xs_cfg.titleFormat, "titleFormat"}, }; -const gint xs_cfgtable_max = (sizeof(xs_cfgtable) / sizeof(t_xs_cfg_item)); +static const gint xs_cfgtable_max = (sizeof(xs_cfgtable) / sizeof(t_xs_cfg_item)); t_xs_wid_item xs_widtable[] = { @@ -139,7 +142,7 @@ }; -const gint xs_widtable_max = (sizeof(xs_widtable) / sizeof(t_xs_wid_item)); +static const gint xs_widtable_max = (sizeof(xs_widtable) / sizeof(t_xs_wid_item)); /* @@ -148,9 +151,13 @@ void xs_reset_filters(void) { /* Reset filter values (copied from libsidplay1's headers) */ + XS_MUTEX_LOCK(xs_cfg); + xs_cfg.filterFs = 400.0f; xs_cfg.filterFm = 60.0f; xs_cfg.filterFt = 0.05f; + + XS_MUTEX_UNLOCK(xs_cfg); } @@ -164,6 +171,7 @@ gint i; XSDEBUG("initializing configuration ...\n"); + XS_MUTEX_LOCK(xs_cfg); /* Pre-initialize configuration structure */ xs_cfg.audioBitsPerSample = XS_RES_16BIT; @@ -287,6 +295,7 @@ /* Free the config file */ xmms_cfg_free(cfgFile); + XS_MUTEX_UNLOCK(xs_cfg); XSDEBUG("OK\n"); } @@ -302,6 +311,7 @@ gint i; XSDEBUG("writing configuration ...\n"); + XS_MUTEX_LOCK(xs_cfg); /* * Try to open the XMMS configuration file @@ -316,7 +326,6 @@ if (!cfgFile) cfgFile = xmms_cfg_new(); - /* Write the new settings to XMMS configuration file */ for (i = 0; i < xs_cfgtable_max; i++) { @@ -354,6 +363,8 @@ /* Free the memory areas */ xmms_cfg_free(cfgFile); + XS_MUTEX_UNLOCK(xs_cfg); + return 0; } @@ -452,11 +463,15 @@ */ void xs_cfg_filter_reset(void) { + XS_MUTEX_LOCK(xs_cfg); + xs_reset_filters(); gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_emu_filt_fs"))), xs_cfg.filterFs); gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_emu_filt_fm"))), xs_cfg.filterFm); gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_emu_filt_ft"))), xs_cfg.filterFt); + + XS_MUTEX_UNLOCK(xs_cfg); } @@ -737,6 +752,8 @@ /* Create the window */ xs_configwin = create_xs_configwin(); + /* Get lock on configuration */ + XS_MUTEX_LOCK(xs_cfg); /* Based on available optional parts, gray out options */ #ifndef HAVE_SIDPLAY1 @@ -832,7 +849,11 @@ break; } } - + + /* Release the configuration */ + XS_MUTEX_UNLOCK(xs_cfg); + + /* Show the widget */ gtk_widget_show(xs_configwin); }