ReactOS  0.4.14-dev-342-gdc047f9
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 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
_In_ HANDLE Handle
Definition: extypes.h:390
static const WCHAR L[]
Definition: oid.c:1250
MMRESULT CloseKernelSoundDevice(IN HANDLE Handle)
Definition: kernel.c:58
#define SND_TRACE(...)

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  }
109  else if ( IS_MIDI_DEVICE_TYPE(DeviceType) )
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,
131  Capabilities,
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 TRUE
Definition: types.h:120
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT OpenNt4KernelSoundDevice(IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: control.c:22
#define IOCTL_MIDI_GET_CAPABILITIES
Definition: mmdef.h:69
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
smooth NULL
Definition: ftsmooth.c:416
#define SND_ASSERT(condition)
_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:426
#define IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
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
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
MMRESULT CloseKernelSoundDevice(IN HANDLE Handle)
Definition: kernel.c:58
#define IOCTL_WAVE_GET_CAPABILITIES
Definition: mmdef.h:52
#define SND_TRACE(...)

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 
40  SND_ASSERT( Path );
41 
43 }
MMRESULT GetSoundDeviceIdentifier(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
Definition: devicelist.c:328
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
uint16_t * PWSTR
Definition: typedefs.h:54
Definition: arc.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT OpenKernelSoundDeviceByName(IN PWSTR DevicePath, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: kernel.c:23
#define SND_ASSERT(condition)
_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:426
_In_ HANDLE Handle
Definition: extypes.h:390
#define SND_ERR(...)
static const WCHAR L[]
Definition: oid.c:1250
PRTL_UNICODE_STRING_BUFFER Path
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87

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 }
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT OpenNt4KernelSoundDevice(IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: control.c:22
_In_ HANDLE Handle
Definition: extypes.h:390
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
#define SND_TRACE(...)

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 {
160  HANDLE Handle;
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 MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT OpenNt4KernelSoundDevice(IN PSOUND_DEVICE SoundDevice, IN BOOLEAN ReadOnly, OUT PHANDLE Handle)
Definition: control.c:22
smooth NULL
Definition: ftsmooth.c:416
_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:426
_In_ HANDLE Handle
Definition: extypes.h:390
#define IOCTL_WAVE_QUERY_FORMAT
Definition: mmdef.h:50
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SND_ERR(...)
static const WCHAR L[]
Definition: oid.c:1250
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
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT CloseKernelSoundDevice(IN HANDLE Handle)
Definition: kernel.c:58
#define SND_TRACE(...)

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 {
206  HANDLE Handle;
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 MMSUCCESS(result)
Definition: mmebuddy.h:80
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
smooth NULL
Definition: ftsmooth.c:416
_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:426
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
_In_ HANDLE Handle
Definition: extypes.h:390
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define IOCTL_WAVE_SET_FORMAT
Definition: mmdef.h:51
static const WCHAR L[]
Definition: oid.c:1250
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
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
#define SND_TRACE(...)

Referenced by FoundDevice().