winejack.drv: Clean up loading.
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Wed, 21 Apr 2010 11:45:32 +0000 (13:45 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 21 Apr 2010 14:15:10 +0000 (16:15 +0200)
dlls/winejack.drv/audio.c
dlls/winejack.drv/jack.c
dlls/winejack.drv/jack.h

index 512bc01c2a4f760cd6ce2a67b6861ffd5923d906..ffaffae699b198502ece8b3834ecd618e606f62b 100644 (file)
@@ -834,15 +834,19 @@ static void       JACK_CloseWaveInDevice(WINE_WAVEIN* wwi)
 #endif
 }
 
+static int WAVE_loadcount;
+
 /******************************************************************
  *             JACK_WaveRelease
  *
  *
  */
-LONG   JACK_WaveRelease(void)
+static LONG JACK_WaveRelease(void)
 { 
   int iDevice;
 
+  if (--WAVE_loadcount)
+      return 1;
   TRACE("closing all open waveout devices\n");
 
   /* close all open output devices */
@@ -887,12 +891,14 @@ LONG      JACK_WaveRelease(void)
  *
  * Initialize internal structures from JACK server info
  */
-LONG JACK_WaveInit(void)
+static LONG JACK_WaveInit(void)
 {
     int i;
     CHAR szPname[MAXPNAMELEN];
 
     TRACE("called\n");
+    if (WAVE_loadcount++)
+        return 1;
 
     /* setup function pointers */
 #define LOAD_FUNCPTR(f) if((fp_##f = wine_dlsym(jackhandle, #f, NULL, 0)) == NULL) goto sym_not_found;    
@@ -1665,7 +1671,9 @@ DWORD WINAPI JACK_wodMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
 
   switch (wMsg) {
   case DRVM_INIT:
+    return JACK_WaveInit();
   case DRVM_EXIT:
+    return JACK_WaveRelease();
   case DRVM_ENABLE:
   case DRVM_DISABLE:
     /* FIXME: Pretend this is supported */
@@ -2362,7 +2370,9 @@ DWORD WINAPI JACK_widMessage(WORD wDevID, WORD wMsg, DWORD dwUser,
 
     switch (wMsg) {
     case DRVM_INIT:
+        return JACK_WaveInit();
     case DRVM_EXIT:
+        return JACK_WaveRelease();
     case DRVM_ENABLE:
     case DRVM_DISABLE:
        /* FIXME: Pretend this is supported */
index 80794ae86be85520961010d97e6761da92fc8139..ebcb6c7c87357f61cbe99e90c377eb6ffc0bc60e 100644 (file)
@@ -49,20 +49,17 @@ static LRESULT JACK_drvLoad(void)
   TRACE("()\n");
 
   /* dynamically load the jack library if not already loaded */
+  jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0);
+  TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK);
+  TRACE("jackhandle == %p\n", jackhandle);
   if(!jackhandle)
   {
-    jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0);
-    TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK);
-    TRACE("jackhandle == %p\n", jackhandle);
-    if(!jackhandle)
-    {
-      FIXME("error loading the jack library %s, please install this library to use jack\n", SONAME_LIBJACK);
-      jackhandle = (void*)-1;
-      return 0;
-    }
+    FIXME("error loading the jack library %s, please install this library to use jack\n",
+          SONAME_LIBJACK);
+    return 0;
   }
 
-  return JACK_WaveInit();
+  return 1;
 }
 
 /**************************************************************************
@@ -73,10 +70,8 @@ static LRESULT JACK_drvFree(void)
 {
   TRACE("()\n");
 
-  if(jackhandle && (jackhandle != (void*)-1))
+  if(jackhandle)
   {
-    JACK_WaveRelease();
-
     TRACE("calling wine_dlclose() on jackhandle\n");
     wine_dlclose(jackhandle, NULL, 0);
     jackhandle = NULL;
@@ -85,31 +80,6 @@ static LRESULT JACK_drvFree(void)
   return 1;
 }
 
-/**************************************************************************
- *                             JACK_drvOpen                    [internal]      
- */
-static LRESULT JACK_drvOpen(LPSTR str)
-{
-  TRACE("(%s)\n", str);
-  /* if we were unable to load the jack library then fail the */
-  /* driver open */
-  if(!jackhandle)
-  {
-    FIXME("unable to open the jack library, returning 0\n");
-    return 0;
-  }
-
-  return 1;
-}
-
-/**************************************************************************
- *                             JACK_drvClose                   [internal]      
- */
-static LRESULT JACK_drvClose(DWORD_PTR dwDevID)
-{
-  TRACE("(%08lx)\n", dwDevID);
-  return 1;
-}
 #endif /* #ifdef SONAME_LIBJACK */
 
 
@@ -136,16 +106,17 @@ LRESULT CALLBACK JACK_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
 #ifdef SONAME_LIBJACK
     case DRV_LOAD:             return JACK_drvLoad();
     case DRV_FREE:             return JACK_drvFree();
-    case DRV_OPEN:             return JACK_drvOpen((LPSTR)dwParam1);
-    case DRV_CLOSE:            return JACK_drvClose(dwDevID);
-    case DRV_ENABLE:           return 1;
-    case DRV_DISABLE:          return 1;
-    case DRV_QUERYCONFIGURE:   return 1;
+    case DRV_OPEN:
+    case DRV_CLOSE:
+    case DRV_INSTALL:
+    case DRV_REMOVE:
+    case DRV_ENABLE:
+    case DRV_DISABLE:
+    case DRV_QUERYCONFIGURE:
+        return 1;
     case DRV_CONFIGURE:                MessageBoxA(0, "jack audio driver!", "jack 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);
+       return 0;
     }
 }
index c53041dab64cb739b290cf1e17dfbb003bb7d80d..5545f24a080adbf5ec54b1fa5beb1c42578bdc68 100644 (file)
@@ -22,7 +22,4 @@
 
 extern void *jackhandle; /* pointer to the libjack library */
 
-extern LONG JACK_WaveInit(void);
-extern LONG JACK_WaveRelease(void);
-
 #endif /* __WINE_JACK_H */