mciqtz32: Implement driver messages.
[wine/hacks.git] / dlls / mciqtz32 / mciqtz.c
blob786105a50198018e18e8bc096851611f9fa33441
1 /*
2 * DirectShow MCI Driver
4 * Copyright 2009 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "mmddk.h"
26 #include "wine/debug.h"
27 #include "mciqtz_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(mciqtz);
31 static DWORD MCIQTZ_mciClose(UINT, DWORD, LPMCI_GENERIC_PARMS);
32 static DWORD MCIQTZ_mciStop(UINT, DWORD, LPMCI_GENERIC_PARMS);
34 /*======================================================================*
35 * MCI QTZ implementation *
36 *======================================================================*/
38 HINSTANCE MCIQTZ_hInstance = 0;
40 /***********************************************************************
41 * DllMain (MCIQTZ.0)
43 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
45 switch (fdwReason) {
46 case DLL_PROCESS_ATTACH:
47 DisableThreadLibraryCalls(hInstDLL);
48 MCIQTZ_hInstance = hInstDLL;
49 break;
51 return TRUE;
54 /**************************************************************************
55 * MCIQTZ_drvOpen [internal]
57 static DWORD MCIQTZ_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
59 WINE_MCIQTZ* wma;
61 TRACE("%s, %p\n", debugstr_w(str), modp);
63 /* session instance */
64 if (!modp)
65 return 0xFFFFFFFF;
67 wma = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIQTZ));
68 if (!wma)
69 return 0;
71 wma->wDevID = modp->wDeviceID;
72 mciSetDriverData(wma->wDevID, (DWORD_PTR)wma);
74 return modp->wDeviceID;
77 /**************************************************************************
78 * MCIQTZ_drvClose [internal]
80 static DWORD MCIQTZ_drvClose(DWORD dwDevID)
82 WINE_MCIQTZ* wma;
84 TRACE("%04x\n", dwDevID);
86 /* finish all outstanding things */
87 MCIQTZ_mciClose(dwDevID, MCI_WAIT, NULL);
89 wma = (WINE_MCIQTZ*)mciGetDriverData(dwDevID);
91 if (wma) {
92 HeapFree(GetProcessHeap(), 0, wma);
93 return 1;
96 return (dwDevID == 0xFFFFFFFF) ? 1 : 0;
99 /**************************************************************************
100 * MCIQTZ_drvConfigure [internal]
102 static DWORD MCIQTZ_drvConfigure(DWORD dwDevID)
104 WINE_MCIQTZ* wma;
106 TRACE("%04x\n", dwDevID);
108 MCIQTZ_mciStop(dwDevID, MCI_WAIT, NULL);
110 wma = (WINE_MCIQTZ*)mciGetDriverData(dwDevID);
112 if (wma) {
113 MessageBoxA(0, "Sample QTZ Wine Driver !", "MM-Wine Driver", MB_OK);
114 return 1;
117 return 0;
120 /**************************************************************************
121 * MCIQTZ_mciGetOpenDev [internal]
123 static WINE_MCIQTZ* MCIQTZ_mciGetOpenDev(UINT wDevID)
125 WINE_MCIQTZ* wma = (WINE_MCIQTZ*)mciGetDriverData(wDevID);
127 if (!wma) {
128 WARN("Invalid wDevID=%u\n", wDevID);
129 return 0;
131 return wma;
134 /***************************************************************************
135 * MCIQTZ_mciClose [internal]
137 static DWORD MCIQTZ_mciClose(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
139 WINE_MCIQTZ* wma;
141 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
143 MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL);
145 wma = MCIQTZ_mciGetOpenDev(wDevID);
146 if (!wma)
147 return MCIERR_INVALID_DEVICE_ID;
149 return 0;
152 /***************************************************************************
153 * MCIQTZ_mciStop [internal]
155 static DWORD MCIQTZ_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
157 WINE_MCIQTZ* wma;
159 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
161 wma = MCIQTZ_mciGetOpenDev(wDevID);
162 if (!wma)
163 return MCIERR_INVALID_DEVICE_ID;
165 return 0;
168 /*======================================================================*
169 * MCI QTZ entry points *
170 *======================================================================*/
172 /**************************************************************************
173 * DriverProc (MCIQTZ.@)
175 LRESULT CALLBACK MCIQTZ_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
176 LPARAM dwParam1, LPARAM dwParam2)
178 TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
179 dwDevID, hDriv, wMsg, dwParam1, dwParam2);
181 switch (wMsg) {
182 case DRV_LOAD: return 1;
183 case DRV_FREE: return 1;
184 case DRV_OPEN: return MCIQTZ_drvOpen((LPCWSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSW)dwParam2);
185 case DRV_CLOSE: return MCIQTZ_drvClose(dwDevID);
186 case DRV_ENABLE: return 1;
187 case DRV_DISABLE: return 1;
188 case DRV_QUERYCONFIGURE: return 1;
189 case DRV_CONFIGURE: return MCIQTZ_drvConfigure(dwDevID);
190 case DRV_INSTALL: return DRVCNF_RESTART;
191 case DRV_REMOVE: return DRVCNF_RESTART;
194 /* session instance */
195 if (dwDevID == 0xFFFFFFFF)
196 return 1;
198 FIXME("Unsupported command [%u]\n", wMsg);
200 return MCIERR_UNRECOGNIZED_COMMAND;