Sync to trunk r39350.
[reactos.git] / reactos / 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
18 #include <mmebuddy.h>
19
20 #if 0
21 MMRESULT HelloWorld(PSOUND_DEVICE_INSTANCE Instance, PVOID String)
22 {
23 PWSTR WString = (PWSTR) String;
24 SND_TRACE(WString);
25 return MMSYSERR_NOTSUPPORTED;
26 }
27 #endif
28
29 /*
30 Standard MME driver entry-point for messages relating to wave audio
31 output.
32 */
33 APIENTRY DWORD
34 wodMessage(
35 DWORD DeviceId,
36 DWORD Message,
37 DWORD PrivateHandle,
38 DWORD Parameter1,
39 DWORD Parameter2)
40 {
41 MMRESULT Result = MMSYSERR_NOTSUPPORTED;
42
43 AcquireEntrypointMutex(WAVE_OUT_DEVICE_TYPE);
44
45 SND_TRACE(L"wodMessage - Message type %d\n", Message);
46
47 switch ( Message )
48 {
49 case WODM_GETNUMDEVS :
50 {
51 Result = GetSoundDeviceCount(WAVE_OUT_DEVICE_TYPE);
52 break;
53 }
54
55 case WODM_GETDEVCAPS :
56 {
57 Result = MmeGetSoundDeviceCapabilities(WAVE_OUT_DEVICE_TYPE,
58 DeviceId,
59 (PVOID) Parameter1,
60 Parameter2);
61 break;
62 }
63
64 case WODM_OPEN :
65 {
66 Result = MmeOpenWaveDevice(WAVE_OUT_DEVICE_TYPE,
67 DeviceId,
68 (LPWAVEOPENDESC) Parameter1,
69 Parameter2,
70 (DWORD*) PrivateHandle);
71 break;
72 }
73
74 case WODM_CLOSE :
75 {
76 Result = MmeCloseDevice(PrivateHandle);
77
78 break;
79 }
80
81 case WODM_PREPARE :
82 {
83 /* TODO: Do we need to pass 2nd parameter? */
84 Result = MmePrepareWaveHeader(PrivateHandle, Parameter1);
85 break;
86 }
87
88 case WODM_UNPREPARE :
89 {
90 Result = MmeUnprepareWaveHeader(PrivateHandle, Parameter1);
91 break;
92 }
93
94 case WODM_WRITE :
95 {
96 Result = MmeSubmitWaveHeader(PrivateHandle, Parameter1);
97 break;
98 }
99
100 case WODM_GETPOS :
101 {
102 #if 0
103 /* Hacky code to test the threading */
104 PSOUND_DEVICE_INSTANCE Instance = (PSOUND_DEVICE_INSTANCE)PrivateHandle;
105 CallSoundThread(Instance->Thread, HelloWorld, Instance, L"Hello World!");
106 CallSoundThread(Instance->Thread, HelloWorld, Instance, L"Hello Universe!");
107 #endif
108 break;
109 }
110 }
111
112 SND_TRACE(L"wodMessage returning MMRESULT %d\n", Result);
113
114 ReleaseEntrypointMutex(WAVE_OUT_DEVICE_TYPE);
115
116 return Result;
117 }