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/modMessage.c
5  *
6  * PURPOSE:     Provides the modMessage exported function, as required by
7  *              the MME API, for MIDI output device support.
8  *
9  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
10 */
11 
12 #include "precomp.h"
13 
14 /*
15     Standard MME driver entry-point for messages relating to MIDI output.
16 */
17 DWORD
18 APIENTRY
modMessage(UINT DeviceId,UINT Message,DWORD_PTR PrivateHandle,DWORD_PTR Parameter1,DWORD_PTR Parameter2)19 modMessage(
20     UINT DeviceId,
21     UINT Message,
22     DWORD_PTR PrivateHandle,
23     DWORD_PTR Parameter1,
24     DWORD_PTR Parameter2)
25 {
26     MMRESULT Result = MMSYSERR_NOTSUPPORTED;
27 
28     AcquireEntrypointMutex(MIDI_OUT_DEVICE_TYPE);
29 
30     SND_TRACE(L"modMessage - Message type %d\n", Message);
31 
32     switch ( Message )
33     {
34         case MODM_GETNUMDEVS :
35         {
36             Result = GetSoundDeviceCount(MIDI_OUT_DEVICE_TYPE);
37             break;
38         }
39 
40         case MODM_GETDEVCAPS :
41         {
42             Result = MmeGetSoundDeviceCapabilities(MIDI_OUT_DEVICE_TYPE,
43                                                    DeviceId,
44                                                    (PVOID) Parameter1,
45                                                    Parameter2);
46             break;
47         }
48 
49         case DRV_QUERYDEVICEINTERFACESIZE :
50         {
51             Result = MmeGetDeviceInterfaceString(MIDI_OUT_DEVICE_TYPE, DeviceId, NULL, 0, (DWORD*)Parameter1); //FIXME DWORD_PTR
52             break;
53         }
54 
55         case DRV_QUERYDEVICEINTERFACE :
56         {
57             Result = MmeGetDeviceInterfaceString(MIDI_OUT_DEVICE_TYPE, DeviceId, (LPWSTR)Parameter1, Parameter2, NULL); //FIXME DWORD_PTR
58             break;
59         }
60 
61         case MODM_OPEN :
62         {
63             Result = MmeOpenDevice(MIDI_OUT_DEVICE_TYPE,
64                                    DeviceId,
65                                    (LPWAVEOPENDESC) Parameter1, /* unused */
66                                    Parameter2,
67                                    (DWORD_PTR*)PrivateHandle);
68             break;
69         }
70 
71         case MODM_CLOSE :
72         {
73             Result = MmeCloseDevice(PrivateHandle);
74 
75             break;
76         }
77 
78         case MODM_GETVOLUME:
79         {
80             Result = MmeGetVolume(MIDI_OUT_DEVICE_TYPE,
81                                   DeviceId,
82                                   PrivateHandle,
83                                   Parameter1);
84             break;
85         }
86 
87         case MODM_SETVOLUME:
88         {
89             Result = MmeSetVolume(MIDI_OUT_DEVICE_TYPE,
90                                   DeviceId,
91                                   PrivateHandle,
92                                   Parameter1);
93             break;
94         }
95     }
96 
97     SND_TRACE(L"modMessage returning MMRESULT %d\n", Result);
98 
99     ReleaseEntrypointMutex(MIDI_OUT_DEVICE_TYPE);
100 
101     return Result;
102 }
103