ReactOS  0.4.13-dev-39-g8b6696f
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 
16 #define NDEBUG
17 #include <debug.h>
18 #include <mmebuddy_debug.h>
19 
20 typedef struct
21 {
28 
30 
31 
32 
33 PVOID Alloc(ULONG NumBytes);
34 MIXER_STATUS Close(HANDLE hDevice);
35 VOID Free(PVOID Block);
36 VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes);
37 MIXER_STATUS Open(IN LPWSTR DevicePath, OUT PHANDLE hDevice);
38 MIXER_STATUS Control(IN HANDLE hMixer, IN ULONG dwIoControlCode, IN PVOID lpInBuffer, IN ULONG nInBufferSize, OUT PVOID lpOutBuffer, ULONG nOutBufferSize, PULONG lpBytesReturned);
39 MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR * DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey);
43 PVOID AllocEventData(IN ULONG ExtraSize);
44 VOID FreeEventData(IN PVOID EventData);
45 
47 {
48  sizeof(MIXER_CONTEXT),
49  NULL,
50  Alloc,
51  Control,
52  Free,
53  Open,
54  Close,
55  Copy,
56  OpenKey,
58  CloseKey,
61 };
62 
64 
67  IN HANDLE hKey,
71  OUT PULONG KeyType)
72 {
75 
77  if (*ResultBuffer == NULL)
78  return MM_STATUS_NO_MEMORY;
79 
81  {
84  }
85  return MM_STATUS_SUCCESS;
86 }
87 
90  IN HANDLE hKey,
91  IN LPWSTR SubKey,
93  OUT PHANDLE OutKey)
94 {
95  if (RegOpenKeyExW((HKEY)hKey, SubKey, 0, DesiredAccess, (PHKEY)OutKey) == ERROR_SUCCESS)
96  return MM_STATUS_SUCCESS;
97 
99 }
100 
103  IN HANDLE hKey)
104 {
105  RegCloseKey((HKEY)hKey);
106  return MM_STATUS_SUCCESS;
107 }
108 
109 
110 PVOID Alloc(ULONG NumBytes)
111 {
112  return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
113 }
114 
116 Close(HANDLE hDevice)
117 {
118  if (CloseHandle(hDevice))
119  return MM_STATUS_SUCCESS;
120  else
121  return MM_STATUS_UNSUCCESSFUL;
122 }
123 
124 VOID
125 Free(PVOID Block)
126 {
127  HeapFree(GetProcessHeap(), 0, Block);
128 }
129 
130 VOID
131 Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
132 {
133  RtlMoveMemory(Src, Dst, NumBytes);
134 }
135 
138  IN LPWSTR DevicePath,
139  OUT PHANDLE hDevice)
140 {
141  DevicePath[1] = L'\\';
142  *hDevice = CreateFileW(DevicePath,
144  0,
145  NULL,
148  NULL);
149  if (*hDevice == INVALID_HANDLE_VALUE)
150  {
151  return MM_STATUS_UNSUCCESSFUL;
152  }
153 
154  return MM_STATUS_SUCCESS;
155 }
156 
159  IN HANDLE hMixer,
161  IN PVOID lpInBuffer,
162  IN ULONG nInBufferSize,
163  OUT PVOID lpOutBuffer,
164  ULONG nOutBufferSize,
166 {
167  OVERLAPPED Overlapped;
168  BOOLEAN IoResult;
169  DWORD Transferred = 0;
170 
171  /* Overlapped I/O is done here - this is used for waiting for completion */
172  ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
173  Overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
174 
175  if ( ! Overlapped.hEvent )
176  return MM_STATUS_NO_MEMORY;
177 
178  /* Talk to the device */
179  IoResult = DeviceIoControl(hMixer,
181  lpInBuffer,
182  nInBufferSize,
183  lpOutBuffer,
184  nOutBufferSize,
185  &Transferred,
186  &Overlapped);
187 
188  /* If failure occurs, make sure it's not just due to the overlapped I/O */
189  if ( ! IoResult )
190  {
191  if ( GetLastError() != ERROR_IO_PENDING )
192  {
193  CloseHandle(Overlapped.hEvent);
194 
196  {
197  if ( lpBytesReturned )
198  *lpBytesReturned = Transferred;
199  return MM_STATUS_MORE_ENTRIES;
200  }
201 
202  return MM_STATUS_UNSUCCESSFUL;
203  }
204  }
205 
206  /* Wait for the I/O to complete */
207  IoResult = GetOverlappedResult(hMixer,
208  &Overlapped,
209  &Transferred,
210  TRUE);
211 
212  /* Don't need this any more */
213  CloseHandle(Overlapped.hEvent);
214 
215  if ( ! IoResult )
216  return MM_STATUS_UNSUCCESSFUL;
217 
218  if ( lpBytesReturned )
219  *lpBytesReturned = Transferred;
220 
221  return MM_STATUS_SUCCESS;
222 }
223 
226  IN PVOID EnumContext,
227  IN ULONG DeviceIndex,
229  OUT PHANDLE OutHandle,
230  OUT PHANDLE OutKey)
231 {
235  BOOL Result;
236  DWORD Length;
238 
239  //printf("Enum EnumContext %p DeviceIndex %lu OutHandle %p\n", EnumContext, DeviceIndex, OutHandle);
240 
241  InterfaceData.cbSize = sizeof(InterfaceData);
242  InterfaceData.Reserved = 0;
243 
244  Result = SetupDiEnumDeviceInterfaces(EnumContext,
245  NULL,
246  &CategoryGuid,
247  DeviceIndex,
248  &InterfaceData);
249 
250  if (!Result)
251  {
253  {
255  }
256  return MM_STATUS_UNSUCCESSFUL;
257  }
258 
261  0,
262  Length);
263  DetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
264  DeviceData.cbSize = sizeof(DeviceData);
265  DeviceData.Reserved = 0;
266 
268  &InterfaceData,
269  DetailData,
270  Length,
271  NULL,
272  &DeviceData);
273 
274  if (!Result)
275  {
276  DPRINT("SetupDiGetDeviceInterfaceDetailW failed with %lu\n", GetLastError());
277  return MM_STATUS_UNSUCCESSFUL;
278  }
279 
280 
281  *OutKey = SetupDiOpenDeviceInterfaceRegKey(EnumContext, &InterfaceData, 0, KEY_READ);
282  if ((HKEY)*OutKey == INVALID_HANDLE_VALUE)
283  {
284  HeapFree(GetProcessHeap(), 0, DetailData);
285  return MM_STATUS_UNSUCCESSFUL;
286  }
287 
288  Status = Open(DetailData->DevicePath, OutHandle);
289 
290  if (Status != MM_STATUS_SUCCESS)
291  {
292  RegCloseKey((HKEY)*OutKey);
293  HeapFree(GetProcessHeap(), 0, DetailData);
294  return Status;
295  }
296 
297  *DeviceName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(DetailData->DevicePath)+1) * sizeof(WCHAR));
298  if (*DeviceName == NULL)
299  {
300  CloseHandle(*OutHandle);
301  RegCloseKey((HKEY)*OutKey);
302  HeapFree(GetProcessHeap(), 0, DetailData);
303  return MM_STATUS_NO_MEMORY;
304  }
305  wcscpy(*DeviceName, DetailData->DevicePath);
306  HeapFree(GetProcessHeap(), 0, DetailData);
307 
308  return Status;
309 }
310 
311 PVOID
313  IN ULONG ExtraSize)
314 {
316  if (!Data)
317  return NULL;
318 
319  Data->EventHandle.Event = CreateEventW(NULL, FALSE, FALSE, NULL);
320  if (!Data->EventHandle.Event)
321  {
323  return NULL;
324  }
325 
326  Data->NotificationType = KSEVENTF_EVENT_HANDLE;
327  return Data;
328 }
329 
330 VOID
332 {
333  PKSEVENTDATA Data = (PKSEVENTDATA)EventData;
334 
335  CloseHandle(Data->EventHandle.Event);
337 }
338 
339 
340 BOOL
342 {
345 
347  {
348  /* library is already initialized */
349  return TRUE;
350  }
351 
352 
353  /* create a device list */
355  NULL,
356  NULL,
357  DIGCF_DEVICEINTERFACE/* FIXME |DIGCF_PRESENT*/);
358 
360  {
361  /* failed to create a device list */
362  return FALSE;
363  }
364 
365 
366  /* initialize the mixer library */
368 
369  /* free device list */
371 
372  if (Status != MM_STATUS_SUCCESS)
373  {
374  /* failed to initialize mixer library */
375  DPRINT1("Failed to initialize mixer library with %x\n", Status);
376  return FALSE;
377  }
378 
379  /* library is now initialized */
381 
382  /* completed successfully */
383  return TRUE;
384 }
385 
386 MMRESULT
388 {
389  /* TODO */
390  return MMSYSERR_NOERROR;
391 }
392 
393 MMRESULT
395  IN ULONG DeviceId,
397 {
399  return MMSYSERR_NOERROR;
400 
401  return MMSYSERR_BADDEVICEID;
402 }
403 
404 MMRESULT
406  IN HANDLE hMixer,
407  IN DWORD MixerId,
408  IN LPMIXERLINEW MixLine,
409  IN ULONG Flags)
410 {
411  if (MMixerGetLineInfo(&MixerContext, hMixer, MixerId, Flags, MixLine) == MM_STATUS_SUCCESS)
412  return MMSYSERR_NOERROR;
413 
414  return MMSYSERR_ERROR;
415 }
416 
417 MMRESULT
419  IN HANDLE hMixer,
420  IN DWORD MixerId,
421  IN LPMIXERLINECONTROLSW MixControls,
422  IN ULONG Flags)
423 {
424  if (MMixerGetLineControls(&MixerContext, hMixer, MixerId, Flags, MixControls) == MM_STATUS_SUCCESS)
425  return MMSYSERR_NOERROR;
426 
427  return MMSYSERR_ERROR;
428 }
429 
430 MMRESULT
432  IN HANDLE hMixer,
433  IN DWORD MixerId,
434  IN LPMIXERCONTROLDETAILS MixDetails,
435  IN ULONG Flags)
436 {
437  if (MMixerSetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
438  return MMSYSERR_NOERROR;
439 
440  return MMSYSERR_ERROR;
441 
442 }
443 
444 MMRESULT
446  IN HANDLE hMixer,
447  IN DWORD MixerId,
448  IN LPMIXERCONTROLDETAILS MixDetails,
449  IN ULONG Flags)
450 {
451  if (MMixerGetControlDetails(&MixerContext, hMixer, MixerId, Flags, MixDetails) == MM_STATUS_SUCCESS)
452  return MMSYSERR_NOERROR;
453 
454  return MMSYSERR_ERROR;
455 }
456 
457 MMRESULT
459  IN ULONG DeviceId,
461 {
463  return MMSYSERR_NOERROR;
464 
465  return MMSYSERR_ERROR;
466 
467 }
468 
469 MMRESULT
471  IN ULONG DeviceId,
473 {
475  return MMSYSERR_NOERROR;
476 
477  return MMSYSERR_ERROR;
478 }
479 
480 MMRESULT
483  IN DWORD DeviceId,
484  IN PWAVEFORMATEX WaveFormat,
485  IN DWORD WaveFormatSize)
486 {
488  PSOUND_DEVICE SoundDevice;
490  BOOL bWaveIn;
491 
492  Result = GetSoundDeviceFromInstance(Instance, &SoundDevice);
493 
494  if ( ! MMSUCCESS(Result) )
495  {
497  }
498 
499  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
501 
502  bWaveIn = (DeviceType == WAVE_IN_DEVICE_TYPE ? TRUE : FALSE);
503 
504  if (MMixerOpenWave(&MixerContext, DeviceId, bWaveIn, WaveFormat, NULL, NULL, &Instance->Handle) == MM_STATUS_SUCCESS)
505  {
507  {
511  }
512  return MMSYSERR_NOERROR;
513  }
514  return MMSYSERR_ERROR;
515 }
516 
517 
518 MMRESULT
520  IN PSOUND_DEVICE SoundDevice,
521  IN DWORD DeviceId,
523  IN DWORD CapabilitiesSize)
524 {
527 
528  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
530 
532  {
534  }
535  else if (DeviceType == WAVE_OUT_DEVICE_TYPE)
536  {
538  }
539  else if (DeviceType == WAVE_IN_DEVICE_TYPE)
540  {
542  }
543  else
544  {
545  // not supported
546  return MMSYSERR_ERROR;
547  }
548 }
549 
550 MMRESULT
552  IN struct _SOUND_DEVICE* SoundDevice,
553  OUT PVOID* Handle)
554 {
556  return MMSYSERR_NOERROR;
557  else
558  return MMSYSERR_ERROR;
559 }
560 
561 MMRESULT
563  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
564  IN PVOID Handle)
565 {
567  PSOUND_DEVICE SoundDevice;
569 
570  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
571 
572  if ( ! MMSUCCESS(Result) )
573  {
575  }
576 
577  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
579 
581  {
582  /* no op */
583  return MMSYSERR_NOERROR;
584  }
586  {
587  /* make sure the pin is stopped */
588  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
589  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
590  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
591 
593  return MMSYSERR_NOERROR;
594  }
595 
596  /* midi is not supported */
597  return MMSYSERR_ERROR;
598 }
599 
600 MMRESULT
604 {
605  switch(DeviceType)
606  {
607  case MIXER_DEVICE_TYPE:
609  break;
612  break;
613  case WAVE_IN_DEVICE_TYPE:
615  break;
616  default:
617  *DeviceCount = 0;
618  }
619  return MMSYSERR_NOERROR;
620 }
621 
622 MMRESULT
624  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
625  IN DWORD MixerId,
626  IN UINT uMsg,
628  IN DWORD Flags)
629 {
630  LPMIXERLINEW MixLine;
631  LPMIXERLINECONTROLSW MixControls;
632  LPMIXERCONTROLDETAILS MixDetails;
633  HANDLE hMixer = NULL;
634 
635  MixLine = (LPMIXERLINEW)Parameter;
636  MixControls = (LPMIXERLINECONTROLSW)Parameter;
637  MixDetails = (LPMIXERCONTROLDETAILS)Parameter;
638 
639  /* FIXME param checks */
640 
641  if (SoundDeviceInstance)
642  {
643  hMixer = SoundDeviceInstance->Handle;
644  }
645 
646  switch(uMsg)
647  {
648  case MXDM_GETLINEINFO:
649  return WdmAudGetLineInfo(hMixer, MixerId, MixLine, Flags);
651  return WdmAudGetLineControls(hMixer, MixerId, MixControls, Flags);
653  return WdmAudSetControlDetails(hMixer, MixerId, MixDetails, Flags);
655  return WdmAudGetControlDetails(hMixer, MixerId, MixDetails, Flags);
656  default:
657  DPRINT1("MixerId %lu, uMsg %lu, Parameter %p, Flags %lu\n", MixerId, uMsg, Parameter, Flags);
658  SND_ASSERT(0);
659  return MMSYSERR_NOTSUPPORTED;
660  }
661 }
662 
663 MMRESULT
666  IN DWORD DeviceId,
668  IN DWORD InterfaceLength,
669  OUT DWORD * InterfaceSize)
670 {
671  /* FIXME */
672  return MMSYSERR_NOTSUPPORTED;
673 }
674 
675 VOID
676 CALLBACK
678  IN PVOID MixerEventContext,
679  IN HANDLE hMixer,
680  IN ULONG NotificationType,
681  IN ULONG Value)
682 {
684 
685  DriverCallback(Instance->WinMM.ClientCallback,
686  HIWORD(Instance->WinMM.Flags),
687  Instance->WinMM.Handle,
688  NotificationType,
689  Instance->WinMM.ClientCallbackInstanceData,
690  (DWORD_PTR)Value,
691  0);
692 }
693 
694 MMRESULT
697  IN DWORD DeviceId,
698  IN PWAVEFORMATEX WaveFormat,
699  IN DWORD WaveFormatSize)
700 {
702  return MMSYSERR_NOERROR;
703 
704  return MMSYSERR_BADDEVICEID;
705 }
706 
707 MMRESULT
709  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
710  IN BOOL bStart)
711 {
713  PSOUND_DEVICE SoundDevice;
715 
716  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
718 
719 
720  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
722 
724  {
725  if (bStart)
726  {
727  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
728  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
729  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
730  }
731  else
732  {
733  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
734  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
735  MMixerSetWaveStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
736  }
737  }
739  {
740  if (bStart)
741  {
742  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
743  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
744  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_RUN);
745  }
746  else
747  {
748  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_PAUSE);
749  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_ACQUIRE);
750  MMixerSetMidiStatus(&MixerContext, SoundDeviceInstance->Handle, KSSTATE_STOP);
751  }
752  }
753 
754  return MMSYSERR_NOERROR;
755 }
756 
757 MMRESULT
759  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
761  IN BOOLEAN bStartReset)
762 {
764 
766  {
767  Status = MMixerSetWaveResetState(&MixerContext, SoundDeviceInstance->Handle, bStartReset);
768  if (Status == MM_STATUS_SUCCESS)
769  {
770  /* completed successfully */
771  return MMSYSERR_NOERROR;
772  }
773  }
774 
775 
776  return MMSYSERR_NOTSUPPORTED;
777 }
778 
779 MMRESULT
781  IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
782  IN MMTIME* Time)
783 {
784  /* FIXME */
785  return MMSYSERR_NOTSUPPORTED;
786 }
787 
788 DWORD
789 WINAPI
792 {
793  DWORD Length;
794  //MMRESULT Result;
796 
797  /*Result = */ SyncOverlappedDeviceIoControl(Packet->hDevice,
798  Packet->IoCtl,
799  NULL,
800  0,
801  &Packet->Header,
802  sizeof(KSSTREAM_HEADER),
803  &Length);
804 
805  Packet->CompletionRoutine(ERROR_SUCCESS, Packet->Header.DataUsed, (LPOVERLAPPED)Packet->Overlap);
806 
808  return 0;
809 }
810 
811 MMRESULT
813  IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
814  IN PVOID OffsetPtr,
815  IN DWORD Length,
816  IN PSOUND_OVERLAPPED Overlap,
818 {
819  PSOUND_DEVICE SoundDevice;
823  HANDLE hThread;
824 
825  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
826 
827  if ( ! MMSUCCESS(Result) )
828  {
830  }
831 
832  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
834 
836  if ( ! Packet )
837  {
838  /* no memory */
839  return MMSYSERR_NOMEM;
840  }
841 
842  /* setup stream packet */
843  Packet->Header.Size = sizeof(KSSTREAM_HEADER);
844  Packet->Header.PresentationTime.Numerator = 1;
845  Packet->Header.PresentationTime.Denominator = 1;
846  Packet->Header.Data = OffsetPtr;
847  Packet->Header.FrameExtent = Length;
848  Packet->hDevice = SoundDeviceInstance->Handle;
849  Packet->Overlap = Overlap;
850  Packet->CompletionRoutine = CompletionRoutine;
852 
854  {
855  Packet->Header.DataUsed = Length;
856  }
857 
859  if (hThread == NULL)
860  {
861  /* error */
862  return MMSYSERR_ERROR;
863  }
864 
866 
867  return MMSYSERR_NOERROR;
868 }
#define CreateEvent
Definition: winbase.h:3562
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:405
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
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:601
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
#define IN
Definition: typedefs.h:38
ULONG MMixerGetWaveInCount(IN PMIXER_CONTEXT MixerContext)
Definition: wave.c:563
#define IOCTL_KS_WRITE_STREAM
Definition: ks.h:157
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
BOOL WdmAudInitUserModeMixer()
Definition: mmixer.c:341
_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:158
MIXER_STATUS QueryKeyValue(IN HANDLE hKey, IN LPWSTR KeyName, OUT PVOID *ResultBuffer, OUT PULONG ResultLength, OUT PULONG KeyType)
Definition: mmixer.c:66
struct tMIXERCONTROLDETAILS * LPMIXERCONTROLDETAILS
#define ERROR_SUCCESS
Definition: deptool.c:10
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
#define STATIC_KSCATEGORY_AUDIO
Definition: ksmedia.h:169
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:850
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
MIXER_STATUS MMixerInitialize(IN PMIXER_CONTEXT MixerContext, IN PMIXER_ENUM EnumFunction, IN PVOID EnumContext)
Definition: mixer.c:770
DWORD WINAPI IoStreamingThread(LPVOID lpParameter)
Definition: mmixer.c:790
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 MMSUCCESS(result)
Definition: mmebuddy.h:80
struct KSEVENTDATA * PKSEVENTDATA
#define IOCTL_KS_READ_STREAM
Definition: ks.h:164
DeviceType
Definition: mmdrv.h:41
MMRESULT WdmAudResetStreamByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
Definition: mmixer.c:758
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:312
ULONG MMixerGetCount(IN PMIXER_CONTEXT MixerContext)
Definition: mixer.c:15
#define CALLBACK
Definition: compat.h:27
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
UINT MMRESULT
Definition: mmsystem.h:962
MMRESULT WdmAudGetCapabilitiesByMMixer(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: mmixer.c:519
MaybeUInt64 bStart[BZ_MAX_HANDLED_BLOCKS]
Definition: bzip2recover.c:296
MIXER_STATUS Close(HANDLE hDevice)
Definition: mmixer.c:116
WCHAR DeviceName[]
Definition: adapter.cpp:21
_In_ PVOID Parameter
Definition: ldrtypes.h:240
MMRESULT WdmAudQueryMixerInfoByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD MixerId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
Definition: mmixer.c:623
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
struct IO_PACKET * LPIO_PACKET
PVOID Alloc(ULONG NumBytes)
Definition: mmixer.c:110
BOOL MMixerLibraryInitialized
Definition: mmixer.c:29
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
PSOUND_OVERLAPPED Overlap
Definition: mmixer.c:24
VOID FreeEventData(IN PVOID EventData)
Definition: mmixer.c:331
LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
Definition: mmixer.c:25
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
_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:394
ULONG DeviceCount
Definition: mpu401.c:26
MMRESULT WdmAudOpenSoundDeviceByMMixer(IN struct _SOUND_DEVICE *SoundDevice, OUT PVOID *Handle)
Definition: mmixer.c:551
#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:431
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:664
HANDLE hEvent
Definition: winbase.h:792
MMRESULT WdmAudGetControlDetails(IN HANDLE hMixer, IN DWORD MixerId, IN LPMIXERCONTROLDETAILS MixDetails, IN ULONG Flags)
Definition: mmixer.c:445
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
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
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
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
void DPRINT(...)
Definition: polytest.cpp:61
GUID CategoryGuid
Definition: mmixer.c:63
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define MXDM_SETCONTROLDETAILS
Definition: mmddk.h:198
#define OPEN_EXISTING
Definition: compat.h:426
MIXER_STATUS Open(IN LPWSTR DevicePath, OUT PHANDLE hDevice)
Definition: mmixer.c:137
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
_In_ HANDLE Handle
Definition: extypes.h:390
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
MMRESULT WdmAudGetWavePositionByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
Definition: mmixer.c:780
VOID Free(PVOID Block)
Definition: mmixer.c:125
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define GetProcessHeap()
Definition: compat.h:395
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:4134
MMRESULT WdmAudCleanupByMMixer()
Definition: mmixer.c:387
__wchar_t WCHAR
Definition: xmlstorage.h:180
MMRESULT WdmAudSetMixerDeviceFormatByMMixer(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: mmixer.c:695
VOID CALLBACK MixerEventCallback(IN PVOID MixerEventContext, IN HANDLE hMixer, IN ULONG NotificationType, IN ULONG Value)
Definition: mmixer.c:677
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
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:418
struct tagMIXERLINEW * LPMIXERLINEW
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
KSSTREAM_HEADER Header
Definition: mmixer.c:22
#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
LPVOID lpParameter
Definition: kernel32.h:234
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
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:301
#define MMSYSERR_BADDEVICEID
Definition: mmsystem.h:98
#define SetupDiGetClassDevs
Definition: setupapi.h:2587
#define GENERIC_READ
Definition: compat.h:124
MIXER_STATUS CloseKey(IN HANDLE hKey)
Definition: mmixer.c:102
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:225
MIXER_STATUS OpenKey(IN HANDLE hKey, IN LPWSTR SubKey, IN ULONG DesiredAccess, OUT PHANDLE OutKey)
Definition: mmixer.c:89
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:812
uint32_t DWORD_PTR
Definition: typedefs.h:63
MMRESULT WdmAudCloseSoundDeviceByMMixer(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
Definition: mmixer.c:562
#define ERROR_MORE_DATA
Definition: dderror.h:13
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
Definition: winbase.h:1404
Status
Definition: gdiplustypes.h:24
#define Dst
Definition: mesh.h:153
MMRESULT WdmAudGetWaveInCapabilities(IN ULONG DeviceId, LPWAVEINCAPSW Capabilities)
Definition: mmixer.c:470
MIXER_STATUS MMixerSetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE MixerHandle, IN ULONG MixerId, IN ULONG Flags, OUT LPMIXERCONTROLDETAILS MixerControlDetails)
Definition: mixer.c:496
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:131
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:4157
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2785
#define KSEVENTF_EVENT_HANDLE
Definition: ks.h:1808
MMRESULT WdmAudGetWaveOutCapabilities(IN ULONG DeviceId, LPWAVEOUTCAPSW Capabilities)
Definition: mmixer.c:458
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704
IN PVOID Instance
Definition: pci.h:359
HANDLE hThread
Definition: wizard.c:27
#define DPRINT1
Definition: precomp.h:8
#define CreateFileW
Definition: compat.h:400
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
HANDLE hDevice
Definition: mmixer.c:23
#define OUT
Definition: typedefs.h:39
struct tagMIXERLINECONTROLSW * LPMIXERLINECONTROLSW
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
MMRESULT WdmAudSetWaveDeviceFormatByMMixer(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: mmixer.c:481
IN PVOID IN PVOID InterfaceData
Definition: pci.h:359
DWORD IoCtl
Definition: mmixer.c:26
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:394
static PLARGE_INTEGER Time
Definition: time.c:105
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:708
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700