de9e353fadc63c643b8c8b234c63cdd6a0d132b9
[reactos.git] / reactos / lib / drivers / sound / mmebuddy / wave / widMessage.c
1 /*
2 * PROJECT: ReactOS Sound System "MME Buddy" Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/sound/mmebuddy/wave/widMessage.c
5 *
6 * PURPOSE: Provides the widMessage exported function, as required by
7 * the MME API, for wave input 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 /*
22 Standard MME driver entry-point for messages relating to wave audio
23 input.
24 */
25 DWORD
26 APIENTRY
27 widMessage(
28 DWORD DeviceId,
29 DWORD Message,
30 DWORD PrivateHandle,
31 DWORD Parameter1,
32 DWORD Parameter2)
33 {
34 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
35
36 AcquireEntrypointMutex(WAVE_IN_DEVICE_TYPE);
37
38 SND_TRACE(L"widMessage - Message type %d\n", Message);
39
40 switch ( Message )
41 {
42 case WIDM_GETNUMDEVS :
43 {
44 Result = GetSoundDeviceCount(WAVE_IN_DEVICE_TYPE);
45 break;
46 }
47
48 case WIDM_START :
49 {
50 Result = MmeSetState(PrivateHandle, TRUE);
51 break;
52 }
53
54 case WIDM_STOP :
55 {
56 Result = MmeSetState(PrivateHandle, FALSE);
57 break;
58 }
59
60 case WIDM_GETDEVCAPS :
61 {
62
63 Result = MmeGetSoundDeviceCapabilities(WAVE_IN_DEVICE_TYPE,
64 DeviceId,
65 (PVOID) Parameter1,
66 Parameter2);
67 break;
68 }
69 case WIDM_OPEN :
70 {
71 Result = MmeOpenWaveDevice(WAVE_IN_DEVICE_TYPE,
72 DeviceId,
73 (LPWAVEOPENDESC) Parameter1,
74 Parameter2,
75 (DWORD*) PrivateHandle);
76 break;
77 }
78
79 case WIDM_CLOSE :
80 {
81 Result = MmeCloseDevice(PrivateHandle);
82
83 break;
84 }
85
86 case WIDM_PREPARE :
87 {
88 /* TODO: Do we need to pass 2nd parameter? */
89 Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
90 break;
91 }
92
93 case WIDM_UNPREPARE :
94 {
95 Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
96 break;
97 }
98
99 case WIDM_RESET :
100 {
101 /* Stop playback, reset position to zero */
102 Result = MmeResetWavePlayback(PrivateHandle);
103 break;
104 }
105
106 case WIDM_ADDBUFFER :
107 {
108 Result = MmeWriteWaveHeader(PrivateHandle, Parameter1);
109 break;
110 }
111
112 }
113
114 SND_TRACE(L"widMessage returning MMRESULT %d\n", Result);
115
116 ReleaseEntrypointMutex(WAVE_IN_DEVICE_TYPE);
117
118 return Result;
119 }