changeset 306:e6dec620b1b3

Improved locking, still some unlocked parts left, but nothing dangerous.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 26 Dec 2004 14:59:01 +0000
parents 3cd7e6f91b8a
children b6481d876ec2
files src/xmms-sid.c
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmms-sid.c	Sun Dec 26 13:01:04 2004 +0000
+++ b/src/xmms-sid.c	Sun Dec 26 14:59:01 2004 +0000
@@ -344,13 +344,13 @@
  doPlay = TRUE;
  while (xs_status.isPlaying && doPlay)
  {
+ /* Automatic sub-tune change logic */
+ XS_MUTEX_LOCK(xs_cfg);
  XS_MUTEX_LOCK(xs_status);
  assert(xs_status.currSong >= 1);
  assert(xs_status.currSong <= XS_STIL_MAXENTRY);
  myStatus.isPlaying = TRUE;
- XS_MUTEX_UNLOCK(xs_status);
 
- /* Automatic sub-tune change logic */
  if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong))
  	{
  	/* Check if currently selected sub-tune has been played already */
@@ -372,7 +372,8 @@
  				if (!playedTune[i])
  					isFound = TRUE;
  				}
-
+			
+			/* currSong = i + 1 anyway, so we get it free here */
 			i++;
  			}
 
@@ -380,22 +381,22 @@
 			{
 			/* Set the new sub-tune */
 			XSDEBUG("found #%i\n", i);
-			XS_MUTEX_LOCK(xs_status);
 			xs_status.currSong = i;
-			XS_MUTEX_UNLOCK(xs_status);
 			} else
 			/* This is the end */
 			doPlay = FALSE;
 
+		XS_MUTEX_UNLOCK(xs_status);
+		XS_MUTEX_UNLOCK(xs_cfg);
 		continue; /* This is ugly, but ... */
  		}
  	}
 
  /* Tell that we are initializing, update sub-tune controls */ 
- XS_MUTEX_LOCK(xs_status);
  myStatus.currSong = xs_status.currSong;
+ playedTune[myStatus.currSong - 1] = TRUE;
  XS_MUTEX_UNLOCK(xs_status);
- playedTune[myStatus.currSong - 1] = TRUE;
+ XS_MUTEX_UNLOCK(xs_cfg);
 
  XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong);