rpcrt4: Use safe_multiply when multiplying anything by pStubMsg->ActualCount or pStub...
[wine] / dlls / winmm / wineoss / oss.c
index e015889..2632cd4 100644 (file)
 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
-/*                                
+/*
  * Wine Driver for Open Sound System
  *
  * Copyright   1999 Eric Pouech
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
+#include <stdarg.h>
+
 #include "windef.h"
+#include "winbase.h"
 #include "wingdi.h"
 #include "winuser.h"
-#include "driver.h"
 #include "mmddk.h"
 #include "oss.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wave);
 
-static struct WINE_OSS* oss = NULL;
+#ifdef HAVE_OSS
 
 /**************************************************************************
- *                             OSS_drvOpen                     [internal]      
+ *                             OSS_drvLoad                     [internal]
  */
-static DWORD   OSS_drvOpen(LPSTR str)
+static LRESULT OSS_drvLoad(void)
 {
-    if (oss)
-       return 0;
-    
-    /* I know, this is ugly, but who cares... */
-    oss = (struct WINE_OSS*)1;
+    TRACE("()\n");
+    OSS_WaveInit();
+    OSS_MidiInit();
+    OSS_MixerInit();
+    OSS_AuxInit();
     return 1;
 }
 
 /**************************************************************************
- *                             OSS_drvClose                    [internal]      
+ *                             OSS_drvFree                     [internal]
  */
-static DWORD   OSS_drvClose(DWORD dwDevID)
+static LRESULT OSS_drvFree(void)
 {
-    if (oss) {
-       oss = NULL;
-       return 1;
-    }
-    return 0;
+    TRACE("()\n");
+    OSS_WaveExit();
+    OSS_MidiExit();
+    OSS_MixerExit();
+    OSS_AuxExit();
+    return 1;
 }
 
 /**************************************************************************
- *                             OSS_DriverProc                  [internal]
+ *                             OSS_drvOpen                     [internal]
  */
-LONG CALLBACK  OSS_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg, 
-                              DWORD dwParam1, DWORD dwParam2)
+static LRESULT OSS_drvOpen(LPSTR str)
 {
-/* EPP     TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n",  */
-/* EPP           dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
-    
+    TRACE("(%s)\n", str);
+    return 1;
+}
+
+/**************************************************************************
+ *                             OSS_drvClose                    [internal]
+ */
+static LRESULT OSS_drvClose(DWORD_PTR dwDevID)
+{
+    TRACE("(%08lx)\n", dwDevID);
+    return 1;
+}
+
+#endif
+
+
+/**************************************************************************
+ *                             DriverProc (WINEOSS.1)
+ */
+LRESULT CALLBACK OSS_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
+                                LPARAM dwParam1, LPARAM dwParam2)
+{
+     TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
+           dwDevID, hDriv, wMsg, dwParam1, dwParam2);
+
     switch(wMsg) {
-    case DRV_LOAD:             OSS_WaveInit(); OSS_MidiInit(); return 1;
-    case DRV_FREE:             return 1;
+#ifdef HAVE_OSS
+    case DRV_LOAD:             return OSS_drvLoad();
+    case DRV_FREE:             return OSS_drvFree();
     case DRV_OPEN:             return OSS_drvOpen((LPSTR)dwParam1);
     case DRV_CLOSE:            return OSS_drvClose(dwDevID);
     case DRV_ENABLE:           return 1;
@@ -59,9 +103,8 @@ LONG CALLBACK        OSS_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg,
     case DRV_CONFIGURE:                MessageBoxA(0, "OSS MultiMedia Driver !", "OSS Driver", MB_OK); return 1;
     case DRV_INSTALL:          return DRVCNF_RESTART;
     case DRV_REMOVE:           return DRVCNF_RESTART;
+#endif
     default:
        return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
     }
 }
-
-