diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index 1597aa0..178dd92 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -98,6 +98,14 @@ void DSOUND_RecalcFormat(IDirectSoundBuf
 	dsb->writelead = (dsb->freq / 100) * dsb->pwfx->nBlockAlign;
 }
 
+/**
+ * Check for application callback requests for when the play position
+ * reaches certain points.
+ *
+ * The offsets that will be triggered will be those between the recorded
+ * "last played" position for the buffer (i.e. dsb->playpos) and "len" bytes
+ * beyond that position.
+ */
 void DSOUND_CheckEvent(IDirectSoundBufferImpl *dsb, int len)
 {
 	int			i;
@@ -163,6 +171,10 @@ static inline BYTE cvtS16toU8(INT16 s)
     return (s >> 8) ^ (unsigned char)0x80;
 }
 
+/**
+ * Copy a single frame from the given input buffer to the given output buffer.
+ * Translate 8 <-> 16 bits and mono <-> stereo
+ */
 static inline void cp_fields(const IDirectSoundBufferImpl *dsb, BYTE *ibuf, BYTE *obuf )
 {
 	DirectSoundDevice * device = dsb->device;
@@ -209,13 +221,32 @@ static inline void cp_fields(const IDire
         }
 }
 
-/* Now with PerfectPitch (tm) technology */
+/** 
+ * Mix at most the given amount of data into the given device buffer from the
+ * given secondary buffer, starting from the dsb's first currently unmixed
+ * frame (buf_mixpos), translating frequency (pitch), stereo/mono and
+ * bits-per-sample. The secondary buffer sample is looped if it is not
+ * long enough and it is a looping buffer.
+ * (Doesn't perform any mixing - this is a straight copy operation).
+ *
+ * Now with PerfectPitch (tm) technology
+ *
+ * dsb = the secondary buffer
+ * buf = the device buffer
+ * len = number of bytes to store in the device buffer
+ * 
+ * Returns: the number of bytes read from the secondary buffer
+ *   (ie. len, adjusted for frequency, number of channels and sample size,
+ *    and limited by buffer length for non-looping buffers)
+ */
 static INT DSOUND_MixerNorm(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
 {
 	INT	i, size, ipos, ilen;
 	BYTE	*ibp, *obp;
 	INT	iAdvance = dsb->pwfx->nBlockAlign;
 	INT	oAdvance = dsb->device->pwfx->nBlockAlign;
+	BOOL    wrap = (dsb->playflags & DSBPLAY_LOOPING) != 0;
+	int     nfiller;
 
 	ibp = dsb->buffer->memory + dsb->buf_mixpos;
 	obp = buf;
@@ -225,9 +256,9 @@ static INT DSOUND_MixerNorm(IDirectSound
 	if ((dsb->freq == dsb->device->pwfx->nSamplesPerSec) &&
 	    (dsb->pwfx->wBitsPerSample == dsb->device->pwfx->wBitsPerSample) &&
 	    (dsb->pwfx->nChannels == dsb->device->pwfx->nChannels)) {
-	        INT bytesleft = dsb->buflen - dsb->buf_mixpos;
+		INT bytesleft = dsb->buflen - dsb->buf_mixpos;
 		TRACE("(%p) Best case\n", dsb);
-	    	if (len <= bytesleft )
+		if (len <= bytesleft || ! wrap)
 			CopyMemory(obp, ibp, len);
 		else { /* wrap */
 			CopyMemory(obp, ibp, bytesleft);
@@ -246,8 +277,14 @@ static INT DSOUND_MixerNorm(IDirectSound
 			ibp += iAdvance;
 			ilen += iAdvance;
 			obp += oAdvance;
-			if (ibp >= (BYTE *)(dsb->buffer->memory + dsb->buflen))
-				ibp = dsb->buffer->memory;	/* wrap */
+
+			if (ibp >= (BYTE *)dsb->buffer->memory + dsb->buflen) {
+				if (wrap) {
+					ibp = dsb->buffer->memory;	/* wrap */
+				} else {
+					goto pad_remaining;
+				}
+			}
 		}
 		return (ilen);
 	}
@@ -273,10 +310,30 @@ static INT DSOUND_MixerNorm(IDirectSound
 		if (dsb->freqAcc >= (1<<DSOUND_FREQSHIFT)) {
 			ULONG adv = (dsb->freqAcc>>DSOUND_FREQSHIFT) * iAdvance;
 			dsb->freqAcc &= (1<<DSOUND_FREQSHIFT)-1;
-			ipos += adv; ilen += adv;
-			ipos %= dsb->buflen;
+			ipos += adv;
+			ilen += adv;
+			if (ipos >= dsb->buflen) {
+				if (wrap) {
+					ipos -= dsb->buflen;
+				} else {
+					break;
+				}
+			}
 		}
 	}
+	i *= oAdvance;
+		
+	pad_remaining:
+
+	/* Pad the remaining length, if any, with silence. We expect the
+	 * remaining length to be quite short. */
+	
+	/* the sound of silence */
+	nfiller = dsb->device->pwfx->wBitsPerSample == 8 ? 128 : 0;
+	for ( ; i < len; i++) {
+		*obp++ = nfiller;
+	}
+
 	return ilen;
 }
 
@@ -356,6 +413,10 @@ static void DSOUND_MixerVol(IDirectSound
 	}
 }
 
+/**
+ * Make sure the device's tmp_buffer is at least the given size. Return a
+ * pointer to it.
+ */
 static LPBYTE DSOUND_tmpbuffer(DirectSoundDevice *device, DWORD len)
 {
     TRACE("(%p,%d)\n", device, len);
@@ -372,6 +433,19 @@ static LPBYTE DSOUND_tmpbuffer(DirectSou
     return device->tmp_buffer;
 }
 
+/**
+ * Mix (at most) the given number of bytes into the given position of the
+ * device buffer, from the secondary buffer "dsb" (starting at the current
+ * mix position for that buffer).
+ *
+ * Returns the number of bytes actually mixed into the device buffer. This
+ * will match fraglen unless the end of the secondary buffer is reached
+ * (and it is not looping).
+ *
+ * dsb  = the secondary buffer to mix from
+ * writepos = position (offset) in device buffer to write at
+ * fraglen = number of bytes to mix
+ */
 static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD fraglen)
 {
 	INT	i, len, ilen, field, todo;
@@ -381,19 +455,37 @@ static DWORD DSOUND_MixInBuffer(IDirectS
 
 	len = fraglen;
 	if (!(dsb->playflags & DSBPLAY_LOOPING)) {
+		/* This buffer is not looping, so make sure the requested
+		 * length will not take us past the end of the buffer */
 		int secondary_remainder = dsb->buflen - dsb->buf_mixpos;
-		int adjusted_remainder = MulDiv(dsb->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec);
+		int blockalign;
+		int adjusted_remainder;
+		
+		if (secondary_remainder == 0)
+			return 0;
+		
+		blockalign = dsb->device->pwfx->nBlockAlign;
+		adjusted_remainder = MulDiv(dsb->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec);
+		adjusted_remainder -= adjusted_remainder % blockalign;
+
 		assert(adjusted_remainder >= 0);
+		if (adjusted_remainder == 0) {
+			/* The adjusted remainder must be at least one sample,
+			 * otherwise we will never reach the end of the
+			 * secondary buffer, as there will perpetually be a
+			 * fractional remainder */
+			 adjusted_remainder = blockalign;
+		}
+
 		TRACE("secondary_remainder = %d, adjusted_remainder = %d, len = %d\n", secondary_remainder, adjusted_remainder, len);
 		if (adjusted_remainder < len) {
 			TRACE("clipping len to remainder of secondary buffer\n");
 			len = adjusted_remainder;
 		}
-		if (len == 0)
-			return 0;
 	}
 
 	if (len % dsb->device->pwfx->nBlockAlign) {
+		/* This shouldn't ever happen anymore */
 		INT nBlockAlign = dsb->device->pwfx->nBlockAlign;
 		ERR("length not a multiple of block size, len = %d, block size = %d\n", len, nBlockAlign);
 		len = (len / nBlockAlign) * nBlockAlign;	/* data alignment */
@@ -404,12 +496,16 @@ static DWORD DSOUND_MixInBuffer(IDirectS
 
 	TRACE("MixInBuffer (%p) len = %d, dest = %d\n", dsb, len, writepos);
 
+	/* first, copy the data from the DirectSoundBuffer into the temporary
+	   buffer, translating frequency/bits-per-sample/number-of-channels
+	   to match the device settings */
 	ilen = DSOUND_MixerNorm(dsb, ibuf, len);
 	if ((dsb->dsbd.dwFlags & DSBCAPS_CTRLPAN) ||
 	    (dsb->dsbd.dwFlags & DSBCAPS_CTRLVOLUME) ||
 	    (dsb->dsbd.dwFlags & DSBCAPS_CTRL3D))
 		DSOUND_MixerVol(dsb, ibuf, len);
 
+	/* Now mix the temporary buffer into the devices main buffer */
 	if (dsb->device->pwfx->wBitsPerSample == 8) {
 		BYTE	*obuf = dsb->device->buffer + writepos;
 
@@ -667,30 +763,48 @@ void DSOUND_ForceRemix(IDirectSoundBuffe
 	LeaveCriticalSection(&dsb->lock);
 }
 
+/**
+ * Calculate the distance between two buffer offsets, taking wraparound
+ * into account.
+ */
+static inline DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2)
+{
+	if (ptr1 >= ptr2) {
+		return ptr1 - ptr2;
+	} else {
+		return buflen + ptr1 - ptr2;
+	}
+}
+
+/**
+ * Mix some frames from the given secondary buffer "dsb" into the device
+ * primary buffer.
+ *
+ * dsb = the secondary buffer
+ * playpos = the current play position in the device buffer (primary buffer)
+ * writepos = the current safe-to-write position in the device buffer
+ * mixlen = the maximum number of bytes in the primary buffer to mix, from the
+ *          current writepos.
+ *
+ * Returns: the number of bytes beyond the writepos that were mixed.
+ */
 static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD playpos, DWORD writepos, DWORD mixlen)
 {
+	/* The buffer's primary_mixpos may be before or after the the device
+	 * buffer's mixpos, but both must be ahead of writepos. */
+
 	DWORD len, slen;
 	/* determine this buffer's write position */
 	DWORD buf_writepos = DSOUND_CalcPlayPosition(dsb, writepos, writepos);
-	/* determine how much already-mixed data exists */
-	DWORD buf_done =
-		((dsb->buf_mixpos < buf_writepos) ? dsb->buflen : 0) +
-		dsb->buf_mixpos - buf_writepos;
-	DWORD primary_done =
-		((dsb->primary_mixpos < writepos) ? dsb->device->buflen : 0) +
-		dsb->primary_mixpos - writepos;
-	DWORD adv_done =
-		((dsb->device->mixpos < writepos) ? dsb->device->buflen : 0) +
-		dsb->device->mixpos - writepos;
-	DWORD played =
-		((buf_writepos < dsb->playpos) ? dsb->buflen : 0) +
-		buf_writepos - dsb->playpos;
+	/* the amount between the buffers current playpos and writepos
+	 * (ie between writepos value from last call and this call) */
+	DWORD played = DSOUND_BufPtrDiff(dsb->buflen, buf_writepos, dsb->playpos);
 	DWORD buf_left = dsb->buflen - buf_writepos;
-	int still_behind;
+	DWORD primary_done = DSOUND_BufPtrDiff(dsb->device->buflen, dsb->primary_mixpos, writepos);
 
 	TRACE("(%p,%d,%d,%d)\n",dsb,playpos,writepos,mixlen);
 	TRACE("buf_writepos=%d, primary_writepos=%d\n", buf_writepos, writepos);
-	TRACE("buf_done=%d, primary_done=%d\n", buf_done, primary_done);
+	TRACE("primary_done=%d\n", primary_done);
 	TRACE("buf_mixpos=%d, primary_mixpos=%d, mixlen=%d\n", dsb->buf_mixpos, dsb->primary_mixpos,
 	      mixlen);
 	TRACE("looping=%d, startpos=%d, leadin=%d\n", dsb->playflags, dsb->startpos, dsb->leadin);
@@ -704,18 +818,6 @@ static DWORD DSOUND_MixOne(IDirectSoundB
 	/* save write position for non-GETCURRENTPOSITION2... */
 	dsb->playpos = buf_writepos;
 
-	/* check whether CalcPlayPosition detected a mixing underrun */
-	if ((buf_done == 0) && (dsb->primary_mixpos != writepos)) {
-		/* it did, but did we have more to play? */
-		if ((dsb->playflags & DSBPLAY_LOOPING) ||
-		    (dsb->buf_mixpos < dsb->buflen)) {
-			/* yes, have to recover */
-			ERR("underrun on sound buffer %p\n", dsb);
-			TRACE("recovering from underrun: primary_mixpos=%d\n", writepos);
-		}
-		dsb->primary_mixpos = writepos;
-		primary_done = 0;
-	}
 	/* determine how far ahead we should mix */
 	if (((dsb->playflags & DSBPLAY_LOOPING) ||
 	     (dsb->leadin && (dsb->probably_valid_to != 0))) &&
@@ -760,40 +862,34 @@ static DWORD DSOUND_MixOne(IDirectSoundB
 	}
 	/* cut mixlen with what's already been mixed */
 	if (mixlen < primary_done) {
-		/* huh? and still CalcPlayPosition didn't
-		 * detect an underrun? */
-		FIXME("problem with underrun detection (mixlen=%d < primary_done=%d)\n", mixlen, primary_done);
 		return 0;
 	}
 	len = mixlen - primary_done;
 	TRACE("remaining mixlen=%d\n", len);
 
+	/* len is now the maximum amount we should mix from dsb's
+	 * primary_mixpos onwards */
 	if (len < dsb->device->fraglen) {
 		/* smaller than a fragment, wait until it gets larger
 		 * before we take the mixing overhead */
 		TRACE("mixlen not worth it, deferring mixing\n");
-		still_behind = 1;
+		len = 0;
 		goto post_mix;
 	}
 
 	/* ok, we know how much to mix, let's go */
-	still_behind = (adv_done > primary_done);
 	while (len) {
 		slen = dsb->device->buflen - dsb->primary_mixpos;
 		if (slen > len) slen = len;
 		slen = DSOUND_MixInBuffer(dsb, dsb->primary_mixpos, slen);
 
-		if ((dsb->primary_mixpos < dsb->device->mixpos) &&
-		    (dsb->primary_mixpos + slen >= dsb->device->mixpos))
-			still_behind = FALSE;
-
 		dsb->primary_mixpos += slen; len -= slen;
 		dsb->primary_mixpos %= dsb->device->buflen;
 
 		if ((dsb->state == STATE_STOPPED) || !slen) break;
 	}
 	TRACE("new primary_mixpos=%d, primary_advbase=%d\n", dsb->primary_mixpos, dsb->device->mixpos);
-	TRACE("mixed data len=%d, still_behind=%d\n", mixlen-len, still_behind);
+	TRACE("mixed data len=%d\n", mixlen-len);
 
 post_mix:
 	/* check if buffer should be considered complete */
@@ -810,11 +906,8 @@ post_mix:
 
 	/* return how far we think the primary buffer can
 	 * advance its underrun detector...*/
-	if (still_behind) return 0;
-	if ((mixlen - len) < primary_done) return 0;
-	slen = ((dsb->primary_mixpos < dsb->device->mixpos) ?
-		dsb->device->buflen : 0) + dsb->primary_mixpos -
-		dsb->device->mixpos;
+	slen = DSOUND_BufPtrDiff(dsb->device->buflen,
+		dsb->primary_mixpos, writepos);
 	if (slen > mixlen) {
 		/* the primary_done and still_behind checks above should have worked */
 		FIXME("problem with advancement calculation (advlen=%d > mixlen=%d)\n", slen, mixlen);
@@ -823,6 +916,19 @@ post_mix:
 	return slen;
 }
 
+/**
+ * For a DirectSoundDevice, go through all the currently playing buffers and
+ * mix them in to the device buffer.
+ *
+ * playpos = the current play position in the primary buffer
+ * writepos = the current safe-to-write position in the primary buffer
+ * mixlen = the maximum amount to mix into the primary buffer
+ *          (beyond the current writepos)
+ * recover = true if the sound device may have been reset and the write
+ *           position in the device buffer changed
+ *
+ * Returns:  the length beyond the writepos that was mixed to.
+ */
 static DWORD DSOUND_MixToPrimary(DirectSoundDevice *device, DWORD playpos, DWORD writepos, DWORD mixlen, BOOL recover)
 {
 	INT			i, len, maxlen = 0;
@@ -844,6 +950,8 @@ static DWORD DSOUND_MixToPrimary(DirectS
 					dsb->primary_mixpos = writepos;
 					dsb->cvolpan = dsb->volpan;
 					dsb->need_remix = FALSE;
+					if (dsb->state == STATE_STARTING)
+						dsb->state = STATE_PLAYING;
 				}
 				else if (dsb->need_remix) {
 					DSOUND_MixCancel(dsb, writepos, TRUE);
@@ -851,8 +959,6 @@ static DWORD DSOUND_MixToPrimary(DirectS
 					dsb->need_remix = FALSE;
 				}
 				len = DSOUND_MixOne(dsb, playpos, writepos, mixlen);
-				if (dsb->state == STATE_STARTING)
-					dsb->state = STATE_PLAYING;
 				maxlen = (len > maxlen) ? len : maxlen;
 			}
 			LeaveCriticalSection(&(dsb->lock));
@@ -940,12 +1046,17 @@ void DSOUND_WaveQueue(DirectSoundDevice 
 }
 
 /* #define SYNC_CALLBACK */
-
-static void DSOUND_PerformMix(DirectSoundDevice *device)
+/**
+ * Perform mixing for a Direct Sound device. That is, go through all the
+ * secondary buffers (the sound bites currently playing) and mix them in
+ * to the primary buffer (the device buffer).
+ */
+void DSOUND_PerformMix(DirectSoundDevice *device)
 {
 	int nfiller;
 	BOOL forced;
 	HRESULT hres;
+	BOOL underrun;
 
 	TRACE("(%p)\n", device);
 
@@ -958,31 +1069,36 @@ static void DSOUND_PerformMix(DirectSoun
 	if (device->priolevel != DSSCL_WRITEPRIMARY) {
 		BOOL paused = ((device->state == STATE_STOPPED) || (device->state == STATE_STARTING));
 		/* FIXME: document variables */
- 		DWORD playpos, writepos, inq, maxq, frag;
- 		if (device->hwbuf) {
+		DWORD playpos, writepos, inq, playleft, maxq, frag, playlead;
+		if (device->hwbuf) {
 			hres = IDsDriverBuffer_GetPosition(device->hwbuf, &playpos, &writepos);
 			if (hres) {
 			    WARN("IDsDriverBuffer_GetPosition failed\n");
 			    return;
 			}
+			playlead = DSOUND_BufPtrDiff(device->buflen, writepos, playpos);
+		} else {
+			playpos = device->pwplay * device->fraglen;
+			playlead = ds_hel_margin * device->fraglen;
 			/* Well, we *could* do Just-In-Time mixing using the writepos,
-			 * but that's a little bit ambitious and unnecessary... */
-			/* rather add our safety margin to the writepos, if we're playing */
+			 * but that's a little bit ambitious and unnecessary...
+			 * rather add our safety margin to the writepos, if we're playing */
+			writepos = playpos;
+
 			if (!paused) {
-				writepos += device->writelead;
-				writepos %= device->buflen;
-			} else writepos = playpos;
-		} else {
- 			playpos = device->pwplay * device->fraglen;
- 			writepos = playpos;
- 			if (!paused) {
-	 			writepos += ds_hel_margin * device->fraglen;
- 				writepos %= device->buflen;
-	 		}
+				writepos += playlead;
+				if (writepos > device->buflen) {
+					writepos -= device->buflen;
+				}
+			}
 		}
+
 		TRACE("primary playpos=%d, writepos=%d, clrpos=%d, mixpos=%d, buflen=%d\n",
 		      playpos,writepos,device->playpos,device->mixpos,device->buflen);
 		assert(device->playpos < device->buflen);
+#ifdef SYNC_CALLBACK
+		EnterCriticalSection(&(device->mixlock));
+#endif
 		/* wipe out just-played sound data */
 		if (playpos < device->playpos) {
 			FillMemory(device->buffer + device->playpos, device->buflen - device->playpos, nfiller);
@@ -992,32 +1108,63 @@ static void DSOUND_PerformMix(DirectSoun
 		}
 		device->playpos = playpos;
 
-		EnterCriticalSection(&(device->mixlock));
-
 		/* reset mixing if necessary */
 		DSOUND_CheckReset(device, writepos);
 
 		/* check how much prebuffering is left */
-		inq = device->mixpos;
-		if (inq < writepos)
-			inq += device->buflen;
-		inq -= writepos;
+		inq = DSOUND_BufPtrDiff(device->buflen, device->mixpos, writepos);
 
 		/* find the maximum we can prebuffer */
-		if (!paused) {
-			maxq = playpos;
-			if (maxq < writepos)
-				maxq += device->buflen;
-			maxq -= writepos;
-		} else maxq = device->buflen;
+		maxq = DSOUND_BufPtrDiff(device->buflen,
+				playpos, writepos);
+		if (maxq == 0) {
+			maxq = device->buflen;
+		}
 
 		/* clip maxq to device->prebuf */
 		frag = device->prebuf * device->fraglen;
 		if (maxq > frag) maxq = frag;
 
 		/* check for consistency */
-		if (inq > maxq) {
-			/* the playback position must have passed our last
+		underrun = (inq > maxq) || paused;
+		
+		/* do the mixing */
+		frag = DSOUND_MixToPrimary(device, playpos, writepos, maxq, underrun);
+		if (frag != 0 || forced) {
+			device->mixpos = writepos + frag;
+			device->mixpos %= device->buflen;
+		}
+		
+		playleft = DSOUND_BufPtrDiff(device->buflen,
+			device->mixpos, playpos);
+		
+		if (paused) {
+			if (frag > 0 || forced) {
+				/* buffers have been filled, restart playback */
+				if (device->state == STATE_STARTING) {
+					device->state = STATE_PLAYING;
+				}
+				else if (device->state == STATE_STOPPED) {
+					/* stopping just means that play will stop once there's no more to
+					 * play. */
+					device->state = STATE_STOPPING;
+				}
+#ifdef SYNC_CALLBACK
+				LeaveCriticalSection(&(device->mixlock));
+#endif
+				if (paused) {
+					if (DSOUND_PrimaryPlay(device) != DS_OK)
+						WARN("DSOUND_PrimaryPlay failed\n");
+					else
+						TRACE("starting playback\n");
+				}
+#ifdef SYNC_CALLBACK
+				EnterCriticalSection(&(device->mixlock));
+#endif			
+			}
+		}
+		else if (playleft > maxq + playlead) {
+			/* the playback position has passed our last
 			 * mixed position, i.e. it's an underrun, or we have
 			 * nothing more to play */
 			TRACE("reached end of mixed data (inq=%d, maxq=%d)\n", inq, maxq);
@@ -1037,6 +1184,8 @@ #ifdef SYNC_CALLBACK
 			/* DSOUND_callback may need this lock */
 			LeaveCriticalSection(&(device->mixlock));
 #endif
+			FillMemory(device->buffer, device->buflen, nfiller);
+
 			if (DSOUND_PrimaryStop(device) != DS_OK)
 				WARN("DSOUND_PrimaryStop failed\n");
 #ifdef SYNC_CALLBACK
@@ -1047,7 +1196,9 @@ #endif
 				/* unfortunately, OSS is not able to do so, so get current pointer */
 				hres = IDsDriverBuffer_GetPosition(device->hwbuf, &playpos, NULL);
 				if (hres) {
+#ifdef SYNC_CALLBACK
 					LeaveCriticalSection(&(device->mixlock));
+#endif
 					WARN("IDsDriverBuffer_GetPosition failed\n");
 					return;
 				}
@@ -1057,39 +1208,10 @@ #endif
 			writepos = playpos;
 			device->playpos = playpos;
 			device->mixpos = writepos;
-			inq = 0;
-			maxq = device->buflen;
-			if (maxq > frag) maxq = frag;
-			FillMemory(device->buffer, device->buflen, nfiller);
-			paused = TRUE;
 		}
-
-		/* do the mixing */
-		frag = DSOUND_MixToPrimary(device, playpos, writepos, maxq, paused);
-		if (forced) frag = maxq - inq;
-		device->mixpos += frag;
-		device->mixpos %= device->buflen;
-
-		if (frag) {
-			/* buffers have been filled, restart playback */
-			if (device->state == STATE_STARTING) {
-				device->state = STATE_PLAYING;
-			}
-			else if (device->state == STATE_STOPPED) {
-				/* the dsound is supposed to play if there's something to play
-				 * even if it is reported as stopped, so don't let this confuse you */
-				device->state = STATE_STOPPING;
-			}
-			LeaveCriticalSection(&(device->mixlock));
-			if (paused) {
-				if (DSOUND_PrimaryPlay(device) != DS_OK)
-					WARN("DSOUND_PrimaryPlay failed\n");
-				else
-					TRACE("starting playback\n");
-			}
-		}
-		else
-			LeaveCriticalSection(&(device->mixlock));
+#ifdef SYNC_CALLBACK
+		LeaveCriticalSection(&(device->mixlock));
+#endif
 	} else {
 		/* in the DSSCL_WRITEPRIMARY mode, the app is totally in charge... */
 		if (device->state == STATE_STARTING) {
