[MMEBUDDY]
[reactos.git] / reactos / lib / drivers / sound / mmebuddy / midi / midMessage.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/midi/midMessage.c
5 *
6 * PURPOSE: Provides the midMessage exported function, as required by
7 * the MME API, for MIDI 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 MIDI input.
23 */
24 DWORD
25 APIENTRY
26 midMessage(
27 UINT DeviceId,
28 UINT Message,
29 DWORD_PTR PrivateHandle,
30 DWORD_PTR Parameter1,
31 DWORD_PTR Parameter2)
32 {
33 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
34
35 AcquireEntrypointMutex(MIDI_IN_DEVICE_TYPE);
36
37 SND_TRACE(L"midMessage - Message type %d\n", Message);
38
39 switch ( Message )
40 {
41 case MIDM_GETNUMDEVS :
42 {
43 Result = GetSoundDeviceCount(MIDI_IN_DEVICE_TYPE);
44 break;
45 }
46
47 case MIDM_GETDEVCAPS :
48 {
49 Result = MmeGetSoundDeviceCapabilities(MIDI_IN_DEVICE_TYPE,
50 DeviceId,
51 (PVOID) Parameter1,
52 Parameter2);
53 break;
54 }
55
56 case DRV_QUERYDEVICEINTERFACESIZE :
57 {
58 Result = MmeGetDeviceInterfaceString(MIDI_IN_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
59 break;
60 }
61
62 case DRV_QUERYDEVICEINTERFACE :
63 {
64 Result = MmeGetDeviceInterfaceString(MIDI_IN_DEVICE_TYPE, DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
65 break;
66 }
67
68 case MIDM_OPEN :
69 {
70 Result = MmeOpenDevice(MIDI_IN_DEVICE_TYPE,
71 DeviceId,
72 (LPWAVEOPENDESC) Parameter1,
73 Parameter2,
74 (DWORD_PTR*) PrivateHandle);
75 break;
76 }
77
78 case MIDM_CLOSE :
79 {
80 Result = MmeCloseDevice(PrivateHandle);
81 break;
82 }
83
84 case MIDM_START :
85 {
86 Result = MmeSetState(PrivateHandle, TRUE);
87 break;
88 }
89
90 case MIDM_STOP :
91 {
92 Result = MmeSetState(PrivateHandle, FALSE);
93 break;
94 }
95 }
96
97 SND_TRACE(L"midMessage returning MMRESULT %d\n", Result);
98
99 ReleaseEntrypointMutex(MIDI_IN_DEVICE_TYPE);
100
101 return Result;
102 }