ReactOS 0.4.16-dev-340-g0540c21
legacy.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/wdmaud.c
5 *
6 * PURPOSE: WDM Audio Driver (User-mode part)
7 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
8 Johannes Anderwald
9 *
10 * NOTES: Looking for wodMessage & co? You won't find them here. Try
11 * the MME Buddy library, which is where these routines are
12 * actually implemented.
13 *
14 */
15
16#include "wdmaud.h"
17
18#define NDEBUG
19#include <debug.h>
20#include <mmebuddy_debug.h>
21
22#define KERNEL_DEVICE_NAME L"\\\\.\\wdmaud"
23
26
31{
32 HANDLE WaitObjects[2];
33 DWORD dwResult;
37
38 /* setup wait objects */
39 WaitObjects[0] = Instance->hNotifyEvent;
40 WaitObjects[1] = Instance->hStopEvent;
41
42 /* zero device info */
44
45 DeviceInfo.hDevice = Instance->Handle;
46 DeviceInfo.DeviceType = MIXER_DEVICE_TYPE;
47
48 do
49 {
50 dwResult = WaitForMultipleObjects(2, WaitObjects, FALSE, INFINITE);
51
52 if (dwResult == WAIT_OBJECT_0 + 1)
53 {
54 /* stop event was signalled */
55 break;
56 }
57
58 do
59 {
63 sizeof(WDMAUD_DEVICE_INFO),
65 sizeof(WDMAUD_DEVICE_INFO),
66 NULL);
67
69 {
70 DriverCallback(Instance->WinMM.ClientCallback,
71 HIWORD(Instance->WinMM.Flags),
72 Instance->WinMM.Handle,
73 DeviceInfo.u.MixerEvent.NotificationType,
74 Instance->WinMM.ClientCallbackInstanceData,
75 (DWORD_PTR)DeviceInfo.u.MixerEvent.Value,
76 0);
77 }
78 }while(Result == MMSYSERR_NOERROR);
79 }while(TRUE);
80
81 /* done */
82 return 0;
83}
84
87{
89 {
92 }
93
94 return MMSYSERR_NOERROR;
95}
96
101{
104
108
110 DeviceInfo.DeviceType = DeviceType;
111
115 sizeof(WDMAUD_DEVICE_INFO),
117 sizeof(WDMAUD_DEVICE_INFO),
118 NULL);
119
120 if ( ! MMSUCCESS( Result ) )
121 {
122 SND_ERR(L"Call to IOCTL_GETNUMDEVS_TYPE failed\n");
123 *DeviceCount = 0;
125 }
126
127 *DeviceCount = DeviceInfo.DeviceCount;
128
129 return MMSYSERR_NOERROR;
130}
131
134 IN PSOUND_DEVICE SoundDevice,
135 IN DWORD DeviceId,
137 IN DWORD CapabilitiesSize)
138{
142
143 SND_ASSERT( SoundDevice );
145
146 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
148
149 if ( ! MMSUCCESS(Result) )
150 return Result;
151
152 SND_TRACE(L"WDMAUD - GetWdmDeviceCapabilities DeviceType %u DeviceId %u\n", DeviceType, DeviceId);
153
155 DeviceInfo.DeviceType = DeviceType;
156 DeviceInfo.DeviceIndex = DeviceId;
157
161 sizeof(WDMAUD_DEVICE_INFO),
163 sizeof(WDMAUD_DEVICE_INFO),
164 NULL);
165
166 if ( ! MMSUCCESS(Result) )
167 {
169 }
170
171 /* This is pretty much a big hack right now */
172 switch ( DeviceType )
173 {
175 {
177
178 DeviceInfo.u.MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
179 CopyWideString(MixerCaps->szPname, DeviceInfo.u.MixCaps.szPname);
180
181 MixerCaps->cDestinations = DeviceInfo.u.MixCaps.cDestinations;
182 MixerCaps->fdwSupport = DeviceInfo.u.MixCaps.fdwSupport;
183 MixerCaps->vDriverVersion = DeviceInfo.u.MixCaps.vDriverVersion;
184 MixerCaps->wMid = DeviceInfo.u.MixCaps.wMid;
185 MixerCaps->wPid = DeviceInfo.u.MixCaps.wPid;
186 break;
187 }
189 {
191
192 DeviceInfo.u.WaveOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
193 WaveOutCaps->wMid = DeviceInfo.u.WaveOutCaps.wMid;
194 WaveOutCaps->wPid = DeviceInfo.u.WaveOutCaps.wPid;
195
196 WaveOutCaps->vDriverVersion = DeviceInfo.u.WaveOutCaps.vDriverVersion;
197 CopyWideString(WaveOutCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname);
198
199 WaveOutCaps->dwFormats = DeviceInfo.u.WaveOutCaps.dwFormats;
200 WaveOutCaps->wChannels = DeviceInfo.u.WaveOutCaps.wChannels;
201 WaveOutCaps->dwSupport = DeviceInfo.u.WaveOutCaps.dwSupport;
202 break;
203 }
205 {
207
208 DeviceInfo.u.WaveInCaps.szPname[MAXPNAMELEN-1] = L'\0';
209
210 WaveInCaps->wMid = DeviceInfo.u.WaveInCaps.wMid;
211 WaveInCaps->wPid = DeviceInfo.u.WaveInCaps.wPid;
212
213 WaveInCaps->vDriverVersion = DeviceInfo.u.WaveInCaps.vDriverVersion;
214 CopyWideString(WaveInCaps->szPname, DeviceInfo.u.WaveInCaps.szPname);
215
216 WaveInCaps->dwFormats = DeviceInfo.u.WaveInCaps.dwFormats;
217 WaveInCaps->wChannels = DeviceInfo.u.WaveInCaps.wChannels;
218 WaveInCaps->wReserved1 = 0;
219 break;
220 }
222 {
224
225 DeviceInfo.u.MidiInCaps.szPname[MAXPNAMELEN-1] = L'\0';
226
227 MidiInCaps->vDriverVersion = DeviceInfo.u.MidiInCaps.vDriverVersion;
228 MidiInCaps->wMid = DeviceInfo.u.MidiInCaps.wMid;
229 MidiInCaps->wPid = DeviceInfo.u.MidiInCaps.wPid;
230 MidiInCaps->dwSupport = DeviceInfo.u.MidiInCaps.dwSupport;
231
232 CopyWideString(MidiInCaps->szPname, DeviceInfo.u.MidiInCaps.szPname);
233 break;
234 }
236 {
238
239 DeviceInfo.u.MidiOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
240
241 MidiOutCaps->vDriverVersion = DeviceInfo.u.MidiOutCaps.vDriverVersion;
242 MidiOutCaps->wMid = DeviceInfo.u.MidiOutCaps.wMid;
243 MidiOutCaps->wPid = DeviceInfo.u.MidiOutCaps.wPid;
244 MidiOutCaps->dwSupport = DeviceInfo.u.MidiOutCaps.dwSupport;
245
246 CopyWideString(MidiOutCaps->szPname, DeviceInfo.u.MidiOutCaps.szPname);
247 break;
248 }
249 }
250
251 return MMSYSERR_NOERROR;
252}
253
256 IN PSOUND_DEVICE SoundDevice,
258{
259 HDEVINFO hDevInfo;
260 SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
261 GUID SWBusGuid = {STATIC_KSCATEGORY_WDMAUD};
262 PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData;
263
265 {
267 if (!hDevInfo)
268 {
269 // failed
270 return MMSYSERR_ERROR;
271 }
272
273 DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
274 if (!SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &SWBusGuid, 0, &DeviceInterfaceData))
275 {
276 // failed
278 return MMSYSERR_ERROR;
279 }
280
282 if (!DeviceInterfaceDetailData)
283 {
284 // failed
286 return MMSYSERR_ERROR;
287 }
288
289 DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
290 if (!SetupDiGetDeviceInterfaceDetailW(hDevInfo, &DeviceInterfaceData, DeviceInterfaceDetailData,MAX_PATH * sizeof(WCHAR) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W), NULL, NULL))
291 {
292 // failed
293 HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailData);
295 return MMSYSERR_ERROR;
296 }
297 SND_TRACE(L"Opening wdmaud device '%s'\n",DeviceInterfaceDetailData->DevicePath);
298 KernelHandle = CreateFileW(DeviceInterfaceDetailData->DevicePath,
300 0,
301 NULL,
304 NULL);
305
306 HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailData);
308 }
309
310
312 return MMSYSERR_ERROR;
313
314 ++ OpenCount;
315 return MMSYSERR_NOERROR;
316
317}
318
321 IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
323{
327 PSOUND_DEVICE SoundDevice;
328
329 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
330
331 if ( ! MMSUCCESS(Result) )
332 {
334 }
335
336 if ( OpenCount == 0 )
337 {
338 return MMSYSERR_NOERROR;
339 }
340
342
343 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
345
346 if (SoundDeviceInstance->Handle != (PVOID)KernelHandle)
347 {
349
350 DeviceInfo.DeviceType = DeviceType;
351 DeviceInfo.hDevice = SoundDeviceInstance->Handle;
352
353 /* First stop the stream */
355 {
356 DeviceInfo.u.State = KSSTATE_PAUSE;
360 sizeof(WDMAUD_DEVICE_INFO),
362 sizeof(WDMAUD_DEVICE_INFO),
363 NULL);
364
365 DeviceInfo.u.State = KSSTATE_ACQUIRE;
369 sizeof(WDMAUD_DEVICE_INFO),
371 sizeof(WDMAUD_DEVICE_INFO),
372 NULL);
373
374
375 DeviceInfo.u.State = KSSTATE_STOP;
379 sizeof(WDMAUD_DEVICE_INFO),
381 sizeof(WDMAUD_DEVICE_INFO),
382 NULL);
383 }
384
388 sizeof(WDMAUD_DEVICE_INFO),
390 sizeof(WDMAUD_DEVICE_INFO),
391 NULL);
392 }
393
395 {
396 SetEvent(SoundDeviceInstance->hStopEvent);
397 CloseHandle(SoundDeviceInstance->hStopEvent);
398 CloseHandle(SoundDeviceInstance->hNotifyEvent);
399 }
400
401 --OpenCount;
402
403 if ( OpenCount < 1 )
404 {
407 }
408
409 return MMSYSERR_NOERROR;
410}
411
415 IN DWORD DeviceId,
416 IN PWAVEFORMATEX WaveFormat,
417 IN DWORD WaveFormatSize)
418{
422
423 Instance->hNotifyEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
424 if ( ! Instance->hNotifyEvent )
425 return MMSYSERR_NOMEM;
426
427 if (Instance->Handle != NULL)
428 {
429 /* device is already open */
430 return MMSYSERR_NOERROR;
431 }
432
433 Instance->hStopEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
434 if ( ! Instance->hStopEvent )
435 return MMSYSERR_NOMEM;
436
438 DeviceInfo.DeviceType = MIXER_DEVICE_TYPE;
439 DeviceInfo.DeviceIndex = DeviceId;
440 DeviceInfo.u.hNotifyEvent = Instance->hNotifyEvent;
441
445 sizeof(WDMAUD_DEVICE_INFO),
447 sizeof(WDMAUD_DEVICE_INFO),
448 NULL);
449
450 if ( ! MMSUCCESS(Result) )
451 {
452 CloseHandle(Instance->hNotifyEvent);
453 CloseHandle(Instance->hStopEvent);
455 }
456
458 if ( hThread )
459 {
461 }
462
463 /* Store sound device handle instance handle */
464 Instance->Handle = (PVOID)DeviceInfo.hDevice;
465
466 return MMSYSERR_NOERROR;
467}
468
472 IN DWORD DeviceId,
473 IN PWAVEFORMATEX WaveFormat,
474 IN DWORD WaveFormatSize)
475{
477 PSOUND_DEVICE SoundDevice;
481
483
484 if ( ! MMSUCCESS(Result) )
485 {
487 }
488
490
491 if ( ! MMSUCCESS(Result) )
492 {
494 }
495
496 if (Instance->Handle != NULL)
497 {
498 /* device is already open */
499 return MMSYSERR_NOERROR;
500 }
501
502 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
503
505
507 DeviceInfo.DeviceType = DeviceType;
508 DeviceInfo.DeviceIndex = DeviceId;
509 DeviceInfo.u.WaveFormatEx.cbSize = WaveFormat->cbSize;
510 DeviceInfo.u.WaveFormatEx.wFormatTag = WaveFormat->wFormatTag;
511#ifdef USERMODE_MIXER
512 DeviceInfo.u.WaveFormatEx.nChannels = 2;
513 DeviceInfo.u.WaveFormatEx.nSamplesPerSec = 44100;
514 DeviceInfo.u.WaveFormatEx.nBlockAlign = 4;
515 DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec = 176400;
516 DeviceInfo.u.WaveFormatEx.wBitsPerSample = 16;
517#else
518 DeviceInfo.u.WaveFormatEx.nChannels = WaveFormat->nChannels;
519 DeviceInfo.u.WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
520 DeviceInfo.u.WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
521 DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
522 DeviceInfo.u.WaveFormatEx.wBitsPerSample = (DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec * 8) / (DeviceInfo.u.WaveFormatEx.nSamplesPerSec * DeviceInfo.u.WaveFormatEx.nChannels);
523#endif
524
528 sizeof(WDMAUD_DEVICE_INFO),
530 sizeof(WDMAUD_DEVICE_INFO),
531 NULL);
532
533 if ( ! MMSUCCESS(Result) )
534 {
536 }
537
538 if (WaveFormatSize >= sizeof(WAVEFORMAT))
539 {
540 /* Store format */
541 Instance->WaveFormatEx.wFormatTag = WaveFormat->wFormatTag;
542 Instance->WaveFormatEx.nChannels = WaveFormat->nChannels;
543 Instance->WaveFormatEx.nSamplesPerSec = WaveFormat->nSamplesPerSec;
544 Instance->WaveFormatEx.nBlockAlign = WaveFormat->nBlockAlign;
545 Instance->WaveFormatEx.nAvgBytesPerSec = WaveFormat->nAvgBytesPerSec;
546 }
547
548 /* store details */
549 Instance->WaveFormatEx.cbSize = WaveFormat->cbSize;
550 Instance->WaveFormatEx.wBitsPerSample = (DeviceInfo.u.WaveFormatEx.nAvgBytesPerSec * 8) / (DeviceInfo.u.WaveFormatEx.nSamplesPerSec * DeviceInfo.u.WaveFormatEx.nChannels);
551
552 /* Store sound device handle instance handle */
553 Instance->Handle = (PVOID)DeviceInfo.hDevice;
554
555 /* Now determine framing requirements */
559 sizeof(WDMAUD_DEVICE_INFO),
561 sizeof(WDMAUD_DEVICE_INFO),
562 NULL);
563
564 if ( MMSUCCESS(Result) )
565 {
566 if (DeviceInfo.u.FrameSize)
567 {
568 Instance->FrameSize = DeviceInfo.u.FrameSize * 2;
569 Instance->BufferCount = WaveFormat->nAvgBytesPerSec / Instance->FrameSize;
570 SND_TRACE(L"FrameSize %u BufferCount %u\n", Instance->FrameSize, Instance->BufferCount);
571 }
572 }
573 else
574 {
575 // use a default of 100 buffers
576 Instance->BufferCount = 100;
577 }
578
579 /* Now acquire resources */
580 DeviceInfo.u.State = KSSTATE_ACQUIRE;
582
583 /* pause the pin */
584 DeviceInfo.u.State = KSSTATE_PAUSE;
586
587 /* start the pin */
588 DeviceInfo.u.State = KSSTATE_RUN;
590
591
592 return MMSYSERR_NOERROR;
593}
594
595VOID
598 IN DWORD dwErrorCode,
599 IN DWORD dwNumberOfBytesTransferred,
601{
602 PSOUND_OVERLAPPED Overlap;
604
607
608 /* Call mmebuddy overlap routine */
609 Overlap->OriginalCompletionRoutine(dwErrorCode, DeviceInfo->Header.DataUsed, lpOverlapped);
610
612}
613
616 IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
617 IN PVOID OffsetPtr,
619 IN PSOUND_OVERLAPPED Overlap,
621{
625 PSOUND_DEVICE SoundDevice;
627 BOOL Ret;
628
629 VALIDATE_MMSYS_PARAMETER( SoundDeviceInstance );
630 VALIDATE_MMSYS_PARAMETER( OffsetPtr );
631 VALIDATE_MMSYS_PARAMETER( Overlap );
633
634 GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
636
637 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
638
639 if ( ! MMSUCCESS(Result) )
640 {
642 }
643
644 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
646
648 if (!DeviceInfo)
649 {
650 // no memory
651 return MMSYSERR_NOMEM;
652 }
653
654 DeviceInfo->Header.FrameExtent = Length;
656 {
657 DeviceInfo->Header.DataUsed = Length;
658 }
659 DeviceInfo->Header.Data = OffsetPtr;
660 DeviceInfo->Header.Size = sizeof(WDMAUD_DEVICE_INFO);
661 DeviceInfo->Header.PresentationTime.Numerator = 1;
662 DeviceInfo->Header.PresentationTime.Denominator = 1;
663 DeviceInfo->hDevice = Handle;
664 DeviceInfo->DeviceType = DeviceType;
665
666
667 // create completion event
668 Overlap->Standard.hEvent = Handle = CreateEventW(NULL, FALSE, FALSE, NULL);
669 if (Overlap->Standard.hEvent == NULL)
670 {
671 // no memory
673 return MMSYSERR_NOMEM;
674 }
675
676 Overlap->OriginalCompletionRoutine = CompletionRoutine;
677 Overlap->CompletionContext = (PVOID)DeviceInfo;
678
680 {
682 if (Ret)
684 }
686 {
688 if (Ret)
690 }
691
692 // close event handle
694
695 return MMSYSERR_NOERROR;
696}
697
700 IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
701 IN BOOL bStart)
702{
704 PSOUND_DEVICE SoundDevice;
708
709 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
710
711 if ( ! MMSUCCESS(Result) )
712 {
714 }
715
716 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
718
719 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
721
723 DeviceInfo.hDevice = Handle;
724 DeviceInfo.DeviceType = DeviceType;
725
726 if (bStart)
727 DeviceInfo.u.State = KSSTATE_RUN;
728 else
729 DeviceInfo.u.State = KSSTATE_PAUSE;
733 sizeof(WDMAUD_DEVICE_INFO),
735 sizeof(WDMAUD_DEVICE_INFO),
736 NULL);
737
738 return Result;
739}
740
744 IN DWORD DeviceId,
746 IN DWORD InterfaceLength,
747 OUT DWORD * InterfaceSize)
748{
751
753 DeviceInfo.DeviceType = DeviceType;
754 DeviceInfo.DeviceIndex = DeviceId;
755
756
760 sizeof(WDMAUD_DEVICE_INFO),
762 sizeof(WDMAUD_DEVICE_INFO),
763 NULL);
764
765
766 if ( ! MMSUCCESS(Result) )
767 {
769 }
770
771
772 if (!Interface)
773 {
774 SND_ASSERT(InterfaceSize);
775
776 *InterfaceSize = DeviceInfo.u.Interface.DeviceInterfaceStringSize;
777 return MMSYSERR_NOERROR;
778 }
779
780 if (InterfaceLength < DeviceInfo.u.Interface.DeviceInterfaceStringSize)
781 {
782 /* buffer is too small */
783 return MMSYSERR_MOREDATA;
784 }
785
786 DeviceInfo.u.Interface.DeviceInterfaceStringSize = InterfaceLength;
787 DeviceInfo.u.Interface.DeviceInterfaceString = Interface;
788
792 sizeof(WDMAUD_DEVICE_INFO),
794 sizeof(WDMAUD_DEVICE_INFO),
795 NULL);
796
797 if ( MMSUCCESS(Result) && InterfaceLength > 2)
798 {
799 Interface[1] = L'\\';
800 Interface[InterfaceLength-1] = L'\0';
801 }
802
803 return Result;
804}
805
808 IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
809 IN MMTIME* Time)
810{
812 PSOUND_DEVICE SoundDevice;
816
817 Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
818
819 if ( ! MMSUCCESS(Result) )
820 {
822 }
823
824 Result = GetSoundDeviceType(SoundDevice, &DeviceType);
826
827 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
829
831 DeviceInfo.hDevice = Handle;
832 DeviceInfo.DeviceType = DeviceType;
833
837 sizeof(WDMAUD_DEVICE_INFO),
839 sizeof(WDMAUD_DEVICE_INFO),
840 NULL);
841
842 if ( ! MMSUCCESS(Result) )
843 {
845 }
846
847 Time->wType = TIME_BYTES;
848 Time->u.cb = (DWORD)DeviceInfo.u.Position;
849
850 return MMSYSERR_NOERROR;
851}
852
855 _In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
856 _In_ DWORD DeviceId,
857 _Out_ PDWORD pdwVolume)
858{
859 /* FIXME */
861}
862
865 _In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
866 _In_ DWORD DeviceId,
867 _In_ DWORD dwVolume)
868{
869 /* FIXME */
871}
872
875 IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
877 IN BOOLEAN bStartReset)
878{
882
883 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
885
887 DeviceInfo.hDevice = Handle;
888 DeviceInfo.DeviceType = DeviceType;
889 DeviceInfo.u.ResetStream = (bStartReset ? KSRESET_BEGIN : KSRESET_END);
890
894 sizeof(WDMAUD_DEVICE_INFO),
896 sizeof(WDMAUD_DEVICE_INFO),
897 NULL);
898 return Result;
899}
900
903 IN struct _SOUND_DEVICE_INSTANCE* SoundDeviceInstance,
904 IN DWORD DeviceId,
905 IN UINT uMsg,
907 IN DWORD Flags)
908{
913 LPMIXERLINEW MixLine;
914 LPMIXERLINECONTROLSW MixControls;
915 LPMIXERCONTROLDETAILS MixDetails;
916
917 SND_TRACE(L"uMsg %x Flags %x\n", uMsg, Flags);
918
919 Result = GetSoundDeviceInstanceHandle(SoundDeviceInstance, &Handle);
921
923 DeviceInfo.hDevice = Handle;
924 DeviceInfo.DeviceIndex = DeviceId;
925 DeviceInfo.DeviceType = MIXER_DEVICE_TYPE;
926 DeviceInfo.Flags = Flags;
927
928 MixLine = (LPMIXERLINEW)Parameter;
929 MixControls = (LPMIXERLINECONTROLSW)Parameter;
930 MixDetails = (LPMIXERCONTROLDETAILS)Parameter;
931
932 switch(uMsg)
933 {
934 case MXDM_GETLINEINFO:
935 RtlCopyMemory(&DeviceInfo.u.MixLine, MixLine, sizeof(MIXERLINEW));
937 break;
939 RtlCopyMemory(&DeviceInfo.u.MixControls, MixControls, sizeof(MIXERLINECONTROLSW));
941 break;
943 RtlCopyMemory(&DeviceInfo.u.MixDetails, MixDetails, sizeof(MIXERCONTROLDETAILS));
945 break;
947 RtlCopyMemory(&DeviceInfo.u.MixDetails, MixDetails, sizeof(MIXERCONTROLDETAILS));
949 break;
950 default:
951 SND_ASSERT(0);
953 }
954
958 sizeof(WDMAUD_DEVICE_INFO),
960 sizeof(WDMAUD_DEVICE_INFO),
961 NULL);
962
963 if ( ! MMSUCCESS(Result) )
964 {
965 return Result;
966 }
967
968 switch(uMsg)
969 {
970 case MXDM_GETLINEINFO:
971 {
972 RtlCopyMemory(MixLine, &DeviceInfo.u.MixLine, sizeof(MIXERLINEW));
973 break;
974 }
975 }
976
977 return Result;
978}
unsigned char BOOLEAN
@ Identifier
Definition: asmpp.cpp:95
#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
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOL WINAPI ReadFileEx(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: rw.c:299
BOOL WINAPI WriteFileEx(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: rw.c:262
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:137
#define MXDM_GETCONTROLDETAILS
Definition: mmddk.h:197
#define MXDM_GETLINECONTROLS
Definition: mmddk.h:196
#define MXDM_SETCONTROLDETAILS
Definition: mmddk.h:198
#define MXDM_GETLINEINFO
Definition: mmddk.h:195
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
BOOL WINAPI SetupDiEnumDeviceInterfaces(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, CONST GUID *InterfaceClassGuid, DWORD MemberIndex, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
Definition: devinst.c:2780
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2292
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:3011
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
MMRESULT WdmAudSetMixerDeviceFormatByLegacy(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: legacy.c:413
MMRESULT WdmAudQueryMixerInfoByLegacy(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN DWORD DeviceId, IN UINT uMsg, IN LPVOID Parameter, IN DWORD Flags)
Definition: legacy.c:902
DWORD OpenCount
Definition: legacy.c:25
MMRESULT WdmAudOpenSoundDeviceByLegacy(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Handle)
Definition: legacy.c:255
MMRESULT WdmAudGetWavePositionByLegacy(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMTIME *Time)
Definition: legacy.c:807
MMRESULT WdmAudSetVolumeByLegacy(_In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance, _In_ DWORD DeviceId, _In_ DWORD dwVolume)
Definition: legacy.c:864
MMRESULT WdmAudSetWaveStateByLegacy(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN BOOL bStart)
Definition: legacy.c:699
MMRESULT WdmAudGetDeviceInterfaceStringByLegacy(IN MMDEVICE_TYPE DeviceType, IN DWORD DeviceId, IN LPWSTR Interface, IN DWORD InterfaceLength, OUT DWORD *InterfaceSize)
Definition: legacy.c:742
MMRESULT WdmAudCloseSoundDeviceByLegacy(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN PVOID Handle)
Definition: legacy.c:320
MMRESULT WdmAudCommitWaveBufferByLegacy(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID OffsetPtr, IN DWORD Length, IN PSOUND_OVERLAPPED Overlap, IN LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine)
Definition: legacy.c:615
MMRESULT WdmAudGetCapabilitiesByLegacy(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: legacy.c:133
MMRESULT WdmAudResetStreamByLegacy(IN struct _SOUND_DEVICE_INSTANCE *SoundDeviceInstance, IN MMDEVICE_TYPE DeviceType, IN BOOLEAN bStartReset)
Definition: legacy.c:874
MMRESULT WdmAudCleanupByLegacy()
Definition: legacy.c:86
MMRESULT WdmAudSetWaveDeviceFormatByLegacy(IN PSOUND_DEVICE_INSTANCE Instance, IN DWORD DeviceId, IN PWAVEFORMATEX WaveFormat, IN DWORD WaveFormatSize)
Definition: legacy.c:470
MMRESULT WdmAudGetVolumeByLegacy(_In_ PSOUND_DEVICE_INSTANCE SoundDeviceInstance, _In_ DWORD DeviceId, _Out_ PDWORD pdwVolume)
Definition: legacy.c:854
HANDLE KernelHandle
Definition: legacy.c:24
DWORD WINAPI MixerEventThreadRoutine(LPVOID Parameter)
Definition: legacy.c:29
MMRESULT WdmAudGetNumWdmDevsByLegacy(IN MMDEVICE_TYPE DeviceType, OUT DWORD *DeviceCount)
Definition: legacy.c:98
VOID CALLBACK LegacyCompletionRoutine(IN DWORD dwErrorCode, IN DWORD dwNumberOfBytesTransferred, IN LPOVERLAPPED lpOverlapped)
Definition: legacy.c:597
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Handle
Definition: gdb_input.c:15
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
@ KSRESET_BEGIN
Definition: ks.h:1227
@ KSRESET_END
Definition: ks.h:1228
@ KSSTATE_ACQUIRE
Definition: ks.h:1216
@ KSSTATE_PAUSE
Definition: ks.h:1217
@ KSSTATE_RUN
Definition: ks.h:1218
@ KSSTATE_STOP
Definition: ks.h:1215
#define STATIC_KSCATEGORY_WDMAUD
Definition: ksmedia.h:219
DeviceType
Definition: mmdrv.h:42
struct _SOUND_DEVICE_INSTANCE * PSOUND_DEVICE_INSTANCE
struct _SOUND_OVERLAPPED * PSOUND_OVERLAPPED
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define CopyWideString(dest, source)
Definition: mmebuddy.h:39
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
MMRESULT GetSoundDeviceInstanceHandle(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PVOID *Handle)
MMRESULT GetSoundDeviceIdentifier(IN PSOUND_DEVICE SoundDevice, OUT PVOID *Identifier)
Definition: devicelist.c:328
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_TRACE(...)
#define SND_ERR(...)
#define SND_ASSERT(condition)
#define TIME_BYTES
Definition: mmsystem.h:30
#define MMSYSERR_NOMEM
Definition: mmsystem.h:103
struct tagMIXERLINECONTROLSW * LPMIXERLINECONTROLSW
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_MOREDATA
Definition: mmsystem.h:117
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
struct tagMIXERCAPSW * LPMIXERCAPSW
struct tagWAVEINCAPSW * LPWAVEINCAPSW
struct tagMIDIOUTCAPSW * LPMIDIOUTCAPSW
struct tagMIDIINCAPSW * LPMIDIINCAPSW
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define MMSYSERR_ERROR
Definition: mmsystem.h:97
#define MAXPNAMELEN
Definition: mmsystem.h:24
struct tagMIXERLINEW * LPMIXERLINEW
struct tMIXERCONTROLDETAILS * LPMIXERCONTROLDETAILS
struct tagWAVEOUTCAPSW * LPWAVEOUTCAPSW
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
static PLARGE_INTEGER Time
Definition: time.c:105
ULONG DeviceCount
Definition: mpu401.c:26
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
DWORD * PDWORD
Definition: pedump.c:68
#define DIGCF_DEVICEINTERFACE
Definition: setupapi.h:174
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA_W
#define DIGCF_PRESENT
Definition: setupapi.h:171
struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * PSP_DEVICE_INTERFACE_DETAIL_DATA_W
struct _SP_DEVICE_INTERFACE_DATA SP_DEVICE_INTERFACE_DATA
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
WCHAR Data[ANYSIZE_ARRAY]
PVOID CompletionContext
Definition: mmebuddy.h:125
LPOVERLAPPED_COMPLETION_ROUTINE OriginalCompletionRoutine
Definition: mmebuddy.h:124
WCHAR DevicePath[ANYSIZE_ARRAY]
Definition: setupapi.h:855
MMVERSION vDriverVersion
Definition: mmsystem.h:1145
DWORD dwSupport
Definition: mmsystem.h:1147
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1146
MMVERSION vDriverVersion
Definition: mmsystem.h:1125
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1126
DWORD cDestinations
Definition: mmsystem.h:1228
MMVERSION vDriverVersion
Definition: mmsystem.h:1225
DWORD fdwSupport
Definition: mmsystem.h:1227
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1226
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1060
MMVERSION vDriverVersion
Definition: mmsystem.h:1059
DWORD dwFormats
Definition: mmsystem.h:1061
MMVERSION vDriverVersion
Definition: mmsystem.h:1038
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
uint32_t DWORD_PTR
Definition: typedefs.h:65
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
#define HIWORD(l)
Definition: typedefs.h:247
#define OUT
Definition: typedefs.h:40
struct _LARGE_INTEGER::@2304 u
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
#define IOCTL_GETFRAMESIZE
Definition: interface.h:255
#define IOCTL_CLOSE_WDMAUD
Definition: interface.h:99
#define IOCTL_GETPOS
Definition: interface.h:238
#define IOCTL_GETCONTROLDETAILS
Definition: interface.h:325
#define IOCTL_OPEN_WDMAUD
Definition: interface.h:82
#define IOCTL_RESET_STREAM
Definition: interface.h:374
#define IOCTL_GETCAPABILITIES
Definition: interface.h:204
#define IOCTL_SETCONTROLDETAILS
Definition: interface.h:307
#define IOCTL_GETLINEINFO
Definition: interface.h:272
#define IOCTL_SETDEVICE_STATE
Definition: interface.h:134
#define IOCTL_QUERYDEVICEINTERFACESTRING
Definition: interface.h:343
#define IOCTL_GETNUMDEVS_TYPE
Definition: interface.h:117
#define IOCTL_GETLINECONTROLS
Definition: interface.h:290
#define IOCTL_GET_MIXER_EVENT
Definition: interface.h:359
struct WDMAUD_DEVICE_INFO * PWDMAUD_DEVICE_INFO
#define ZeroMemory
Definition: winbase.h:1737
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
Definition: winbase.h:1476
#define WAIT_OBJECT_0
Definition: winbase.h:432
#define WINAPI
Definition: msvc.h:6
_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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184