d364297aa0bececa30d1b217db7394c82e9b47e7
[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_GETDEVCAPS :
49 {
50 Result = MmeGetSoundDeviceCapabilities(WAVE_IN_DEVICE_TYPE,
51 DeviceId,
52 (PVOID) Parameter1,
53 Parameter2);
54 break;
55 }
56 case WIDM_OPEN :
57 {
58 Result = MmeOpenWaveDevice(WAVE_IN_DEVICE_TYPE,
59 DeviceId,
60 (LPWAVEOPENDESC) Parameter1,
61 Parameter2,
62 (DWORD*) PrivateHandle);
63 break;
64 }
65
66 case WIDM_CLOSE :
67 {
68 Result = MmeCloseDevice(PrivateHandle);
69
70 break;
71 }
72
73 case WIDM_PREPARE :
74 {
75 /* TODO: Do we need to pass 2nd parameter? */
76 Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
77 break;
78 }
79
80 case WIDM_UNPREPARE :
81 {
82 Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
83 break;
84 }
85
86 case WIDM_RESET :
87 {
88 /* Stop playback, reset position to zero */
89 Result = MmeResetWavePlayback(PrivateHandle);
90 break;
91 }
92 }
93
94 SND_TRACE(L"widMessage returning MMRESULT %d\n", Result);
95
96 ReleaseEntrypointMutex(WAVE_IN_DEVICE_TYPE);
97
98 return Result;
99 }