Mercurial > hg > xmms-sid
comparison src/xmms-sid.c @ 606:59046d70c0ef
Fixed a thread race conds in xs_reinit() and xs_get_song_info()
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 31 Aug 2007 16:54:04 +0000 |
parents | 358b2770d32d |
children | d7389ea52113 |
comparison
equal
deleted
inserted
replaced
605:0675613af00c | 606:59046d70c0ef |
---|---|
143 xs_stop(); | 143 xs_stop(); |
144 } else { | 144 } else { |
145 XS_MUTEX_UNLOCK(xs_status); | 145 XS_MUTEX_UNLOCK(xs_status); |
146 } | 146 } |
147 | 147 |
148 XS_MUTEX_LOCK(xs_status); | |
149 XS_MUTEX_LOCK(xs_cfg); | |
150 | |
148 /* Initialize status and sanitize configuration */ | 151 /* Initialize status and sanitize configuration */ |
149 xs_memset(&xs_status, 0, sizeof(xs_status)); | 152 xs_memset(&xs_status, 0, sizeof(xs_status)); |
150 | 153 |
151 if (xs_cfg.audioFrequency < 8000) | 154 if (xs_cfg.audioFrequency < 8000) |
152 xs_cfg.audioFrequency = 8000; | 155 xs_cfg.audioFrequency = 8000; |
193 iPlayer++; | 196 iPlayer++; |
194 } | 197 } |
195 | 198 |
196 XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); | 199 XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); |
197 | 200 |
201 | |
198 /* Get settings back, in case the chosen emulator backend changed them */ | 202 /* Get settings back, in case the chosen emulator backend changed them */ |
199 xs_cfg.audioFrequency = xs_status.audioFrequency; | 203 xs_cfg.audioFrequency = xs_status.audioFrequency; |
200 xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; | 204 xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; |
201 xs_cfg.audioChannels = xs_status.audioChannels; | 205 xs_cfg.audioChannels = xs_status.audioChannels; |
202 xs_cfg.oversampleEnable = xs_status.oversampleEnable; | 206 xs_cfg.oversampleEnable = xs_status.oversampleEnable; |
203 | 207 |
208 XS_MUTEX_UNLOCK(xs_status); | |
209 XS_MUTEX_UNLOCK(xs_cfg); | |
210 | |
204 /* Initialize song-length database */ | 211 /* Initialize song-length database */ |
205 xs_songlen_close(); | 212 xs_songlen_close(); |
206 if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { | 213 if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { |
207 xs_error(_("Error initializing song-length database!\n")); | 214 xs_error(_("Error initializing song-length database!\n")); |
208 } | 215 } |
210 /* Initialize STIL database */ | 217 /* Initialize STIL database */ |
211 xs_stil_close(); | 218 xs_stil_close(); |
212 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { | 219 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { |
213 xs_error(_("Error initializing STIL database!\n")); | 220 xs_error(_("Error initializing STIL database!\n")); |
214 } | 221 } |
222 | |
215 } | 223 } |
216 | 224 |
217 | 225 |
218 /* | 226 /* |
219 * Initialize XMMS-SID | 227 * Initialize XMMS-SID |
938 * which uses xs_plugin_ip.set_info(); | 946 * which uses xs_plugin_ip.set_info(); |
939 */ | 947 */ |
940 void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) | 948 void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) |
941 { | 949 { |
942 t_xs_tuneinfo *pInfo; | 950 t_xs_tuneinfo *pInfo; |
951 | |
952 XS_MUTEX_LOCK(xs_status); | |
943 | 953 |
944 /* Get tune information from emulation engine */ | 954 /* Get tune information from emulation engine */ |
945 pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); | 955 pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); |
946 if (!pInfo) | 956 if (!pInfo) { |
957 XS_MUTEX_UNLOCK(xs_status); | |
947 return; | 958 return; |
959 } | |
948 | 960 |
949 /* Get sub-tune information, if available */ | 961 /* Get sub-tune information, if available */ |
950 if ((pInfo->startTune > 0) && (pInfo->startTune <= pInfo->nsubTunes)) { | 962 if ((pInfo->startTune > 0) && (pInfo->startTune <= pInfo->nsubTunes)) { |
951 gint tmpInt; | 963 gint tmpInt; |
952 | 964 |
959 (*songLength) = (tmpInt * 1000); | 971 (*songLength) = (tmpInt * 1000); |
960 } | 972 } |
961 | 973 |
962 /* Free tune information */ | 974 /* Free tune information */ |
963 xs_tuneinfo_free(pInfo); | 975 xs_tuneinfo_free(pInfo); |
976 XS_MUTEX_UNLOCK(xs_status); | |
964 } | 977 } |
965 | 978 |
966 | 979 |
967 /* Allocate a new tune information structure | 980 /* Allocate a new tune information structure |
968 */ | 981 */ |