ReactOS  0.4.15-dev-1177-g6cb3b62
mmixer.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Sound System
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/wdmaud.drv/mmixer.c
5  *
6  * PURPOSE: WDM Audio Mixer API (User-mode part)
7  * PROGRAMMERS: Johannes Anderwald
8  */
9 
10 #include "wdmaud.h"
11 
12 #include <winreg.h>
13 #include <setupapi.h>
14 #include <mmixer.h>
15 #define NTOS_MODE_USER
16 #include <ndk/rtlfuncs.h>
17 #include <ndk/iofuncs.h>
18 
19 #define NDEBUG
20 #include <debug.h>
21 #include <mmebuddy_debug.h>
22 
23 
25 
26 
27 
28 PVOID Alloc(ULONG NumBytes);
29 MIXER_STATUS Close(HANDLE hDevice);
30 VOID Free(PVOID Block);
31 VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes);
32 MIXER_STATUS Open(IN LPWSTR DevicePath, OUT PHANDLE hDevice);
33 MIXER_STATUS Control(IN HANDLE hMixer, IN ULONG dwIoControlCode, IN PVOID lpInBuffer, IN ULONG nInBufferSize, OUT PVOID lpOutBuffer, ULONG nOutBufferSize, PULONG lpBytesReturned);
34 MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR * DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey);
38 PVOID AllocEventData(IN ULONG ExtraSize);
39 VOID FreeEventData(IN PVOID EventData);
40 
42 {
43  sizeof(MIXER_CONTEXT),
44  NULL,
45  Alloc,
46  Control,
47  Free,
48  Open,
49  Close,
50  Copy,
51  OpenKey,
53  CloseKey,
56 };
57 
59 
62  IN HANDLE hKey,
66  OUT PULONG KeyType)
67 {
70 
72  if (*ResultBuffer == NULL)
73  return MM_STATUS_NO_MEMORY;
74 
76  {
79  }
80  return MM_STATUS_SUCCESS;
81 }
82 
85  IN HANDLE hKey,
86  IN LPWSTR SubKey,
88  OUT PHANDLE OutKey)
89 {
90  if (RegOpenKeyExW((HKEY)hKey, SubKey, 0, DesiredAccess, (PHKEY)OutKey) == ERROR_SUCCESS)
91  return MM_STATUS_SUCCESS;
92 
94 }
95 
98  IN HANDLE hKey)
99 {
100  RegCloseKey((HKEY)hKey);
101  return MM_STATUS_SUCCESS;
102 }
103 
104 
105 PVOID Alloc(ULONG NumBytes)
106 {
107  return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
108 }
109 
111 Close(HANDLE hDevice)
112 {
113  if (CloseHandle(hDevice))
114  return MM_STATUS_SUCCESS;
115  else
116  return MM_STATUS_UNSUCCESSFUL;
117 }
118 
119 VOID
120 Free(PVOID Block)
121 {
122  HeapFree(GetProcessHeap(), 0, Block);
123 }
124 
125 VOID
126 Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
127 {
128  RtlMoveMemory(Src, Dst, NumBytes);
129 }
130 
133  IN LPWSTR DevicePath,
134  OUT PHANDLE hDevice)
135 {
136  DevicePath[1] = L'\\';
137  *hDevice = CreateFileW(DevicePath,
139  0,
140  NULL,
143  NULL);
144  if (*hDevice == INVALID_HANDLE_VALUE)
145  {
146  return MM_STATUS_UNSUCCESSFUL;
147  }
148 
149  return MM_STATUS_SUCCESS;
150 }
151 
154  IN HANDLE hMixer,
156  IN PVOID lpInBuffer,
157  IN ULONG nInBufferSize,
158  OUT PVOID lpOutBuffer,
159  ULONG nOutBufferSize,
161 {
162  OVERLAPPED Overlapped;
163  BOOLEAN IoResult;
164  DWORD Transferred = 0;
165 
166  /* Overlapped I/O is done here - this is used for waiting for completion */
167  ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
168  Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
169 
170  if ( ! Overlapped.hEvent )
171  return MM_STATUS_NO_MEMORY;
172 
173  /* Talk to the device */
174  IoResult = DeviceIoControl(hMixer,
176  lpInBuffer,
177  nInBufferSize,
178  lpOutBuffer,
179  nOutBufferSize,
180  &Transferred,
181  &Overlapped);
182 
183  /* If failure occurs, make sure it's not just due to the overlapped I/O */
184  if ( ! IoResult )
185  {
186  if ( GetLastError() != ERROR_IO_PENDING )
187  {
188  CloseHandle(Overlapped.hEvent);
189 
191  {
192  if ( lpBytesReturned )
193  *lpBytesReturned = Transferred;
194  return MM_STATUS_MORE_ENTRIES;
195  }
196 
197  return MM_STATUS_UNSUCCESSFUL;
198  }
199  }
200 
201  /* Wait for the I/O to complete */
202  IoResult = GetOverlappedResult(hMixer,
203  &Overlapped,
204  &Transferred,
205  TRUE);
206 
207  /* Don't need this any more */
208  CloseHandle(Overlapped.hEvent);
209 
210  if ( ! IoResult )
211  return MM_STATUS_UNSUCCESSFUL;
212 
213  if ( lpBytesReturned )
214  *lpBytesReturned = Transferred;
215 
216  return MM_STATUS_SUCCESS;
217 }
218 
221  IN PVOID EnumContext,
222  IN ULONG DeviceIndex,
224  OUT PHANDLE OutHandle,
225  OUT PHANDLE OutKey)
226 {
230  BOOL Result;
231  DWORD Length;
233 
234  //printf("Enum EnumContext %p DeviceIndex %lu OutHandle %p\n", EnumContext, DeviceIndex, OutHandle);
235 
236  InterfaceData.cbSize = sizeof(InterfaceData);
237  InterfaceData.Reserved = 0;
238 
239  Result = SetupDiEnumDeviceInterfaces(EnumContext,
240  NULL,
241  &CategoryGuid,
242  DeviceIndex,
243  &InterfaceData);
244 
245  if (!Result)
246  {
248  {
250  }
251  return MM_STATUS_UNSUCCESSFUL;
252  }
253 
256  0,
257  Length);
258  DetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
259  DeviceData.cbSize = sizeof(DeviceData);
260  DeviceData.Reserved = 0;
261 
263  &InterfaceData,
264  DetailData,
265  Length,
266  NULL,
267  &DeviceData);
268 
269  if (!Result)
270  {
271  DPRINT("SetupDiGetDeviceInterfaceDetailW failed with %lu\n", GetLastError());
272  return MM_STATUS_UNSUCCESSFUL;
273  }
274 
275 
276  *OutKey = SetupDiOpenDeviceInterfaceRegKey(EnumContext, &InterfaceData, 0, KEY_READ);
277  if ((HKEY)*OutKey == INVALID_HANDLE_VALUE)
278  {
279  HeapFree(GetProcessHeap(), 0, DetailData);
280  return MM_STATUS_UNSUCCESSFUL;
281  }
282 
283  Status = Open(DetailData->DevicePath, OutHandle);
284 
285  if (Status != MM_STATUS_SUCCESS)
286  {
287  RegCloseKey((HKEY)*OutKey);
288  HeapFree(GetProcessHeap(), 0, DetailData);
289  return Status;
290  }
291 
292  *DeviceName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(DetailData->DevicePath)+1) * sizeof(WCHAR));
293  if (*DeviceName == NULL)
294  {
295  CloseHandle(*OutHandle);
296  RegCloseKey((HKEY)*OutKey);
297  HeapFree(GetProcessHeap(), 0, DetailData);
298  return MM_STATUS_NO_MEMORY;
299  }
300  wcscpy(*DeviceName, DetailData->DevicePath);
301  HeapFree(GetProcessHeap(), 0, DetailData);
302 
303  return Status;
304 }
305 
306 PVOID
308  IN ULONG ExtraSize)
309 {
311  if (!Data)
312  return NULL;
313 
314  Data->EventHandle.Event = CreateEventW(NULL, FALSE, FALSE, NULL);
315  if (!Data->EventHandle.Event)
316  {
318  return NULL;
319  }
320 
321  Data->NotificationType = KSEVENTF_EVENT_HANDLE;
322  return Data;
323 }
324 
325 VOID
327 {
328  PKSEVENTDATA Data = (PKSEVENTDATA)EventData;
329 
330  CloseHandle(Data->EventHandle.Event);
332 }
333 
334 
335 BOOL
337 {
340 
342  {
343  /* library is already initialized */
344  return TRUE;
345  }
346 
347 
348  /* create a device list */
350  NULL,
351  NULL,
352  DIGCF_DEVICEINTERFACE/* FIXME |DIGCF_PRESENT*/);
353 
355  {
356  /* failed to create a device list */
357  return FALSE;
358  }
359 
360 
361  /* initialize the mixer library */
363 
364  /* free device list */
366 
367  if (Status != MM_STATUS_SUCCESS)
368  {
369  /* failed to initialize mixer library */
370  DPRINT1("Failed to initialize mixer library with %x\n", Status);
371  return FALSE;
372  }
373 
374  /* library is now initialized */
376 
377  /* completed successfully */
378  return TRUE;
379 }
380 
381 MMRESULT
383 {
384  /* TODO */
385  return MMSYSERR_NOERROR;
386 }
387 
388 MMRESULT
390  IN ULONG DeviceId,
392 {
394  return MMSYSERR_NOERROR;
395 
396  return MMSYSERR_BADDEVICEID;
397 }
398 
399 MMRESULT
401  IN HANDLE hMixer,
402  IN DWORD MixerId,
403  IN LPMIXERLINEW MixLine,
404  IN ULONG Flags)
405 {
406  if (MMixerGetLineInfo(&MixerContext, hMixer, MixerId, Flags, MixLine) == MM_STATUS_SUCCESS)
407  return MMSYSERR_NOERROR;
408 
409  return MMSYSERR_ERROR;
410 }
411 
412 MMRESULT
414  IN HANDLE hMixer,
415  IN DWORD MixerId,
416  IN LPMIXERLINECONTROLSW MixControls,
417  IN ULONG Flags)
418 {
419  if (MMixerGetLineControls(&MixerContext, hMixer, MixerId, Flags, MixControls) == MM_STATUS_SUCCESS)
420  return MMSYSERR_NOERROR;
421 
422  return MMSYSERR_ERROR;
423 }
424 
425 MMRESULT
427  IN HANDLE hMixer,
428  IN DWORD MixerId,
429  IN LPMIXERCONTROLDETAILS MixDetails,
430  IN ULONG Flags)
431 {
432  if (MMixerSetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
433  return MMSYSERR_NOERROR;
434 
435  return MMSYSERR_ERROR;
436 
437 }
438 
439 MMRESULT
441  IN HANDLE hMixer,
442  IN DWORD MixerId,
443  IN LPMIXERCONTROLDETAILS MixDetails,
444  IN ULONG Flags)
445 {
446  if (MMixerGetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
447  return MMSYSERR_NOERROR;
448 
449  return MMSYSERR_ERROR;
450 }
451 
452 MMRESULT
454  IN ULONG DeviceId,
456 {
458  return MMSYSERR_NOERROR;
459 
460  return MMSYSERR_ERROR;
461 
462 }
463 
464 MMRESULT
466  IN ULONG DeviceId,
468 {
470  return MMSYSERR_NOERROR;
471 
472  return MMSYSERR_ERROR;
473 }
474 
475 MMRESULT
478  IN DWORD DeviceId,
479  IN PWAVEFORMATEX WaveFormat,
480  IN DWORD WaveFormatSize)
481 {
483  PSOUND_DEVICE SoundDevice;
485  BOOL bWaveIn;
486 
487  Result = GetSoundDeviceFromInstance(Instance, &SoundDevice);
488 
489  if ( ! MMSUCCESS(Result) )
490  {
492  }
493 
494  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
496 
497  bWaveIn = (DeviceType == WAVE_IN_DEVICE_TYPE ? TRUE : FALSE);
498 
499  if (MMixerOpenWave(&MixerContext, DeviceId, bWaveIn, WaveFormat, NULL, NULL, &Instance->Handle) == MM_STATUS_SUCCESS)
500  {
502  {
506  }
507  return MMSYSERR_NOERROR;
508  }
509  return MMSYSERR_ERROR;
510 }
511 
512 
513 MMRESULT
515  IN PSOUND_DEVICE SoundDevice,
516  IN DWORD DeviceId,
518  IN DWORD CapabilitiesSize)
519 {
522 
523  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
525 
527  {
529  }
530  else if (DeviceType == WAVE_OUT_DEVICE_TYPE)
531  {
533  }
534  else if (DeviceType == WAVE_IN_DEVICE_TYPE)
535  {
537  }
538  else
539  {
540  // not supported
541  return MMSYSERR_ERROR;
542  }
543 }
544 
545 MMRESULT
547  IN struct _SOUND_DEVICE* SoundDevice,
548  OUT PVOID* Handle)
549 {
551  return MMSYSERR_NOERROR;
552  else
553  return MMSYSERR_ERROR;
554 }
555 
556 MMRESULT
558  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
559  IN PVOID Handle)
560 {
562  PSOUND_DEVICE SoundDevice;
564 
565  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
566 
567  if ( ! MMSUCCESS(Result) )
568  {
570  }
571 
572  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
574 
576  {
577  /* no op */
578  return MMSYSERR_NOERROR;
579  }
581  {
582  /* make sure the pin is stopped */
583  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
584  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
585  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
586 
588  return MMSYSERR_NOERROR;
589  }
590 
591  /* midi is not supported */
592  return MMSYSERR_ERROR;
593 }
594 
595 MMRESULT
599 {
600  switch(DeviceType)
601  {
602  case MIXER_DEVICE_TYPE:
604  break;
607  break;
608  case WAVE_IN_DEVICE_TYPE:
610  break;
611  default:
612  *DeviceCount = 0;
613  }
614  return MMSYSERR_NOERROR;
615 }
616 
617 MMRESULT
619  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
620  IN DWORD MixerId,
621  IN UINT uMsg,
623  IN DWORD Flags)
624 {
625  LPMIXERLINEW MixLine;
626  LPMIXERLINECONTROLSW MixControls;
627  LPMIXERCONTROLDETAILS MixDetails;
628  HANDLE hMixer = NULL;
629 
630  MixLine = (LPMIXERLINEW)Parameter;
631  MixControls = (LPMIXERLINECONTROLSW)Parameter;
632  MixDetails = (LPMIXERCONTROLDETAILS)Parameter;
633 
634  /* FIXME param checks */
635 
636  if (SoundDeviceInstance)
637  {
638  hMixer = SoundDeviceInstance->Handle;
639  }
640 
641  switch(uMsg)
642  {
643  case MXDM_GETLINEINFO:
644  return WdmAudGetLineInfo(hMixer, MixerId, MixLine, Flags);
646  return WdmAudGetLineControls(hMixer, MixerId, MixControls, Flags);
648  return WdmAudSetControlDetails(hMixer, MixerId, MixDetails, Flags);
650  return WdmAudGetControlDetails(hMixer, MixerId, MixDetails, Flags);
651  default:
652  DPRINT1("MixerId %lu, uMsg %lu, Parameter %p, Flags %lu\n", MixerId, uMsg, Parameter, Flags);
653  SND_ASSERT(0);
654  return MMSYSERR_NOTSUPPORTED;
655  }
656 }
657 
658 MMRESULT
661  IN DWORD DeviceId,
663  IN DWORD InterfaceLength,
664  OUT DWORD * InterfaceSize)
665 {
666  /* FIXME */
667  return MMSYSERR_NOTSUPPORTED;
668 }
669 
670 VOID
671 CALLBACK
673  IN PVOID MixerEventContext,
674  IN HANDLE hMixer,
675  IN ULONG NotificationType,
676  IN ULONG Value)
677 {
679 
680  DriverCallback(Instance->WinMM.ClientCallback,
681  HIWORD(Instance->WinMM.Flags),
682  Instance->WinMM.Handle,
683  NotificationType,
684  Instance->WinMM.ClientCallbackInstanceData,
685  (DWORD_PTR)Value,
686  0);
687 }
688 
689 MMRESULT
692  IN DWORD DeviceId,
693  IN PWAVEFORMATEX WaveFormat,
694  IN DWORD WaveFormatSize)
695 {
697  return MMSYSERR_NOERROR;
698 
699  return MMSYSERR_BADDEVICEID;
700 }
701 
702 MMRESULT
704  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
705  IN BOOL bStart)
706 {
708  PSOUND_DEVICE SoundDevice;
710 
711  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
713 
714 
715  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
717 
719  {
720  if (bStart)
721  {
722  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
723  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
724  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
725  }
726  else
727  {
728  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
729  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
730  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
731  }
732  }
734  {
735  if (bStart)
736  {
737  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
738  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
739  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
740  }
741  else
742  {
743  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
744  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
745  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
746  }
747  }
748 
749  return MMSYSERR_NOERROR;
750 }
751 
752 MMRESULT
754  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
756  IN BOOLEAN bStartReset)
757 {
759 
761  {
762  Status = MMixerSetWaveResetState(&MixerContext, SoundDeviceInstance->Handle, bStartReset);
763  if (Status == MM_STATUS_SUCCESS)
764  {
765  /* completed successfully */
766  return MMSYSERR_NOERROR;
767  }
768  }
769 
770 
771  return MMSYSERR_NOTSUPPORTED;
772 }
773 
774 MMRESULT
776  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
777  IN MMTIME* Time)
778 {
779  /* FIXME */
780  return MMSYSERR_NOTSUPPORTED;
781 }
782 
783 static
784 VOID WINAPI
787  ULONG Reserved)
788 {
789  DWORD dwErrorCode;
790  PSOUND_OVERLAPPED Overlap;
792 
794  Overlap = (PSOUND_OVERLAPPED)IoStatusBlock;
795  lpHeader = Overlap->CompletionContext;
796 
797  /* Call mmebuddy overlap routine */
798  Overlap->OriginalCompletionRoutine(dwErrorCode,
799  lpHeader->DataUsed, &Overlap->Standard);
800 
802 }
803 
804 MMRESULT
806  IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
807  IN PVOID OffsetPtr,
808  IN DWORD Length,
809  IN PSOUND_OVERLAPPED Overlap,
811 {
812  PSOUND_DEVICE SoundDevice;
815  ULONG IoCtl;
818 
819  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
820 
821  if ( ! MMSUCCESS(Result) )
822  {
824  }
825 
826  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
828 
830  if ( ! lpHeader )
831  {
832  /* no memory */
833  return MMSYSERR_NOMEM;
834  }
835 
836  /* setup stream packet */
837  lpHeader->Size = sizeof(KSSTREAM_HEADER);
838  lpHeader->PresentationTime.Numerator = 1;
839  lpHeader->PresentationTime.Denominator = 1;
840  lpHeader->Data = OffsetPtr;
841  lpHeader->FrameExtent = Length;
842  Overlap->CompletionContext = lpHeader;
843  Overlap->OriginalCompletionRoutine = CompletionRoutine;
845 
847  {
848  lpHeader->DataUsed = Length;
849  }
850 
851  Status = NtDeviceIoControlFile(SoundDeviceInstance->Handle,
852  NULL,
854  NULL,
855  (PIO_STATUS_BLOCK)Overlap,
856  IoCtl,
857  NULL,
858  0,
859  lpHeader,
860  sizeof(KSSTREAM_HEADER));
861 
862  if (!NT_SUCCESS(Status))
863  {
864  DPRINT1("NtDeviceIoControlFile() failed with status %08lx\n", Status);
865  return MMSYSERR_ERROR;
866  }
867 
868  return MMSYSERR_NOERROR;
869 }
#define CreateEvent
Definition: winbase.h:3588
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
MMRESULT WdmAudGetLineInfo(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINEW MixLine, IN ULONG Flags)
Definition: mmixer.c:400
MIXER_STATUS MMixerOpenWave(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, IN ULONG bWaveIn, IN LPWAVEFORMATEX WaveFormat, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
Definition: wave.c:436
MIXER_STATUS MMixerSetMidiStatus(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
Definition: midi.c:437
MMRESULT WdmAudGetNumWdmDevsByMMixer(IN MMDEVICE_TYPE DeviceType, OUT DWORD *DeviceCount)
Definition: mmixer.c:596
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define IN
Definition: typedefs.h:39
ULONG MMixerGetWaveInCount(IN PMIXER_CONTEXT MixerContext)
Definition: wave.c:563
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:719
TCHAR lpHeader[80]
Definition: ctm.c:66
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:139
#define CloseHandle
Definition: compat.h:487
BOOL WdmAudInitUserModeMixer()
Definition: mmixer.c:336
PVOID CompletionContext
Definition: mmebuddy.h:126
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
MIXER_STATUS Control(IN HANDLE hMixer, IN ULONG dwIoControlCode, IN PVOID lpInBuffer, IN ULONG nInBufferSize, OUT PVOID lpOutBuffer, ULONG nOutBufferSize, PULONG lpBytesReturned)
Definition: mmixer.c:153
MIXER_STATUS QueryKeyValue(IN HANDLE hKey, IN LPWSTR KeyName, OUT PVOID *ResultBuffer, OUT PULONG ResultLength, OUT PULONG KeyType)
Definition: mmixer.c:61
struct tMIXERCONTROLDETAILS * LPMIXERCONTROLDETAILS
#define ERROR_SUCCESS
Definition: deptool.c:10
#define STATIC_KSCATEGORY_AUDIO
Definition: ksmedia.h:169
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:850
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
MIXER_STATUS MMixerInitialize(IN PMIXER_CONTEXT MixerContext, IN PMIXER_ENUM EnumFunction, IN PVOID EnumContext)
Definition: mixer.c:770
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:204
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
struct KSEVENTDATA * PKSEVENTDATA
#define IOCTL_KS_READ_STREAM
Definition: ks.h:142
DeviceType
Definition: mmdrv.h:41
MMRESULT WdmAudResetStreamByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
Definition: mmixer.c:753
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(HDEVINFO DeviceInfoSet, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, DWORD DeviceInterfaceDetailDataSize, PDWORD RequiredSize, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:3016
MIXER_STATUS MMixerGetLineInfo(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINEW MixerLine)
Definition: mixer.c:149
PVOID AllocEventData(IN ULONG ExtraSize)
Definition: mmixer.c:307
ULONG MMixerGetCount(IN PMIXER_CONTEXT MixerContext)
Definition: mixer.c:15
LONG NTSTATUS
Definition: precomp.h:26
#define CALLBACK
Definition: compat.h:35
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT WdmAudGetCapabilitiesByMMixer(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: mmixer.c:514
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
MIXER_STATUS Close(HANDLE hDevice)
Definition: mmixer.c:111
WCHAR DeviceName[]
Definition: adapter.cpp:21
_In_ PVOID Parameter
Definition: ldrtypes.h:241
MMRESULT WdmAudQueryMixerInfoByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD MixerId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
Definition: mmixer.c:618
MIXER_STATUS MMixerGetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:566
#define ERROR_IO_PENDING
Definition: dderror.h:15
OVERLAPPED Standard
Definition: mmebuddy.h:120
PVOID Alloc(ULONG NumBytes)
Definition: mmixer.c:105
BOOL MMixerLibraryInitialized
Definition: mmixer.c:24
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
IN UCHAR Value
Definition: halp.h:394
VOID FreeEventData(IN PVOID EventData)
Definition: mmixer.c:326
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA_W
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
unsigned int BOOL
Definition: ntddk_ex.h:94
MMRESULT WdmAudGetMixerCapabilities(IN ULONG DeviceId, LPMIXERCAPSW Capabilities)
Definition: mmixer.c:389
ULONG DeviceCount
Definition: mpu401.c:26
MMRESULT WdmAudOpenSoundDeviceByMMixer(IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)
Definition: mmixer.c:546
#define GENERIC_WRITE
Definition: nt_native.h:90
MMRESULT WdmAudSetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:426
HMIXER hMixer
Definition: test.c:10
MMRESULT WdmAudGetDeviceInterfaceStringByMMixer(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
Definition: mmixer.c:659
HANDLE hEvent
Definition: winbase.h:798
MMRESULT WdmAudGetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:440
MIXER_STATUS MMixerGetLineControls(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERLINECONTROLSW MixerLineControls)
Definition: mixer.c:332
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: cdrom.h:1146
#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
void DPRINT(...)
Definition: polytest.cpp:61
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
GUID CategoryGuid
Definition: mmixer.c:58
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define MXDM_SETCONTROLDETAILS
Definition: mmddk.h:198
#define OPEN_EXISTING
Definition: compat.h:523
MIXER_STATUS Open(IN LPWSTR DevicePath, OUT PHANDLE hDevice)
Definition: mmixer.c:132
HKEY WINAPI SetupDiOpenDeviceInterfaceRegKey(IN HDEVINFO DeviceInfoSet, IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IN DWORD Reserved, IN REGSAM samDesired)
Definition: interface.c:547
MIXER_STATUS MMixerSetWaveStatus(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
Definition: wave.c:607
#define MXDM_GETCONTROLDETAILS
Definition: mmddk.h:197
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
_In_ HANDLE Handle
Definition: extypes.h:390
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
MMRESULT WdmAudGetWavePositionByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
Definition: mmixer.c:775
VOID Free(PVOID Block)
Definition: mmixer.c:120
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
MMRESULT WdmAudCleanupByMMixer()
Definition: mmixer.c:382
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
MMRESULT WdmAudSetMixerDeviceFormatByMMixer(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: mmixer.c:690
VOID CALLBACK MixerEventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:672
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * PSP_DEVICE_INTERFACE_DETAIL_DATA_W
MIXER_STATUS MMixerWaveInCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEINCAPSW Caps)
Definition: wave.c:491
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
MMRESULT WdmAudGetLineControls(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERLINECONTROLSW MixControls, IN ULONG Flags)
Definition: mmixer.c:413
struct tagMIXERLINEW * LPMIXERLINEW
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
Status
Definition: gdiplustypes.h:24
#define MXDM_GETLINECONTROLS
Definition: mmddk.h:196
static const WCHAR L[]
Definition: oid.c:1250
MIXER_STATUS MMixerWaveOutCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEOUTCAPSW Caps)
Definition: wave.c:527
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
static VOID WINAPI CommitWaveBufferApc(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
Definition: mmixer.c:785
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define SetupDiGetClassDevs
Definition: setupapi.h:2588
#define GENERIC_READ
Definition: compat.h:135
MIXER_STATUS CloseKey(IN HANDLE hKey)
Definition: mmixer.c:97
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:220
MIXER_STATUS OpenKey(IN HANDLE hKey, IN LPWSTR SubKey, IN ULONG DesiredAccess, OUT PHANDLE OutKey)
Definition: mmixer.c:84
MMRESULT WdmAudCommitWaveBufferByMMixer(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
Definition: mmixer.c:805
uint32_t DWORD_PTR
Definition: typedefs.h:65
MMRESULT WdmAudCloseSoundDeviceByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
Definition: mmixer.c:557
#define ERROR_MORE_DATA
Definition: dderror.h:13
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
Definition: winbase.h:1417
#define Dst
Definition: mesh.h:153
MMRESULT WdmAudGetWaveInCapabilities(IN ULONG DeviceId, LPWAVEINCAPSW Capabilities)
Definition: mmixer.c:465
MIXER_STATUS MMixerSetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:496
LPOVERLAPPED_COMPLETION_ROUTINE OriginalCompletionRoutine
Definition: mmebuddy.h:125
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
MIXER_STATUS MMixerSetWaveResetState(IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN ULONG bBegin)
Definition: wave.c:634
MIXER_STATUS
Definition: mmixer.h:3
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4137
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2785
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1778
MMRESULT WdmAudGetWaveOutCapabilities(IN ULONG DeviceId, LPWAVEOUTCAPSW Capabilities)
Definition: mmixer.c:453
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704
IN PVOID Instance
Definition: pci.h:361
#define DPRINT1
Definition: precomp.h:8
#define CreateFileW
Definition: compat.h:489
MIXER_STATUS MMixerOpen(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerId, IN PVOID MixerEventContext, IN PMIXER_EVENT MixerEventRoutine, OUT PHANDLE MixerHandle)
Definition: mixer.c:77
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
#define OUT
Definition: typedefs.h:40
struct tagMIXERLINECONTROLSW * LPMIXERLINECONTROLSW
#define HIWORD(l)
Definition: typedefs.h:247
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
MMRESULT WdmAudSetWaveDeviceFormatByMMixer(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: mmixer.c:476
IN PVOID IN PVOID InterfaceData
Definition: pci.h:361
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
MIXER_STATUS MMixerGetCapabilities(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerIndex, OUT LPMIXERCAPSW MixerCaps)
Definition: mixer.c:38
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
PKMT_RESULTBUFFER ResultBuffer
#define MXDM_GETLINEINFO
Definition: mmddk.h:195
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
static PLARGE_INTEGER Time
Definition: time.c:105
_In_ ULONG_PTR Data
Definition: cdrom.h:947
ULONG MMixerGetWaveOutCount(IN PMIXER_CONTEXT MixerContext)
Definition: wave.c:585
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
MMRESULT WdmAudSetWaveStateByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)
Definition: mmixer.c:703
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700