Index: trunk/src/winmm/initwinmm.cpp
===================================================================
--- trunk/src/winmm/initwinmm.cpp	(revision 8566)
+++ trunk/src/winmm/initwinmm.cpp	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: initwinmm.cpp,v 1.8 2002-05-28 17:10:02 sandervl Exp $
+/* $Id: initwinmm.cpp,v 1.9 2002-06-04 17:36:55 sandervl Exp $
  *
  * WINMM DLL entry point
@@ -243,5 +243,5 @@
         return MCIERR_CANNOT_LOAD_DRIVER;
     }
-    USHORT sel = GetFS();
+    USHORT sel = RestoreOS2FS();
     DWORD ret = pfnmciSendCommand(wDeviceID, wMessage, dwParam1, dwParam2, wUserParm);
     SetFS(sel);
@@ -258,5 +258,5 @@
         return MCIERR_CANNOT_LOAD_DRIVER;
     }
-    USHORT sel = GetFS();
+    USHORT sel = RestoreOS2FS();
     DWORD ret = pfnmciGetErrorString(dwError, lpstrBuffer, wLength);
     SetFS(sel);
Index: trunk/src/winmm/waveout.cpp
===================================================================
--- trunk/src/winmm/waveout.cpp	(revision 8566)
+++ trunk/src/winmm/waveout.cpp	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveout.cpp,v 1.24 2002-05-28 14:09:25 sandervl Exp $ */
+/* $Id: waveout.cpp,v 1.25 2002-06-04 17:36:55 sandervl Exp $ */
 //#undef DEBUG
 /*
@@ -153,5 +153,5 @@
 
     if(WaveOut::find(dwave) == TRUE)
-         return(dwave->restart());
+         return(dwave->resume());
     else return(MMSYSERR_INVALHANDLE);
 }
Index: trunk/src/winmm/waveoutbase.h
===================================================================
--- trunk/src/winmm/waveoutbase.h	(revision 8566)
+++ trunk/src/winmm/waveoutbase.h	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveoutbase.h,v 1.2 2001-06-02 08:30:35 sandervl Exp $ */
+/* $Id: waveoutbase.h,v 1.3 2002-06-04 17:36:55 sandervl Exp $ */
 
 /*
@@ -27,5 +27,5 @@
      virtual  MMRESULT pause() = 0;
      virtual  MMRESULT stop() = 0;
-     virtual  MMRESULT restart() = 0;
+     virtual  MMRESULT resume() = 0;
      virtual  MMRESULT reset() = 0;
      virtual  ULONG    getPosition() = 0;
Index: trunk/src/winmm/waveoutdart.cpp
===================================================================
--- trunk/src/winmm/waveoutdart.cpp	(revision 8566)
+++ trunk/src/winmm/waveoutdart.cpp	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveoutdart.cpp,v 1.7 2002-04-07 14:36:31 sandervl Exp $ */
+/* $Id: waveoutdart.cpp,v 1.8 2002-06-04 17:36:55 sandervl Exp $ */
 
 /*
@@ -197,8 +197,14 @@
         int minbufsize = consumerate/32;
 
-        ulBufSize = pwh->dwBufferLength/2;
-        if(ulBufSize > minbufsize) {
-            dprintf(("set buffer size to %d bytes (org size = %d)", minbufsize, pwh->dwBufferLength));
-            ulBufSize = minbufsize;
+        if(pwh->dwBufferLength > minbufsize) {
+            ulBufSize = pwh->dwBufferLength/2;
+            if(ulBufSize < minbufsize) {
+                dprintf(("set buffer size to %d bytes (org size = %d)", minbufsize, pwh->dwBufferLength));
+                ulBufSize = minbufsize;
+            }
+        }
+        else {
+            //assume application knows what it's doing and use the first buffersize
+            ulBufSize = pwh->dwBufferLength;
         }
 #else
@@ -261,5 +267,5 @@
         //write buffers to DART; starts playback
         // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
-        USHORT selTIB = GetFS(); // save current FS selector
+        USHORT selTIB = RestoreOS2FS(); // save current FS selector
 
         MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle,
@@ -267,5 +273,4 @@
                                  PREFILLBUF_DART);
         SetFS(selTIB);           // switch back to the saved FS selector
-
         dprintf(("Dart playing\n"));
     }
@@ -290,28 +295,19 @@
 
         writeBuffer();  //must be called before (re)starting playback
+
+        State     = STATE_PLAYING;
+        fUnderrun = FALSE;
         wmutex.leave();
 
-        if(State == STATE_STOPPED) {//continue playback
-            restart();
-        }
-        else
-        if(fUnderrun) {
-            dprintf(("Resume playback after underrun"));
-            fUnderrun = FALSE;
-            State = STATE_PLAYING;
-
-            memset(&GenericParms, 0, sizeof(GenericParms));
-
-            // Resume the playback.
-            mymciSendCommand(DeviceId, MCI_RESUME, MCI_WAIT, (PVOID)&GenericParms, 0);
-
-            //write buffers to DART; starts playback
-            // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
-            USHORT selTIB = GetFS(); // save current FS selector
-
-            MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle, &MixBuffer[curPlayBuf], 1);
-
-            SetFS(selTIB);           // switch back to the saved FS selector
-        }
+        //write buffers to DART; starts playback
+        // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
+        USHORT selTIB = RestoreOS2FS(); // save current FS selector
+
+        MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle,
+                                 MixBuffer,
+                                 PREFILLBUF_DART);
+        SetFS(selTIB);           // switch back to the saved FS selector
+
+        dprintf(("Dart playing\n"));
     }
     return(MMSYSERR_NOERROR);
@@ -321,5 +317,5 @@
 MMRESULT DartWaveOut::pause()
 {
- MCI_GENERIC_PARMS Params;
+    MCI_GENERIC_PARMS Params;
 
     dprintf(("WINMM: DartWaveOut::pause"));
@@ -339,4 +335,28 @@
     // Pause the playback.
     mymciSendCommand(DeviceId, MCI_PAUSE, MCI_WAIT, (PVOID)&Params, 0);
+
+    return(MMSYSERR_NOERROR);
+}
+/******************************************************************************/
+/******************************************************************************/
+MMRESULT DartWaveOut::resume()
+{
+    MCI_GENERIC_PARMS Params;
+
+    dprintf(("DartWaveOut::resume"));
+    
+    wmutex.enter();
+    if(State != STATE_PAUSED) {
+        wmutex.leave();
+        return(MMSYSERR_NOERROR);
+    }
+
+    State = STATE_PLAYING;
+    wmutex.leave();
+
+    memset(&Params, 0, sizeof(Params));
+
+    // Resume the playback.
+    mymciSendCommand(DeviceId, MCI_RESUME, MCI_WAIT, (PVOID)&Params, 0);
 
     return(MMSYSERR_NOERROR);
@@ -408,39 +428,4 @@
 /******************************************************************************/
 /******************************************************************************/
-MMRESULT DartWaveOut::restart()
-{
-  int i, curbuf;
-
-    dprintf(("DartWaveOut::restart"));
-    if(State == STATE_PLAYING)
-        return(MMSYSERR_NOERROR);
-
-    //Only write buffers to dart if mixer has been initialized; if not, then
-    //the first buffer write will do this for us.
-    if(fMixerSetup == TRUE)
-    {
-        wmutex.enter();
-        State     = STATE_PLAYING;
-        fUnderrun = FALSE;
-        wmutex.leave();
-        curbuf = curPlayBuf;
-
-        // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
-        USHORT selTIB = GetFS(); // save current FS selector
-
-        for(i=0;i<PREFILLBUF_DART;i++)
-        {
-            dprintf(("restart: write buffer at %x size %d", MixBuffer[curbuf].pBuffer, MixBuffer[curbuf].ulBufferLength));
-            MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle, &MixBuffer[curbuf], 1);
-            if(++curbuf == PREFILLBUF_DART)
-                curbuf = 0;
-        }
-        SetFS(selTIB);           // switch back to the saved FS selector
-    }
-
-    return(MMSYSERR_NOERROR);
-}
-/******************************************************************************/
-/******************************************************************************/
 ULONG DartWaveOut::getPosition()
 {
@@ -612,5 +597,5 @@
     //Transfer buffer to DART
     // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector!
-    USHORT selTIB = GetFS(); // save current FS selector
+    USHORT selTIB = RestoreOS2FS(); // save current FS selector
     MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle, &MixBuffer[curPlayBuf], 1);
     SetFS(selTIB);           // switch back to the saved FS selector
@@ -678,6 +663,8 @@
                              ULONG ulFlags)
 {
- PTIB2 ptib2;
- DartWaveOut *dwave;
+    PTIB2 ptib2;
+    DartWaveOut *dwave;
+
+    dprintf2(("WaveOutHandler %x %x %x", ulStatus, pBuffer, ulFlags));
 
     ptib2 = (PTIB2)_getTIBvalue(offsetof(TIB, tib_ptib2));
Index: trunk/src/winmm/waveoutdart.h
===================================================================
--- trunk/src/winmm/waveoutdart.h	(revision 8566)
+++ trunk/src/winmm/waveoutdart.h	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveoutdart.h,v 1.2 2001-04-01 12:31:01 sandervl Exp $ */
+/* $Id: waveoutdart.h,v 1.3 2002-06-04 17:36:56 sandervl Exp $ */
 
 /*
@@ -38,5 +38,5 @@
      virtual  MMRESULT pause();
      virtual  MMRESULT stop();
-     virtual  MMRESULT restart();
+     virtual  MMRESULT resume();
      virtual  MMRESULT setVolume(ULONG ulVol);
      virtual  MMRESULT reset();
Index: trunk/src/winmm/waveoutdaud.cpp
===================================================================
--- trunk/src/winmm/waveoutdaud.cpp	(revision 8566)
+++ trunk/src/winmm/waveoutdaud.cpp	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveoutdaud.cpp,v 1.7 2002-04-07 14:36:32 sandervl Exp $ */
+/* $Id: waveoutdaud.cpp,v 1.8 2002-06-04 17:36:56 sandervl Exp $ */
 
 /*
@@ -160,15 +160,14 @@
     }
 
-    if(State == STATE_STOPPED) {//continue playback
-        restart();
-    }
-    else
-    if(fUnderrun) {
-        dprintf(("Resume playback after underrun"));
+    if(State == STATE_STOPPED || fUnderrun) {
+        wmutex.enter();
+        State     = STATE_PLAYING;
         fUnderrun = FALSE;
-        State = STATE_PLAYING;
-
-        // Resume the playback.
-        resume();
+        wmutex.leave();
+
+        if(sendIOCTL(DAUDIO_START, &cmd)) {
+            dprintf(("Unable to (re)start stream!!!!!"));
+            return MMSYSERR_ERROR;
+        }
     }
     return(MMSYSERR_NOERROR);
@@ -266,21 +265,4 @@
 /******************************************************************************/
 /******************************************************************************/
-MMRESULT DAudioWaveOut::restart()
-{
-    DAUDIO_CMD cmd;
-
-    dprintf(("DAudioWaveOut::restart"));
-    if(State == STATE_PLAYING)
-        return(MMSYSERR_NOERROR);
-
-    wmutex.enter();
-    State     = STATE_PLAYING;
-    fUnderrun = FALSE;
-    wmutex.leave();
-
-    return sendIOCTL(DAUDIO_START, &cmd);
-}
-/******************************************************************************/
-/******************************************************************************/
 ULONG DAudioWaveOut::getPosition()
 {
Index: trunk/src/winmm/waveoutdaud.h
===================================================================
--- trunk/src/winmm/waveoutdaud.h	(revision 8566)
+++ trunk/src/winmm/waveoutdaud.h	(revision 8568)
@@ -1,3 +1,3 @@
-/* $Id: waveoutdaud.h,v 1.4 2001-04-30 21:06:56 sandervl Exp $ */
+/* $Id: waveoutdaud.h,v 1.5 2002-06-04 17:36:56 sandervl Exp $ */
 
 /*
@@ -30,5 +30,5 @@
      virtual  MMRESULT pause();
      virtual  MMRESULT stop();
-     virtual  MMRESULT restart();
+     virtual  MMRESULT resume();
      virtual  MMRESULT setVolume(ULONG ulVol);
      virtual  MMRESULT reset();
@@ -44,5 +44,4 @@
 
 private:
-       MMRESULT resume();
        BOOL     handler();
        MMRESULT sendIOCTL(ULONG cmd, DAUDIO_CMD *pDataPacket);
