ReactOS 0.4.15-dev-7906-g1b85a5f
control.c File Reference
#include "precomp.h"
#include <winioctl.h>
#include <ntddsnd.h>
#include <mmebuddy_debug.h>
Include dependency graph for control.c:

Go to the source code of this file.

Functions

MMRESULT OpenNt4KernelSoundDevice (IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
 
MMRESULT OpenNt4SoundDevice (IN PSOUND_DEVICE SoundDevice, OUT PVOID *Handle)
 
MMRESULT CloseNt4SoundDevice (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Handle)
 
MMRESULT GetNt4SoundDeviceCapabilities (IN PSOUND_DEVICE SoundDevice, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
 
MMRESULT QueryNt4WaveDeviceFormatSupport (IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
 
MMRESULT SetNt4WaveDeviceFormat (IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
 

Function Documentation

◆ CloseNt4SoundDevice()

MMRESULT CloseNt4SoundDevice ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN PVOID  Handle 
)

Definition at line 65 of file control.c.

68{
69 SND_TRACE(L"Closing NT4 style sound device\n");
70
73}
ULONG Handle
Definition: gdb_input.c:15
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT CloseKernelSoundDevice(IN HANDLE Handle)
Definition: kernel.c:58
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define SND_TRACE(...)
#define L(x)
Definition: ntvdm.h:50

Referenced by FoundDevice().

◆ GetNt4SoundDeviceCapabilities()

MMRESULT GetNt4SoundDeviceCapabilities ( IN PSOUND_DEVICE  SoundDevice,
OUT PVOID  Capabilities,
IN DWORD  CapabilitiesSize 
)

Definition at line 80 of file control.c.

84{
87 DWORD IoCtl;
89
90 /* If these are bad there's an internal error with MME-Buddy! */
91 SND_ASSERT( SoundDevice );
93 SND_ASSERT( CapabilitiesSize > 0 );
94
95 SND_TRACE(L"NT4 get-capabilities routine called\n");
96
97 /* Get the device type */
98 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
100
101 if ( ! MMSUCCESS(Result) )
103
104 /* Choose the appropriate IOCTL */
106 {
108 }
110 {
112 }
113 else
114 {
115 /* FIXME - need to support AUX and mixer devices */
116 SND_ASSERT( FALSE );
117 IoCtl = 0;
118 }
119
120 /* Get the capabilities information from the driver */
122
123 if ( ! MMSUCCESS(Result) )
124 {
125 SND_ERR(L"Failed to open device");
127 }
128
130 IoCtl,
132 CapabilitiesSize,
133 NULL,
134 0,
135 NULL);
136
138
139 if ( ! MMSUCCESS(Result) )
140 {
141 SND_ERR(L"Retrieval of capabilities information failed\n");
143 }
144
145 return Result;
146}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD SyncOverlappedDeviceIoControl(IN HANDLE Handle, IN DWORD IoControlCode, IN LPVOID InBuffer, IN DWORD InBufferSize, OUT LPVOID OutBuffer, IN DWORD OutBufferSize, OUT LPDWORD BytesTransferred OPTIONAL)
Definition: misc.c:298
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define IOCTL_WAVE_GET_CAPABILITIES
Definition: mmdef.h:52
#define IOCTL_MIDI_GET_CAPABILITIES
Definition: mmdef.h:69
DeviceType
Definition: mmdrv.h:42
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_ERR(...)
#define SND_ASSERT(condition)
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
MMRESULT OpenNt4KernelSoundDevice(IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: control.c:22
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by GetSoundBlasterDeviceCapabilities().

◆ OpenNt4KernelSoundDevice()

MMRESULT OpenNt4KernelSoundDevice ( IN PSOUND_DEVICE  SoundDevice,
IN BOOLEAN  ReadOnly,
OUT PHANDLE  Handle 
)

Definition at line 22 of file control.c.

26{
27 PWSTR Path;
29
32
33 Result = GetSoundDeviceIdentifier(SoundDevice, (PVOID*) &Path);
34 if ( ! MMSUCCESS(Result) )
35 {
36 SND_ERR(L"Unable to get sound device path");
38 }
39
41
43}
PRTL_UNICODE_STRING_BUFFER Path
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT OpenKernelSoundDeviceByName(IN PWSTR DevicePath, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: kernel.c:23
MMRESULT GetSoundDeviceIdentifier(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
Definition: devicelist.c:328
@ ReadOnly
Definition: arc.h:80
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by GetNt4SoundDeviceCapabilities(), OpenNt4SoundDevice(), and QueryNt4WaveDeviceFormatSupport().

◆ OpenNt4SoundDevice()

MMRESULT OpenNt4SoundDevice ( IN PSOUND_DEVICE  SoundDevice,
OUT PVOID Handle 
)

Definition at line 52 of file control.c.

55{
56 SND_TRACE(L"Opening NT4 style sound device\n");
57
60
61 return OpenNt4KernelSoundDevice(SoundDevice, FALSE, Handle);
62}

Referenced by FoundDevice().

◆ QueryNt4WaveDeviceFormatSupport()

MMRESULT QueryNt4WaveDeviceFormatSupport ( IN PSOUND_DEVICE  SoundDevice,
IN LPWAVEFORMATEX  Format,
IN DWORD  FormatSize 
)

Definition at line 154 of file control.c.

158{
161
162 SND_TRACE(L"NT4 wave format support querying routine called\n");
163
166 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
167
168 /* Get the device path */
169 Result = OpenNt4KernelSoundDevice(SoundDevice,
170 FALSE,
171 &Handle);
172
173 if ( ! MMSUCCESS(Result) )
174 {
175 SND_ERR(L"Unable to open kernel sound device\n");
177 }
178
181 (LPVOID) Format,
182 FormatSize,
183 NULL,
184 0,
185 NULL);
186
187 if ( ! MMSUCCESS(Result) )
188 {
189 SND_ERR(L"Sync overlapped I/O failed - MMSYS_ERROR %d\n", Result);
191 }
192
194
195 return MMSYSERR_NOERROR;
196}
#define IOCTL_WAVE_QUERY_FORMAT
Definition: mmdef.h:50

Referenced by FoundDevice().

◆ SetNt4WaveDeviceFormat()

MMRESULT SetNt4WaveDeviceFormat ( IN PSOUND_DEVICE_INSTANCE  SoundDeviceInstance,
IN DWORD  DeviceId,
IN LPWAVEFORMATEX  Format,
IN DWORD  FormatSize 
)

Definition at line 199 of file control.c.

204{
207
210 VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
211
212 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
213
214 if ( ! MMSUCCESS(Result) )
216
217 SND_TRACE(L"Setting wave device format on handle %x\n", Handle);
218
221 (LPVOID) Format,
222 FormatSize,
223 NULL,
224 0,
225 NULL);
226
227 if ( ! MMSUCCESS(Result) )
229
230 return MMSYSERR_NOERROR;
231}
#define IOCTL_WAVE_SET_FORMAT
Definition: mmdef.h:51
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)

Referenced by FoundDevice().