xref: /reactos/dll/win32/mmdrv/mme.c (revision 845faec4)
1 /*
2  *
3  * COPYRIGHT:            See COPYING in the top level directory
4  * PROJECT:              ReactOS Multimedia
5  * FILE:                 dll/win32/mmdrv/mme.c
6  * PURPOSE:              Multimedia User Mode Driver (MME Interface)
7  * PROGRAMMER:           Andrew Greenwood
8  *                       Aleksey Bragin
9  * UPDATE HISTORY:
10  *                       Jan 14, 2007: Rewritten and tidied up
11  */
12 
13 #include "mmdrv.h"
14 
15 #define NDEBUG
16 #include <debug.h>
17 
18 /*
19     Sends a message to the client (application), such as WOM_DONE. This
20     is just a wrapper around DriverCallback which translates the
21     parameters appropriately.
22 */
23 
24 BOOL
25 NotifyClient(
26     SessionInfo* session_info,
27     DWORD message,
28     DWORD_PTR parameter1,
29     DWORD_PTR parameter2)
30 {
31     return DriverCallback(session_info->callback,
32                           HIWORD(session_info->flags),
33                           session_info->mme_handle,
34                           message,
35                           session_info->app_user_data,
36                           parameter1,
37                           parameter2);
38 }
39 
40 
41 
42 /*
43     MME Driver Entrypoint
44     Wave Output
45 */
46 
47 DWORD APIENTRY
48 wodMessage(
49     UINT device_id,
50     UINT message,
51     DWORD_PTR private_handle,
52     DWORD_PTR parameter1,
53     DWORD_PTR parameter2)
54 {
55     switch ( message )
56     {
57         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p80.htm */
58         case WODM_GETNUMDEVS :
59             DPRINT("WODM_GETNUMDEVS\n");
60             return GetDeviceCount(WaveOutDevice);
61 
62         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p6h.htm */
63         case WODM_GETDEVCAPS :
64             DPRINT("WODM_GETDEVCAPS\n");
65             return GetDeviceCapabilities(WaveOutDevice,
66                                          device_id,
67                                          parameter1,
68                                          parameter2);
69 
70         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p85.htm */
71         case WODM_OPEN :
72         {
73             WAVEOPENDESC* open_desc = (WAVEOPENDESC*) parameter1;
74             DPRINT("WODM_OPEN\n");
75 
76             if ( parameter2 && WAVE_FORMAT_QUERY )
77                 return QueryWaveFormat(WaveOutDevice, open_desc->lpFormat);
78             else
79                 return OpenDevice(WaveOutDevice,
80                                   device_id,
81                                   open_desc,
82                                   parameter2,
83                                   private_handle);
84         }
85 
86         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p6g.htm */
87         case WODM_CLOSE :
88         {
89             DPRINT("WODM_CLOSE\n");
90             return CloseDevice(private_handle);
91         }
92 
93         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p9w.htm */
94         case WODM_WRITE :
95         {
96             DPRINT("WODM_WRITE\n");
97             return WriteWaveBuffer(private_handle,
98                                    (PWAVEHDR) parameter1,
99                                    parameter2);
100         }
101 
102         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p86.htm */
103         case WODM_PAUSE :
104         {
105             DPRINT("WODM_PAUSE\n");
106             return HandleBySessionThread(private_handle, message, 0);
107         }
108 
109         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p89.htm */
110         case WODM_RESTART :
111         {
112             DPRINT("WODM_RESTART\n");
113             return HandleBySessionThread(private_handle, message, 0);
114         }
115 
116         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p88.htm */
117         case WODM_RESET :
118         {
119             DPRINT("WODM_RESET\n");
120             return HandleBySessionThread(private_handle, message, 0);
121         }
122 
123         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p83.htm */
124 #if 0
125         case WODM_GETPOS :
126         {
127             DPRINT("WODM_GETPOS\n");
128             return GetPosition(private_handle,
129                                (PMMTIME) parameter1,
130                                parameter2);
131         }
132 #endif
133 
134         /* http://www.osronline.com/ddkx/w98ddk/mmedia_4p6f.htm */
135         case WODM_BREAKLOOP :
136         {
137             DPRINT("WODM_BREAKLOOP\n");
138             return HandleBySessionThread(private_handle, message, 0);
139         }
140 
141         /* TODO: Others */
142     }
143 
144     DPRINT("Unsupported message\n");
145     return MMSYSERR_NOTSUPPORTED;
146 }
147