Index: trunk/src/winmm/os2timer.cpp
===================================================================
--- trunk/src/winmm/os2timer.cpp	(revision 9901)
+++ trunk/src/winmm/os2timer.cpp	(revision 9902)
@@ -1,3 +1,3 @@
-/* $Id: os2timer.cpp,v 1.19 2001-10-03 13:47:58 sandervl Exp $ */
+/* $Id: os2timer.cpp,v 1.20 2003-03-05 14:49:03 sandervl Exp $ */
 
 /*
@@ -24,5 +24,6 @@
 #include <win32api.h>
 #include <wprocess.h>
-#include <misc.h>
+#include <dbglog.h>
+#include <vmutex.h>
 
 #include "time.h"
@@ -36,5 +37,5 @@
  * Structures                                                               *
  ****************************************************************************/
-  
+static VMutex timeMutex;
 
 /****************************************************************************
@@ -70,4 +71,5 @@
            dwPeriod));
 
+  timeMutex.enter();
   // add to linked list
   OS2TimerResolution *timeRes = OS2TimerResolution::sTimerResolutions;
@@ -83,4 +85,6 @@
   else
     OS2TimerResolution::sTimerResolutions = this;
+
+  timeMutex.leave();
 
   this->dwPeriod = dwPeriod;
@@ -106,4 +110,6 @@
 
 
+  timeMutex.enter();
+
   // remove from linked list
   OS2TimerResolution *timeRes = OS2TimerResolution::sTimerResolutions;
@@ -121,4 +127,6 @@
   else
     OS2TimerResolution::sTimerResolutions = timeRes->next;
+
+  timeMutex.leave();
 }
 
@@ -166,4 +174,5 @@
            dwPeriod));
 
+  timeMutex.enter();
   OS2TimerResolution* timeRes = OS2TimerResolution::sTimerResolutions;
 
@@ -178,7 +187,10 @@
     {
       delete timeRes;              // so delete that object
+      timeMutex.leave();
       return TRUE;                 // OK, can remove the entry
     }
  }
+ timeMutex.leave();
+
  return FALSE;                     // nope, mismatch !
 }
@@ -199,4 +211,5 @@
 int OS2TimerResolution::queryCurrentResolution()
 {
+  timeMutex.enter();
   OS2TimerResolution *timeRes = OS2TimerResolution::sTimerResolutions;
   int                iMin = -1;
@@ -210,4 +223,5 @@
         iMin = timeRes->dwPeriod;
     }
+  timeMutex.leave();
 
   dprintf(("WINMM:OS2Timer: OS2TimerResolution::queryCurrentResolution == %08xh\n",
@@ -230,4 +244,5 @@
            this));
 
+  timeMutex.enter();
   OS2Timer *timer = OS2Timer::timers;
 
@@ -242,4 +257,5 @@
   else
     timers = this;
+  timeMutex.leave();
   
   // create timer semaphore
@@ -274,8 +290,9 @@
            this));
 
+  KillTimer();
+
+  timeMutex.enter();
   OS2Timer *timer = OS2Timer::timers;
 
-  KillTimer();
-
   if(timer != this)
   {
@@ -288,4 +305,6 @@
   else
     timers = timer->next;
+
+  timeMutex.leave();
 }
 /******************************************************************************/
Index: trunk/src/winmm/waveindart.cpp
===================================================================
--- trunk/src/winmm/waveindart.cpp	(revision 9901)
+++ trunk/src/winmm/waveindart.cpp	(revision 9902)
@@ -1,3 +1,3 @@
-/* $Id: waveindart.cpp,v 1.5 2002-06-05 11:05:56 sandervl Exp $ */
+/* $Id: waveindart.cpp,v 1.6 2003-03-05 14:49:04 sandervl Exp $ */
 
 /*
@@ -6,4 +6,5 @@
  * Copyright 2001 Sander van Leeuwen (sandervl@xs4all.nl)
  *
+ * TODO: mulaw, alaw & adpcm
  *
  * Project Odin Software License can be found in LICENSE.TXT
@@ -46,5 +47,17 @@
 LONG APIENTRY WaveInHandler(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags);
 
-//TODO: mulaw, alaw & adpcm
+static BOOL fwaveInFixedBuffers = FALSE;
+
+//******************************************************************************
+// ODIN_waveInSetFixedBuffers
+//
+// Tell WINMM to use DART buffers of the same size as the first buffer delivered
+// by waveInAddBuffer
+//
+//******************************************************************************
+void WIN32API ODIN_waveInSetFixedBuffers()
+{
+    fwaveInFixedBuffers = TRUE;
+}
 /******************************************************************************/
 /******************************************************************************/
@@ -208,7 +221,13 @@
         LPWAVEHDR pwh = wavehdr;
         if(pwh) {
-            dprintf(("mix setup %d, %d\n", pwh->dwBufferLength, pwh->dwBufferLength));
-
-            ulBufSize = pwh->dwBufferLength/2;
+            if(fwaveInFixedBuffers) {
+                ulBufSize = pwh->dwBufferLength;
+            }
+            else 
+            {
+                dprintf(("mix setup %d, %d\n", pwh->dwBufferLength, pwh->dwBufferLength));
+    
+                ulBufSize = pwh->dwBufferLength/2;
+            }
             if(ulBufSize > minbufsize) {
                 dprintf(("set buffer size to %d bytes (org size = %d)", minbufsize, pwh->dwBufferLength));
@@ -388,4 +407,9 @@
     ULONG rc, nrbytes;
 
+    if(State == STATE_STOPPED) {
+        dprintf(("Not recording; return 0 position"));
+        return 0;
+    }
+
     mciStatus.ulItem = MCI_STATUS_POSITION;
     rc = mymciSendCommand(DeviceId, MCI_STATUS, MCI_STATUS_ITEM|MCI_WAIT, (PVOID)&mciStatus, 0);
Index: trunk/src/winmm/waveinoutbase.cpp
===================================================================
--- trunk/src/winmm/waveinoutbase.cpp	(revision 9901)
+++ trunk/src/winmm/waveinoutbase.cpp	(revision 9902)
@@ -1,3 +1,3 @@
-/* $Id: waveinoutbase.cpp,v 1.5 2003-01-14 19:38:38 sandervl Exp $ */
+/* $Id: waveinoutbase.cpp,v 1.6 2003-03-05 14:49:04 sandervl Exp $ */
 
 /*
@@ -140,4 +140,7 @@
         break;
 
+    case CALLBACK_NULL:
+        break; //no callback
+
     default:
         dprintf(("WARNING: Unknown callback type %x %x", fdwOpen, dwCallback));
Index: trunk/src/winmm/waveoutdart.cpp
===================================================================
--- trunk/src/winmm/waveoutdart.cpp	(revision 9901)
+++ trunk/src/winmm/waveoutdart.cpp	(revision 9902)
@@ -1,3 +1,3 @@
-/* $Id: waveoutdart.cpp,v 1.15 2002-08-16 10:09:49 sandervl Exp $ */
+/* $Id: waveoutdart.cpp,v 1.16 2003-03-05 14:49:04 sandervl Exp $ */
 
 /*
@@ -53,11 +53,15 @@
 static BOOL fFixedWaveBufferSize = FALSE;
 
-/******************************************************************************/
-//Call to tell winmm to expect simple fixed size buffers, so
-//it doesn't have to use very small DART buffers; this will
-//only work in very specific cases; it is not a good general
-//purpose solution)
-/******************************************************************************/
-void WIN32API SetFixedWaveBufferSize()
+//******************************************************************************
+// ODIN_waveOutSetFixedBuffers
+//
+// Tell WINMM to use DART buffers of the same size as the first buffer delivered
+// by waveOutWrite
+//
+// NOTE: This will only work in very specific cases; it is not a good general
+//       purpose solution.
+// 
+//******************************************************************************
+void WIN32API ODIN_waveOutSetFixedBuffers();
 {
     fFixedWaveBufferSize = TRUE;
@@ -224,5 +228,4 @@
         else    ulBufSize = 1024;
 #endif
-
         MixSetupParms->ulBufferSize = ulBufSize;
 
@@ -467,4 +470,9 @@
  ULONG rc, nrbytes;
 
+    if(State == STATE_STOPPED) {
+        dprintf(("Not playing; return 0 position"));
+        return 0;
+    }
+
     mciStatus.ulItem = MCI_STATUS_POSITION;
     rc = mymciSendCommand(DeviceId, MCI_STATUS, MCI_STATUS_ITEM|MCI_WAIT, (PVOID)&mciStatus, 0);
