# HG changeset patch # User Matti Hamalainen # Date 1188579244 0 # Node ID 59046d70c0ef0f017371eb72dfa0efb224091cd2 # Parent 0675613af00ccb9e0e3ab21d30a5f4f95b0558b2 Fixed a thread race conds in xs_reinit() and xs_get_song_info() diff -r 0675613af00c -r 59046d70c0ef src/xmms-sid.c --- a/src/xmms-sid.c Fri Aug 31 16:52:05 2007 +0000 +++ b/src/xmms-sid.c Fri Aug 31 16:54:04 2007 +0000 @@ -145,6 +145,9 @@ XS_MUTEX_UNLOCK(xs_status); } + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_cfg); + /* Initialize status and sanitize configuration */ xs_memset(&xs_status, 0, sizeof(xs_status)); @@ -195,12 +198,16 @@ XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); + /* Get settings back, in case the chosen emulator backend changed them */ xs_cfg.audioFrequency = xs_status.audioFrequency; xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; xs_cfg.audioChannels = xs_status.audioChannels; xs_cfg.oversampleEnable = xs_status.oversampleEnable; + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_cfg); + /* Initialize song-length database */ xs_songlen_close(); if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { @@ -212,6 +219,7 @@ if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { xs_error(_("Error initializing STIL database!\n")); } + } @@ -940,11 +948,15 @@ void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) { t_xs_tuneinfo *pInfo; + + XS_MUTEX_LOCK(xs_status); /* Get tune information from emulation engine */ pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); - if (!pInfo) + if (!pInfo) { + XS_MUTEX_UNLOCK(xs_status); return; + } /* Get sub-tune information, if available */ if ((pInfo->startTune > 0) && (pInfo->startTune <= pInfo->nsubTunes)) { @@ -961,6 +973,7 @@ /* Free tune information */ xs_tuneinfo_free(pInfo); + XS_MUTEX_UNLOCK(xs_status); }