gdi32: Use exec() and _exit() instead of system() and exit().
[wine/hacks.git] / dlls / winejack.drv / jack.c
blob65a193454d938ca96875662a6015ff7f0e6a8333
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3 * Wine Driver for jack Sound Server
4 * http://jackit.sourceforge.net
6 * Copyright 2002 Chris Morgan
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.
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.
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
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdarg.h>
27 #include <stdio.h>
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"
38 WINE_DEFAULT_DEBUG_CHANNEL(jack);
40 #ifdef HAVE_JACK_JACK_H
42 #ifndef SONAME_LIBJACK
43 #define SONAME_LIBJACK "libjack.so"
44 #endif
46 void *jackhandle = NULL;
48 /**************************************************************************
49 * JACK_drvLoad [internal]
51 static LRESULT JACK_drvLoad(void)
53 TRACE("()\n");
55 /* dynamically load the jack library if not already loaded */
56 if(!jackhandle)
58 jackhandle = wine_dlopen(SONAME_LIBJACK, RTLD_NOW, NULL, 0);
59 TRACE("SONAME_LIBJACK == %s\n", SONAME_LIBJACK);
60 TRACE("jackhandle == %p\n", jackhandle);
61 if(!jackhandle)
63 FIXME("error loading the jack library %s, please install this library to use jack\n", SONAME_LIBJACK);
64 jackhandle = (void*)-1;
65 return 0;
69 return JACK_WaveInit();
72 /**************************************************************************
73 * JACK_drvFree [internal]
75 /* unload the jack library on driver free */
76 static LRESULT JACK_drvFree(void)
78 TRACE("()\n");
80 if(jackhandle && (jackhandle != (void*)-1))
82 JACK_WaveRelease();
84 TRACE("calling wine_dlclose() on jackhandle\n");
85 wine_dlclose(jackhandle, NULL, 0);
86 jackhandle = NULL;
89 return 1;
92 /**************************************************************************
93 * JACK_drvOpen [internal]
95 static LRESULT JACK_drvOpen(LPSTR str)
97 TRACE("(%s)\n", str);
98 /* if we were unable to load the jack library then fail the */
99 /* driver open */
100 if(!jackhandle)
102 FIXME("unable to open the jack library, returning 0\n");
103 return 0;
106 return 1;
109 /**************************************************************************
110 * JACK_drvClose [internal]
112 static LRESULT JACK_drvClose(DWORD_PTR dwDevID)
114 TRACE("(%08lx)\n", dwDevID);
115 return 1;
117 #endif /* #ifdef HAVE_JACK_JACK_H */
120 /**************************************************************************
121 * DriverProc (WINEJACK.1)
123 LRESULT CALLBACK JACK_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
124 LPARAM dwParam1, LPARAM dwParam2)
126 TRACE("(%08lX, %p, %s (%08X), %08lX, %08lX)\n",
127 dwDevID, hDriv, wMsg == DRV_LOAD ? "DRV_LOAD" :
128 wMsg == DRV_FREE ? "DRV_FREE" :
129 wMsg == DRV_OPEN ? "DRV_OPEN" :
130 wMsg == DRV_CLOSE ? "DRV_CLOSE" :
131 wMsg == DRV_ENABLE ? "DRV_ENABLE" :
132 wMsg == DRV_DISABLE ? "DRV_DISABLE" :
133 wMsg == DRV_QUERYCONFIGURE ? "DRV_QUERYCONFIGURE" :
134 wMsg == DRV_CONFIGURE ? "DRV_CONFIGURE" :
135 wMsg == DRV_INSTALL ? "DRV_INSTALL" :
136 wMsg == DRV_REMOVE ? "DRV_REMOVE" : "UNKNOWN",
137 wMsg, dwParam1, dwParam2);
139 switch(wMsg) {
140 #ifdef HAVE_JACK_JACK_H
141 case DRV_LOAD: return JACK_drvLoad();
142 case DRV_FREE: return JACK_drvFree();
143 case DRV_OPEN: return JACK_drvOpen((LPSTR)dwParam1);
144 case DRV_CLOSE: return JACK_drvClose(dwDevID);
145 case DRV_ENABLE: return 1;
146 case DRV_DISABLE: return 1;
147 case DRV_QUERYCONFIGURE: return 1;
148 case DRV_CONFIGURE: MessageBoxA(0, "jack audio driver!", "jack driver", MB_OK); return 1;
149 case DRV_INSTALL: return DRVCNF_RESTART;
150 case DRV_REMOVE: return DRVCNF_RESTART;
151 #endif
152 default:
153 return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);