user32/tests: Fix more DDE test failures on Win9x.
[wine] / dlls / winejack.drv / jack.c
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3  * Wine Driver for jack Sound Server
4  *   http://jackit.sourceforge.net
5  *
6  * Copyright 2002 Chris Morgan
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdarg.h>
27 #include <stdio.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "mmddk.h"
34 #include "jack.h"
35 #include "wine/library.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(jack);
39
40 #ifdef SONAME_LIBJACK
41
42 void *jackhandle = NULL;
43
44 /**************************************************************************
45  *                              JACK_drvLoad                    [internal]      
46  */
47 static LRESULT JACK_drvLoad(void)
48 {
49   TRACE("()\n");
50
51   /* dynamically load the jack library if not already loaded */
52   jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0);
53   TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK);
54   TRACE("jackhandle == %p\n", jackhandle);
55   if(!jackhandle)
56   {
57     FIXME("error loading the jack library %s, please install this library to use jack\n",
58           SONAME_LIBJACK);
59     return 0;
60   }
61
62   return 1;
63 }
64
65 /**************************************************************************
66  *                              JACK_drvFree                    [internal]      
67  */
68 /* unload the jack library on driver free */
69 static LRESULT JACK_drvFree(void)
70 {
71   TRACE("()\n");
72
73   if(jackhandle)
74   {
75     TRACE("calling wine_dlclose() on jackhandle\n");
76     wine_dlclose(jackhandle, NULL, 0);
77     jackhandle = NULL;
78   }
79
80   return 1;
81 }
82
83 #endif /* #ifdef SONAME_LIBJACK */
84
85
86 /**************************************************************************
87  *                              DriverProc (WINEJACK.1)
88  */
89 LRESULT CALLBACK JACK_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg, 
90                                  LPARAM dwParam1, LPARAM dwParam2)
91 {
92      TRACE("(%08lX, %p, %s (%08X), %08lX, %08lX)\n",
93            dwDevID, hDriv, wMsg == DRV_LOAD ? "DRV_LOAD" :
94            wMsg == DRV_FREE ? "DRV_FREE" :
95            wMsg == DRV_OPEN ? "DRV_OPEN" :
96            wMsg == DRV_CLOSE ? "DRV_CLOSE" :
97            wMsg == DRV_ENABLE ? "DRV_ENABLE" :
98            wMsg == DRV_DISABLE ? "DRV_DISABLE" :
99            wMsg == DRV_QUERYCONFIGURE ? "DRV_QUERYCONFIGURE" :
100            wMsg == DRV_CONFIGURE ? "DRV_CONFIGURE" :
101            wMsg == DRV_INSTALL ? "DRV_INSTALL" :
102            wMsg == DRV_REMOVE ? "DRV_REMOVE" : "UNKNOWN", 
103            wMsg, dwParam1, dwParam2);
104     
105     switch(wMsg) {
106 #ifdef SONAME_LIBJACK
107     case DRV_LOAD:              return JACK_drvLoad();
108     case DRV_FREE:              return JACK_drvFree();
109     case DRV_OPEN:
110     case DRV_CLOSE:
111     case DRV_INSTALL:
112     case DRV_REMOVE:
113     case DRV_ENABLE:
114     case DRV_DISABLE:
115     case DRV_QUERYCONFIGURE:
116         return 1;
117     case DRV_CONFIGURE:         MessageBoxA(0, "jack audio driver!", "jack driver", MB_OK);     return 1;
118 #endif
119     default:
120         return 0;
121     }
122 }