[CMAKE]
[reactos.git] / lib / drivers / sound / mmebuddy / wave / wodMessage.c
1 /*
2 * PROJECT: ReactOS Sound System "MME Buddy" Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/drivers/sound/mmebuddy/wave/wodMessage.c
5 *
6 * PURPOSE: Provides the wodMessage exported function, as required by
7 * the MME API, for wave output device support.
8 *
9 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
10 */
11
12 #include <windows.h>
13 #include <mmsystem.h>
14 #include <mmddk.h>
15
16 #include <ntddsnd.h>
17 #include <sndtypes.h>
18
19 #include <mmebuddy.h>
20
21 #if 0
22 MMRESULT HelloWorld(PSOUND_DEVICE_INSTANCE Instance, PVOID String)
23 {
24 PWSTR WString = (PWSTR) String;
25 SND_TRACE(WString);
26 return MMSYSERR_NOTSUPPORTED;
27 }
28 #endif
29
30 /*
31 Standard MME driver entry-point for messages relating to wave audio
32 output.
33 */
34 DWORD
35 APIENTRY
36 wodMessage(
37 UINT DeviceId,
38 UINT Message,
39 DWORD_PTR PrivateHandle,
40 DWORD_PTR Parameter1,
41 DWORD_PTR Parameter2)
42 {
43 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
44
45 AcquireEntrypointMutex(WAVE_OUT_DEVICE_TYPE);
46
47 SND_TRACE(L"wodMessage - Message type %d\n", Message);
48
49 switch ( Message )
50 {
51 case WODM_GETNUMDEVS :
52 {
53 Result = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
54 break;
55 }
56
57 case WODM_GETDEVCAPS :
58 {
59 Result = MmeGetSoundDeviceCapabilities(WAVE_OUT_DEVICE_TYPE,
60 DeviceId,
61 (PVOID) Parameter1,
62 Parameter2);
63 break;
64 }
65
66 case WODM_OPEN :
67 {
68 Result = MmeOpenDevice(WAVE_OUT_DEVICE_TYPE,
69 DeviceId,
70 (LPWAVEOPENDESC) Parameter1,
71 Parameter2,
72 (DWORD_PTR*)PrivateHandle);
73 break;
74 }
75
76 case WODM_CLOSE :
77 {
78 Result = MmeCloseDevice(PrivateHandle);
79
80 break;
81 }
82
83 case WODM_PREPARE :
84 {
85 /* TODO: Do we need to pass 2nd parameter? */
86 Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
87 break;
88 }
89
90 case WODM_UNPREPARE :
91 {
92 Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
93 break;
94 }
95
96 case WODM_WRITE :
97 {
98 Result = MmeWriteWaveHeader(PrivateHandle, Parameter1);
99 break;
100 }
101
102 case WODM_RESET :
103 {
104 /* Stop playback, reset position to zero */
105 Result = MmeResetWavePlayback(PrivateHandle);
106 break;
107 }
108
109 case WODM_RESTART :
110 {
111 /* Continue playback when paused */
112 break;
113 }
114
115 case WODM_GETPOS :
116 {
117 Result = MmeGetPosition(WAVE_OUT_DEVICE_TYPE, DeviceId, PrivateHandle, (MMTIME*)Parameter1, Parameter2);
118 break;
119 }
120
121 case DRV_QUERYDEVICEINTERFACESIZE :
122 {
123 Result = MmeGetDeviceInterfaceString(WAVE_OUT_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
124 break;
125 }
126
127 case DRV_QUERYDEVICEINTERFACE :
128 {
129 Result = MmeGetDeviceInterfaceString(WAVE_OUT_DEVICE_TYPE, DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
130 break;
131 }
132 }
133
134 SND_TRACE(L"wodMessage returning MMRESULT %d\n", Result);
135
136 ReleaseEntrypointMutex(WAVE_OUT_DEVICE_TYPE);
137
138 return Result;
139 }