ReactOS 0.4.15-dev-8102-g108db8f
sup.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: lib/drivers/sound/mmixer/sup.c
5 * PURPOSE: Mixer Support Functions
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "precomp.h"
10
11// #define NDEBUG
12#include <debug.h>
13
14const GUID KSNODETYPE_SUM = {0xDA441A60L, 0xC556, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
15const GUID KSNODETYPE_DAC = {0x507AE360L, 0xC554, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
16const GUID KSNODETYPE_ADC = {0x4D837FE0L, 0xC555, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
17const GUID KSNODETYPE_AGC = {0xE88C9BA0L, 0xC557, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
18const GUID KSNODETYPE_LOUDNESS = {0x41887440L, 0xC558, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
19const GUID KSNODETYPE_MUTE = {0x02B223C0L, 0xC557, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
20const GUID KSNODETYPE_TONE = {0x7607E580L, 0xC557, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
21const GUID KSNODETYPE_VOLUME = {0x3A5ACC00L, 0xC557, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
22const GUID KSNODETYPE_PEAKMETER = {0xa085651e, 0x5f0d, 0x4b36, {0xa8, 0x69, 0xd1, 0x95, 0xd6, 0xab, 0x4b, 0x9e}};
23const GUID KSNODETYPE_MUX = {0x2CEAF780, 0xC556, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
24const GUID KSNODETYPE_STEREO_WIDE = {0xA9E69800L, 0xC558, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
25const GUID KSNODETYPE_CHORUS = {0x20173F20L, 0xC559, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
26const GUID KSNODETYPE_REVERB = {0xEF0328E0L, 0xC558, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
27const GUID KSNODETYPE_SUPERMIX = {0xE573ADC0L, 0xC555, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
28
29const GUID KSPROPSETID_Audio = {0x45FFAAA0L, 0x6E1B, 0x11D0, {0xBC, 0xF2, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
30const GUID KSPROPSETID_Pin = {0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
31const GUID KSPROPSETID_General = {0x1464EDA5L, 0x6A8F, 0x11D1, {0x9A, 0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
32const GUID KSPROPSETID_Topology = {0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
33const GUID KSEVENTSETID_AudioControlChange = {0xE85E9698L, 0xFA2F, 0x11D1, {0x95, 0xBD, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}};
34
35const GUID KSDATAFORMAT_TYPE_MUSIC = {0xE725D360L, 0x62CC, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
36const GUID KSDATAFORMAT_SUBTYPE_MIDI = {0x1D262760L, 0xE957, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
37const GUID KSDATAFORMAT_SPECIFIER_NONE = {0x0F6417D6L, 0xC318, 0x11D0, {0xA4, 0x3F, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
38
42{
45
50
53
54 return MM_STATUS_SUCCESS;
55}
56
59 IN LPMIXER_INFO MixerInfo,
60 IN ULONG NodeID)
61{
62 PLIST_ENTRY Entry, ControlEntry;
63 LPMIXERLINE_EXT MixerLineSrc;
64 LPMIXERCONTROL_EXT MixerControl;
65
66 /* get first entry */
67 Entry = MixerInfo->LineList.Flink;
68
69 while(Entry != &MixerInfo->LineList)
70 {
72
73 ControlEntry = MixerLineSrc->ControlsList.Flink;
74 while(ControlEntry != &MixerLineSrc->ControlsList)
75 {
76 MixerControl = (LPMIXERCONTROL_EXT)CONTAINING_RECORD(ControlEntry, MIXERCONTROL_EXT, Entry);
77 if (MixerControl->NodeID == NodeID)
78 {
79 return MixerLineSrc;
80 }
81 ControlEntry = ControlEntry->Flink;
82 }
83 Entry = Entry->Flink;
84 }
85
86 return NULL;
87}
88
89VOID
91 IN ULONG LogicalPinArrayCount,
92 IN PULONG LogicalPinArray,
93 OUT PULONG PinOffset)
94{
96 ULONG LowestId = 0;
97
98 for(Index = 1; Index < LogicalPinArrayCount; Index++)
99 {
100 if (LogicalPinArray[Index] != MAXULONG)
101 {
102 /* sanity check: logical pin id must be unique */
103 ASSERT(LogicalPinArray[Index] != LogicalPinArray[LowestId]);
104 }
105
106 if (LogicalPinArray[Index] < LogicalPinArray[LowestId])
107 LowestId = Index;
108 }
109
110 /* store result */
111 *PinOffset = LowestId;
112}
113
114VOID
117 IN LPMIXER_INFO MixerInfo)
118{
119 /* UNIMPLEMENTED;
120 * FIXME
121 * free all lines
122 */
123
124 MixerContext->Free((PVOID)MixerInfo);
125}
126
130 IN HANDLE hDevice)
131{
132 LPMIXER_DATA MixerData;
134 PMIXER_LIST MixerList;
135
136 /* get mixer list */
138
139 if (!MixerList->MixerDataCount)
140 return NULL;
141
142 Entry = MixerList->MixerData.Flink;
143
144 while(Entry != &MixerList->MixerData)
145 {
147
148 if (MixerData->hDevice == hDevice)
149 return MixerData;
150
151 /* move to next mixer entry */
152 Entry = Entry->Flink;
153 }
154 return NULL;
155}
156
160 IN ULONG MixerIndex)
161{
162 LPMIXER_INFO MixerInfo;
164 PMIXER_LIST MixerList;
165 ULONG Index = 0;
166
167 /* get mixer list */
169
170 if (!MixerList->MixerListCount)
171 return NULL;
172
173 Entry = MixerList->MixerList.Flink;
174
175 while(Entry != &MixerList->MixerList)
176 {
178
179 if (Index == MixerIndex)
180 return MixerInfo;
181
182 /* move to next mixer entry */
183 Index++;
184 Entry = Entry->Flink;
185 }
186
187 return NULL;
188}
189
192 IN PMIXER_LIST MixerList,
193 IN LPWSTR MixerName,
194 OUT LPMIXER_INFO *OutMixerInfo)
195{
196 LPMIXER_INFO MixerInfo;
198
199 Entry = MixerList->MixerList.Flink;
200 while(Entry != &MixerList->MixerList)
201 {
203
204 DPRINT1("MixerName %S MixerName %S\n", MixerInfo->MixCaps.szPname, MixerName);
205 if (wcsicmp(MixerInfo->MixCaps.szPname, MixerName) == 0)
206 {
207 *OutMixerInfo = MixerInfo;
208 return MM_STATUS_SUCCESS;
209 }
210 /* move to next mixer entry */
211 Entry = Entry->Flink;
212 }
213
215}
216
219 LPMIXER_INFO MixerInfo,
220 DWORD dwLineID)
221{
223 LPMIXERLINE_EXT MixerLineSrc;
224
225 /* get first entry */
226 Entry = MixerInfo->LineList.Flink;
227
228 while(Entry != &MixerInfo->LineList)
229 {
231 DPRINT("dwLineID %x dwLineID %x MixerLineSrc %p\n", MixerLineSrc->Line.dwLineID, dwLineID, MixerLineSrc);
232 if (MixerLineSrc->Line.dwLineID == dwLineID)
233 return MixerLineSrc;
234
235 Entry = Entry->Flink;
236 }
237
238 return NULL;
239}
240
241LPGUID
243 IN PKSMULTIPLE_ITEM MultipleItem,
244 IN ULONG Index)
245{
247
248 ASSERT(Index < MultipleItem->Count);
249
250 NodeType = (LPGUID)(MultipleItem + 1);
251 return &NodeType[Index];
252}
253
256 LPMIXER_INFO MixerInfo,
257 DWORD dwComponentType)
258{
260 LPMIXERLINE_EXT MixerLineSrc;
261
262 /* get first entry */
263 Entry = MixerInfo->LineList.Flink;
264
265 while(Entry != &MixerInfo->LineList)
266 {
268 if (MixerLineSrc->Line.dwComponentType == dwComponentType)
269 return MixerLineSrc;
270
271 Entry = Entry->Flink;
272 }
273
274 return NULL;
275}
276
279 LPMIXER_INFO MixerInfo,
280 DWORD dwControlID,
281 LPMIXERLINE_EXT *OutMixerLine,
282 LPMIXERCONTROL_EXT *OutMixerControl,
283 PULONG NodeId)
284{
285 PLIST_ENTRY Entry, ControlEntry;
286 LPMIXERLINE_EXT MixerLineSrc;
287 LPMIXERCONTROL_EXT MixerControl;
288
289 /* get first entry */
290 Entry = MixerInfo->LineList.Flink;
291
292 while(Entry != &MixerInfo->LineList)
293 {
295
296 ControlEntry = MixerLineSrc->ControlsList.Flink;
297 while(ControlEntry != &MixerLineSrc->ControlsList)
298 {
299 MixerControl = (LPMIXERCONTROL_EXT)CONTAINING_RECORD(ControlEntry, MIXERCONTROL_EXT, Entry);
300 if (MixerControl->Control.dwControlID == dwControlID)
301 {
302 if (OutMixerLine)
303 *OutMixerLine = MixerLineSrc;
304 if (OutMixerControl)
305 *OutMixerControl = MixerControl;
306 if (NodeId)
307 *NodeId = MixerControl->NodeID;
308 return MM_STATUS_SUCCESS;
309 }
310 ControlEntry = ControlEntry->Flink;
311 }
312 Entry = Entry->Flink;
313 }
314
316}
317
318ULONG
320 LPMIXERVOLUME_DATA VolumeData,
321 LONG Value)
322{
323 ULONG Index;
324
325 for(Index = 0; Index < VolumeData->ValuesCount; Index++)
326 {
327 if (VolumeData->Values[Index] > Value)
328 {
329 return VolumeData->InputSteppingDelta * Index;
330 }
331 }
332 return VolumeData->InputSteppingDelta * (VolumeData->ValuesCount-1);
333}
334
335VOID
338 IN LPMIXER_INFO MixerInfo,
340 IN ULONG Value)
341{
344
345 /* enumerate list and perform notification */
346 Entry = MixerInfo->EventList.Flink;
347 while(Entry != &MixerInfo->EventList)
348 {
349 /* get notification entry offset */
351
352 if (NotificationEntry->MixerEventRoutine)
353 {
354 /* now perform the callback */
355 NotificationEntry->MixerEventRoutine(NotificationEntry->MixerEventContext, (HANDLE)MixerInfo, NotificationType, Value);
356 }
357
358 /* move to next notification entry */
359 Entry = Entry->Flink;
360 }
361}
362
366 IN LPMIXER_INFO MixerInfo,
367 IN LPMIXERCONTROL_EXT MixerControl,
368 IN ULONG dwLineID,
369 IN LPMIXERCONTROLDETAILS MixerControlDetails,
370 IN ULONG bSet)
371{
373 LONG Value;
375
376 if (MixerControlDetails->cbDetails != sizeof(MIXERCONTROLDETAILS_BOOLEAN))
378
379 /* get input */
380 Input = (LPMIXERCONTROLDETAILS_BOOLEAN)MixerControlDetails->paDetails;
381
382 /* FIXME SEH */
383 if (bSet)
384 Value = Input->fValue;
385
386 /* set control details */
387 Status = MMixerSetGetControlDetails(MixerContext, MixerControl->hDevice, MixerControl->NodeID, bSet, KSPROPERTY_AUDIO_MUTE, 0, &Value);
388
390 return Status;
391
392 /* FIXME SEH */
393 if (!bSet)
394 {
395 Input->fValue = Value;
396 return Status;
397 }
398 else
399 {
400 /* notify wdmaud clients MM_MIXM_LINE_CHANGE dwLineID */
402 }
403
404 return Status;
405}
406
410 IN LPMIXER_INFO MixerInfo,
411 IN ULONG NodeId,
412 IN ULONG bSet,
413 IN ULONG Flags,
414 IN LPMIXERCONTROL_EXT MixerControl,
415 IN LPMIXERCONTROLDETAILS MixerControlDetails,
416 IN LPMIXERLINE_EXT MixerLine)
417{
419 PULONG LogicalNodes, ConnectedNodes;
420 ULONG LogicalNodesCount, ConnectedNodesCount, Index, CurLogicalPinOffset, BytesReturned, OldLogicalPinOffset;
421 LPMIXER_DATA MixerData;
424 LPMIXERLINE_EXT SourceLine;
426
427 DPRINT("MixerControlDetails %p\n", MixerControlDetails);
428 DPRINT("bSet %lx\n", bSet);
429 DPRINT("Flags %lx\n", Flags);
430 DPRINT("NodeId %lu\n", MixerControl->NodeID);
431 DPRINT("MixerControlDetails dwControlID %lu\n", MixerControlDetails->dwControlID);
432 DPRINT("MixerControlDetails cChannels %lu\n", MixerControlDetails->cChannels);
433 DPRINT("MixerControlDetails cMultipleItems %lu\n", MixerControlDetails->cMultipleItems);
434 DPRINT("MixerControlDetails cbDetails %lu\n", MixerControlDetails->cbDetails);
435 DPRINT("MixerControlDetails paDetails %p\n", MixerControlDetails->paDetails);
436
437 if (MixerControl->Control.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM)
438 {
439 /* control acts uniform */
440 if (MixerControlDetails->cChannels != 1)
441 {
442 /* expected 1 channel */
443 DPRINT1("Expected 1 channel but got %lu\n", MixerControlDetails->cChannels);
445 }
446 }
447
448 /* check if multiple items match */
449 if (MixerControlDetails->cMultipleItems != MixerControl->Control.cMultipleItems)
450 {
451 DPRINT1("MultipleItems mismatch %lu expected %lu\n", MixerControlDetails->cMultipleItems, MixerControl->Control.cMultipleItems);
453 }
454
455 if (bSet)
456 {
458 {
459 /* tell me when this is hit */
460 ASSERT(FALSE);
461 }
463 {
464 /* sanity check */
465 ASSERT(bSet == TRUE);
466 ASSERT(MixerControlDetails->cbDetails == sizeof(MIXERCONTROLDETAILS_BOOLEAN));
467
468 Values = (LPMIXERCONTROLDETAILS_BOOLEAN)MixerControlDetails->paDetails;
469 CurLogicalPinOffset = MAXULONG;
470 for(Index = 0; Index < MixerControlDetails->cMultipleItems; Index++)
471 {
472 if (Values[Index].fValue)
473 {
474 /* mux can only activate one line at a time */
475 ASSERT(CurLogicalPinOffset == MAXULONG);
476 CurLogicalPinOffset = Index;
477 }
478 }
479
480 /* setup request */
481 Request.NodeId = NodeId;
482 Request.Reserved = 0;
485 Request.Property.Set = KSPROPSETID_Audio;
486
487 /* perform getting source */
488 Status = MixerContext->Control(MixerControl->hDevice, IOCTL_KS_PROPERTY, (PVOID)&Request, sizeof(KSNODEPROPERTY), &OldLogicalPinOffset, sizeof(ULONG), &BytesReturned);
490 {
491 /* failed to get source */
492 return Status;
493 }
494
495 DPRINT("OldLogicalPinOffset %lu CurLogicalPinOffset %lu\n", OldLogicalPinOffset, CurLogicalPinOffset);
496
497 if (OldLogicalPinOffset == CurLogicalPinOffset)
498 {
499 /* cannot be unselected */
501 }
502
503 /* perform setting source */
505 Status = MixerContext->Control(MixerControl->hDevice, IOCTL_KS_PROPERTY, (PVOID)&Request, sizeof(KSNODEPROPERTY), &CurLogicalPinOffset, sizeof(ULONG), &BytesReturned);
507 {
508 /* failed to set source */
509 return Status;
510 }
511
512 /* notify control change */
513 MMixerNotifyControlChange(MixerContext, MixerInfo, MM_MIXM_CONTROL_CHANGE, MixerControl->Control.dwControlID );
514
515 return Status;
516 }
517 }
518 else
519 {
521 {
522 /* setup request */
523 Request.NodeId = NodeId;
524 Request.Reserved = 0;
527 Request.Property.Set = KSPROPSETID_Audio;
528
529 /* perform getting source */
530 Status = MixerContext->Control(MixerControl->hDevice, IOCTL_KS_PROPERTY, (PVOID)&Request, sizeof(KSNODEPROPERTY), &OldLogicalPinOffset, sizeof(ULONG), &BytesReturned);
532 {
533 /* failed to get source */
534 return Status;
535 }
536
537 /* gets the corresponding mixer data */
538 MixerData = MMixerGetMixerDataByDeviceHandle(MixerContext, MixerControl->hDevice);
539
540 /* sanity check */
541 ASSERT(MixerData);
542 ASSERT(MixerData->Topology);
543 ASSERT(MixerData->MixerInfo == MixerInfo);
544
545 /* now allocate logical pin array */
546 Status = MMixerAllocateTopologyNodeArray(MixerContext, MixerData->Topology, &LogicalNodes);
548 {
549 /* no memory */
550 return MM_STATUS_NO_MEMORY;
551 }
552
553 /* get logical pin nodes */
554 MMixerGetConnectedFromLogicalTopologyPins(MixerData->Topology, MixerControl->NodeID, &LogicalNodesCount, LogicalNodes);
555
556 /* sanity check */
557 ASSERT(LogicalNodesCount == MixerControlDetails->cMultipleItems);
558 ASSERT(LogicalNodesCount == MixerControl->Control.Metrics.dwReserved[0]);
559
560 Values = (LPMIXERCONTROLDETAILS_BOOLEAN)MixerControlDetails->paDetails;
561 for(Index = 0; Index < LogicalNodesCount; Index++)
562 {
563 /* getting logical pin offset */
564 MMixerGetLowestLogicalTopologyPinOffsetFromArray(LogicalNodesCount, LogicalNodes, &CurLogicalPinOffset);
565
566 if (CurLogicalPinOffset == OldLogicalPinOffset)
567 {
568 /* mark index as active */
569 Values[Index].fValue = TRUE;
570 }
571 else
572 {
573 /* index not active */
574 Values[Index].fValue = FALSE;
575 }
576
577 /* mark offset as consumed */
578 LogicalNodes[CurLogicalPinOffset] = MAXULONG;
579 }
580
581 /* cleanup */
582 MixerContext->Free(LogicalNodes);
583
584 /* done */
585 return MM_STATUS_SUCCESS;
586 }
588 {
589 /* sanity check */
590 ASSERT(bSet == FALSE);
591
592 /* gets the corresponding mixer data */
593 MixerData = MMixerGetMixerDataByDeviceHandle(MixerContext, MixerControl->hDevice);
594
595 /* sanity check */
596 ASSERT(MixerData);
597 ASSERT(MixerData->Topology);
598 ASSERT(MixerData->MixerInfo == MixerInfo);
599
600 /* now allocate logical pin array */
601 Status = MMixerAllocateTopologyNodeArray(MixerContext, MixerData->Topology, &LogicalNodes);
603 {
604 /* no memory */
605 return MM_STATUS_NO_MEMORY;
606 }
607
608 /* allocate connected node array */
609 Status = MMixerAllocateTopologyNodeArray(MixerContext, MixerData->Topology, &ConnectedNodes);
611 {
612 /* no memory */
613 MixerContext->Free(LogicalNodes);
614 return MM_STATUS_NO_MEMORY;
615 }
616
617 /* get logical pin nodes */
618 MMixerGetConnectedFromLogicalTopologyPins(MixerData->Topology, MixerControl->NodeID, &LogicalNodesCount, LogicalNodes);
619
620 /* get connected nodes */
621 MMixerGetNextNodesFromNodeIndex(MixerContext, MixerData->Topology, MixerControl->NodeID, TRUE, &ConnectedNodesCount, ConnectedNodes);
622
623 /* sanity check */
624 ASSERT(ConnectedNodesCount == LogicalNodesCount);
625 ASSERT(ConnectedNodesCount == MixerControlDetails->cMultipleItems);
626 ASSERT(ConnectedNodesCount == MixerControl->Control.Metrics.dwReserved[0]);
627
628 ListText = (LPMIXERCONTROLDETAILS_LISTTEXTW)MixerControlDetails->paDetails;
629
630 for(Index = 0; Index < ConnectedNodesCount; Index++)
631 {
632 /* getting logical pin offset */
633 MMixerGetLowestLogicalTopologyPinOffsetFromArray(LogicalNodesCount, LogicalNodes, &CurLogicalPinOffset);
634
635 /* get mixer line with that node */
636 SourceLine = MMixerGetMixerLineContainingNodeId(MixerInfo, ConnectedNodes[CurLogicalPinOffset]);
637
638 /* sanity check */
639 ASSERT(SourceLine);
640
641 DPRINT1("PinOffset %lu LogicalPin %lu NodeId %lu LineName %S\n", CurLogicalPinOffset, LogicalNodes[CurLogicalPinOffset], ConnectedNodes[CurLogicalPinOffset], SourceLine->Line.szName);
642
643 /* copy details */
644 ListText[Index].dwParam1 = SourceLine->Line.dwLineID;
645 ListText[Index].dwParam2 = SourceLine->Line.dwComponentType;
646 MixerContext->Copy(ListText[Index].szName, SourceLine->Line.szName, (wcslen(SourceLine->Line.szName) + 1) * sizeof(WCHAR));
647
648 /* mark offset as consumed */
649 LogicalNodes[CurLogicalPinOffset] = MAXULONG;
650 }
651
652 /* cleanup */
653 MixerContext->Free(LogicalNodes);
654 MixerContext->Free(ConnectedNodes);
655
656 /* done */
657 return MM_STATUS_SUCCESS;
658 }
659 }
660
662}
663
667 IN LPMIXER_INFO MixerInfo,
668 IN ULONG NodeId,
669 IN ULONG bSet,
670 LPMIXERCONTROL_EXT MixerControl,
671 IN LPMIXERCONTROLDETAILS MixerControlDetails,
672 LPMIXERLINE_EXT MixerLine)
673{
675 LONG Value;
676 ULONG Index, Channel = 0;
677 ULONG dwValue;
679 LPMIXERVOLUME_DATA VolumeData;
680
681 if (MixerControlDetails->cbDetails != sizeof(MIXERCONTROLDETAILS_SIGNED))
683
684 VolumeData = (LPMIXERVOLUME_DATA)MixerControl->ExtraData;
685 if (!VolumeData)
687
688 /* get input */
689 Input = (LPMIXERCONTROLDETAILS_UNSIGNED)MixerControlDetails->paDetails;
690 if (!Input)
691 return MM_STATUS_UNSUCCESSFUL; /* to prevent dereferencing NULL */
692
693 if (bSet)
694 {
695 /* FIXME SEH */
696 Value = Input->dwValue;
697 Index = Value / VolumeData->InputSteppingDelta;
698
699 if (Index >= VolumeData->ValuesCount)
700 {
701 DPRINT1("Index %u out of bounds %u \n", Index, VolumeData->ValuesCount);
703 }
704
705 Value = VolumeData->Values[Index];
706 }
707
708 /* set control details */
709 if (bSet)
710 {
711 /* TODO */
714 }
715 else
716 {
718 }
719
720 if (!bSet)
721 {
722 dwValue = MMixerGetVolumeControlIndex(VolumeData, (LONG)Value);
723 /* FIXME SEH */
724 Input->dwValue = dwValue;
725 }
726 else
727 {
728 /* notify clients of a line change MM_MIXM_CONTROL_CHANGE with MixerControl->dwControlID */
730 }
731 return Status;
732}
733
736 IN PMIXER_LIST MixerList,
737 IN ULONG DeviceId)
738{
740 LPMIXER_DATA MixerData;
741
742 Entry = MixerList->MixerData.Flink;
743 while(Entry != &MixerList->MixerData)
744 {
746 if (MixerData->DeviceId == DeviceId)
747 {
748 return MixerData;
749 }
750 Entry = Entry->Flink;
751 }
752 return NULL;
753}
754
757 IN PMIXER_LIST MixerList,
759{
761 LPMIXER_DATA MixerData;
762
763 Entry = MixerList->MixerData.Flink;
764 while(Entry != &MixerList->MixerData)
765 {
767 if (wcsicmp(&DeviceName[2], &MixerData->DeviceName[2]) == 0)
768 {
769 /* found entry */
770 return MixerData;
771 }
772 Entry = Entry->Flink;
773 }
774 return NULL;
775}
776
780 IN PMIXER_LIST MixerList,
781 IN ULONG DeviceId,
783 IN HANDLE hDevice,
784 IN HANDLE hKey)
785{
786 LPMIXER_DATA MixerData;
787
788 MixerData = (LPMIXER_DATA)MixerContext->Alloc(sizeof(MIXER_DATA));
789 if (!MixerData)
790 return MM_STATUS_NO_MEMORY;
791
792 MixerData->DeviceId = DeviceId;
793 MixerData->DeviceName = DeviceName;
794 MixerData->hDevice = hDevice;
795 MixerData->hDeviceInterfaceKey = hKey;
796 MixerData->Topology = NULL;
797
798 InsertTailList(&MixerList->MixerData, &MixerData->Entry);
799 MixerList->MixerDataCount++;
800 return MM_STATUS_SUCCESS;
801}
802
807 OUT LPWSTR OutDeviceName)
808{
814 ULONG ResultLength, KeyType;
815 HANDLE hMediaKey, hGuidKey;
817
818 /* prepare property */
822
823 /* try get component id */
825
827 {
828 Status = MixerContext->OpenKey(NULL, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\MediaCategories", KEY_READ, &hMediaKey);
830 {
832 Status = MixerContext->OpenKey(hMediaKey, GuidString.Buffer, KEY_READ, &hGuidKey);
835 {
836 Status = MixerContext->QueryKeyValue(hGuidKey, L"Name", (PVOID*)&DeviceName, &ResultLength, &KeyType);
838 {
839 MixerContext->Copy(OutDeviceName, DeviceName, min(ResultLength, (MAXPNAMELEN-1)*2));
841 }
842
843 MixerContext->CloseKey(hGuidKey);
844 }
845 MixerContext->CloseKey(hMediaKey);
846 }
847 }
848 return Status;
849}
850
855 IN HANDLE hKey)
856{
857 LPWSTR Name;
858 HANDLE hTemp;
860 ULONG Type;
862
863 Status = MixerContext->QueryKeyValue(hKey, L"FriendlyName", (PVOID*)&Name, &Length, &Type);
865 {
866 /* copy device name */
868
869 /* make sure its null terminated */
870 DeviceName[MAXPNAMELEN-1] = L'\0';
871
872 /* free device name */
874
875 /* done */
876 return Status;
877 }
878
879 Status = MixerContext->OpenKey(hKey, L"Device Parameters", KEY_READ, &hTemp);
881 return Status;
882
883 Status = MixerContext->QueryKeyValue(hTemp, L"FriendlyName", (PVOID*)&Name, &Length, &Type);
885 {
886 /* copy device name */
888
889 /* make sure its null terminated */
890 DeviceName[MAXPNAMELEN-1] = L'\0';
891
892 /* free device name */
894 }
895
896 MixerContext->CloseKey(hTemp);
897 return Status;
898}
899
900VOID
902 IN OUT PKSPIN_CONNECT PinConnect,
903 IN ULONG PinId)
904{
905 PinConnect->Interface.Set = KSINTERFACESETID_Standard;
906 PinConnect->Interface.Id = KSINTERFACE_STANDARD_STREAMING;
907 PinConnect->Interface.Flags = 0;
908 PinConnect->Medium.Set = KSMEDIUMSETID_Standard;
909 PinConnect->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
910 PinConnect->Medium.Flags = 0;
911 PinConnect->PinToHandle = NULL;
912 PinConnect->PinId = PinId;
913 PinConnect->Priority.PriorityClass = KSPRIORITY_NORMAL;
914 PinConnect->Priority.PrioritySubClass = 1;
915}
NodeType
Definition: Node.h:6
Type
Definition: Type.h:7
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1281
struct NameRec_ * Name
Definition: cdprocs.h:460
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcsicmp
Definition: compat.h:15
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
#define NodeType(P)
Definition: nodetype.h:51
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define KSPROPERTY_TYPE_TOPOLOGY
Definition: dmksctrl.h:53
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define InsertTailList(ListHead, Entry)
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define KSPRIORITY_NORMAL
Definition: ks.h:1386
#define KSMEDIUM_TYPE_ANYINSTANCE
Definition: ks.h:301
#define KSMEDIUMSETID_Standard
Definition: ks.h:306
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
@ KSINTERFACE_STANDARD_STREAMING
Definition: ks.h:283
#define KSINTERFACESETID_Standard
Definition: ks.h:280
@ KSPROPERTY_GENERAL_COMPONENTID
Definition: ks.h:447
@ KSPROPERTY_AUDIO_VOLUMELEVEL
Definition: ksmedia.h:1057
@ KSPROPERTY_AUDIO_MUTE
Definition: ksmedia.h:1066
@ KSPROPERTY_AUDIO_MUX_SOURCE
Definition: ksmedia.h:1065
if(dx< 0)
Definition: linetemp.h:194
MIXER_STATUS
Definition: mmixer.h:4
@ MM_STATUS_NOT_IMPLEMENTED
Definition: mmixer.h:7
@ MM_STATUS_UNSUCCESSFUL
Definition: mmixer.h:11
@ MM_STATUS_INVALID_PARAMETER
Definition: mmixer.h:10
@ MM_STATUS_NO_MEMORY
Definition: mmixer.h:12
@ MM_STATUS_SUCCESS
Definition: mmixer.h:5
#define MIXERCONTROL_CONTROLF_UNIFORM
Definition: mmsystem.h:350
#define MIXER_SETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:415
struct tMIXERCONTROLDETAILS_BOOLEAN * LPMIXERCONTROLDETAILS_BOOLEAN
#define MIXER_GETCONTROLDETAILSF_VALUE
Definition: mmsystem.h:412
#define MIXER_GETCONTROLDETAILSF_QUERYMASK
Definition: mmsystem.h:414
#define MM_MIXM_CONTROL_CHANGE
Definition: mmsystem.h:83
#define MIXER_SETCONTROLDETAILSF_CUSTOM
Definition: mmsystem.h:416
#define MIXER_SETCONTROLDETAILSF_QUERYMASK
Definition: mmsystem.h:417
#define MIXER_GETCONTROLDETAILSF_LISTTEXT
Definition: mmsystem.h:413
#define MM_MIXM_LINE_CHANGE
Definition: mmsystem.h:82
struct tagMIXERCONTROLDETAILS_LISTTEXTW * LPMIXERCONTROLDETAILS_LISTTEXTW
#define MAXPNAMELEN
Definition: mmsystem.h:24
struct tMIXERCONTROLDETAILS_UNSIGNED * LPMIXERCONTROLDETAILS_UNSIGNED
#define ASSERT(a)
Definition: mode.c:44
static PWSTR GuidString
Definition: apphelp.c:93
HMIXER hMixer
Definition: test.c:10
#define min(a, b)
Definition: monoChain.cc:55
int Count
Definition: noreturn.cpp:7
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
static const WCHAR szName[]
Definition: powrprof.c:45
GUID * LPGUID
Definition: guiddef.h:81
@ Input
Definition: arc.h:84
MIXER_STATUS MMixerSetGetControlDetails(IN PMIXER_CONTEXT MixerContext, IN HANDLE hMixer, IN ULONG NodeId, IN ULONG bSet, IN ULONG PropertyId, IN ULONG Channel, IN PLONG InputValue)
Definition: filter.c:214
struct MIXERLINE_EXT * LPMIXERLINE_EXT
struct EVENT_NOTIFICATION_ENTRY * PEVENT_NOTIFICATION_ENTRY
struct MIXERVOLUME_DATA * LPMIXERVOLUME_DATA
struct MIXER_DATA * LPMIXER_DATA
struct MIXERCONTROL_EXT * LPMIXERCONTROL_EXT
struct MIXER_LIST * PMIXER_LIST
VOID MMixerGetConnectedFromLogicalTopologyPins(IN PTOPOLOGY Topology, IN ULONG NodeIndex, OUT PULONG OutPinCount, OUT PULONG OutPins)
Definition: topology.c:1158
MIXER_STATUS MMixerAllocateTopologyNodeArray(IN PMIXER_CONTEXT MixerContext, IN PTOPOLOGY Topology, OUT PULONG *OutPins)
Definition: topology.c:1045
VOID MMixerGetNextNodesFromNodeIndex(IN PMIXER_CONTEXT MixerContext, IN PTOPOLOGY Topology, IN ULONG NodeIndex, IN ULONG bUpStream, OUT PULONG OutNodesCount, OUT PULONG OutNodes)
Definition: topology.c:965
struct MIXER_INFO * LPMIXER_INFO
const GUID KSNODETYPE_DAC
Definition: sup.c:15
const GUID KSPROPSETID_Audio
Definition: sup.c:29
const GUID KSPROPSETID_Pin
Definition: sup.c:30
const GUID KSNODETYPE_PEAKMETER
Definition: sup.c:22
MIXER_STATUS MMixerSetGetMuteControlDetails(IN PMIXER_CONTEXT MixerContext, IN LPMIXER_INFO MixerInfo, IN LPMIXERCONTROL_EXT MixerControl, IN ULONG dwLineID, IN LPMIXERCONTROLDETAILS MixerControlDetails, IN ULONG bSet)
Definition: sup.c:364
VOID MMixerFreeMixerInfo(IN PMIXER_CONTEXT MixerContext, IN LPMIXER_INFO MixerInfo)
Definition: sup.c:115
LPMIXER_INFO MMixerGetMixerInfoByIndex(IN PMIXER_CONTEXT MixerContext, IN ULONG MixerIndex)
Definition: sup.c:158
const GUID KSDATAFORMAT_TYPE_MUSIC
Definition: sup.c:35
LPMIXER_DATA MMixerGetDataByDeviceName(IN PMIXER_LIST MixerList, IN LPWSTR DeviceName)
Definition: sup.c:756
const GUID KSEVENTSETID_AudioControlChange
Definition: sup.c:33
VOID MMixerInitializePinConnect(IN OUT PKSPIN_CONNECT PinConnect, IN ULONG PinId)
Definition: sup.c:901
const GUID KSNODETYPE_VOLUME
Definition: sup.c:21
MIXER_STATUS MMixerGetDeviceNameWithComponentId(IN PMIXER_CONTEXT MixerContext, IN HANDLE hMixer, OUT LPWSTR OutDeviceName)
Definition: sup.c:804
ULONG MMixerGetVolumeControlIndex(LPMIXERVOLUME_DATA VolumeData, LONG Value)
Definition: sup.c:319
const GUID KSNODETYPE_CHORUS
Definition: sup.c:25
const GUID KSNODETYPE_AGC
Definition: sup.c:17
const GUID KSNODETYPE_SUPERMIX
Definition: sup.c:27
LPGUID MMixerGetNodeType(IN PKSMULTIPLE_ITEM MultipleItem, IN ULONG Index)
Definition: sup.c:242
MIXER_STATUS MMixerSetGetMuxControlDetails(IN PMIXER_CONTEXT MixerContext, IN LPMIXER_INFO MixerInfo, IN ULONG NodeId, IN ULONG bSet, IN ULONG Flags, IN LPMIXERCONTROL_EXT MixerControl, IN LPMIXERCONTROLDETAILS MixerControlDetails, IN LPMIXERLINE_EXT MixerLine)
Definition: sup.c:408
const GUID KSNODETYPE_SUM
Definition: sup.c:14
MIXER_STATUS MMixerGetMixerByName(IN PMIXER_LIST MixerList, IN LPWSTR MixerName, OUT LPMIXER_INFO *OutMixerInfo)
Definition: sup.c:191
MIXER_STATUS MMixerGetDeviceName(IN PMIXER_CONTEXT MixerContext, OUT LPWSTR DeviceName, IN HANDLE hKey)
Definition: sup.c:852
const GUID KSDATAFORMAT_SPECIFIER_NONE
Definition: sup.c:37
const GUID KSNODETYPE_ADC
Definition: sup.c:16
MIXER_STATUS MMixerGetMixerControlById(LPMIXER_INFO MixerInfo, DWORD dwControlID, LPMIXERLINE_EXT *OutMixerLine, LPMIXERCONTROL_EXT *OutMixerControl, PULONG NodeId)
Definition: sup.c:278
const GUID KSNODETYPE_MUX
Definition: sup.c:23
const GUID KSNODETYPE_MUTE
Definition: sup.c:19
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:40
LPMIXERLINE_EXT MMixerGetSourceMixerLineByComponentType(LPMIXER_INFO MixerInfo, DWORD dwComponentType)
Definition: sup.c:255
VOID MMixerGetLowestLogicalTopologyPinOffsetFromArray(IN ULONG LogicalPinArrayCount, IN PULONG LogicalPinArray, OUT PULONG PinOffset)
Definition: sup.c:90
MIXER_STATUS MMixerSetGetVolumeControlDetails(IN PMIXER_CONTEXT MixerContext, IN LPMIXER_INFO MixerInfo, IN ULONG NodeId, IN ULONG bSet, LPMIXERCONTROL_EXT MixerControl, IN LPMIXERCONTROLDETAILS MixerControlDetails, LPMIXERLINE_EXT MixerLine)
Definition: sup.c:665
MIXER_STATUS MMixerCreateMixerData(IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN LPWSTR DeviceName, IN HANDLE hDevice, IN HANDLE hKey)
Definition: sup.c:778
LPMIXERLINE_EXT MMixerGetMixerLineContainingNodeId(IN LPMIXER_INFO MixerInfo, IN ULONG NodeID)
Definition: sup.c:58
const GUID KSNODETYPE_STEREO_WIDE
Definition: sup.c:24
VOID MMixerNotifyControlChange(IN PMIXER_CONTEXT MixerContext, IN LPMIXER_INFO MixerInfo, IN ULONG NotificationType, IN ULONG Value)
Definition: sup.c:336
const GUID KSNODETYPE_REVERB
Definition: sup.c:26
const GUID KSNODETYPE_TONE
Definition: sup.c:20
LPMIXERLINE_EXT MMixerGetSourceMixerLineByLineId(LPMIXER_INFO MixerInfo, DWORD dwLineID)
Definition: sup.c:218
const GUID KSPROPSETID_General
Definition: sup.c:31
LPMIXER_DATA MMixerGetMixerDataByDeviceHandle(IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice)
Definition: sup.c:128
const GUID KSDATAFORMAT_SUBTYPE_MIDI
Definition: sup.c:36
const GUID KSPROPSETID_Topology
Definition: sup.c:32
LPMIXER_DATA MMixerGetDataByDeviceId(IN PMIXER_LIST MixerList, IN ULONG DeviceId)
Definition: sup.c:735
const GUID KSNODETYPE_LOUDNESS
Definition: sup.c:18
#define DPRINT
Definition: sndvol32.h:73
Definition: precomp.h:169
base of all file and directory entries
Definition: entries.h:83
HANDLE hDevice
Definition: precomp.h:81
MIXERCONTROLW Control
Definition: precomp.h:79
PVOID ExtraData
Definition: precomp.h:82
ULONG NodeID
Definition: precomp.h:80
MIXERLINEW Line
Definition: precomp.h:89
LIST_ENTRY ControlsList
Definition: precomp.h:90
ULONG ValuesCount
Definition: precomp.h:107
ULONG InputSteppingDelta
Definition: precomp.h:106
PMIXER_ALLOC_EVENT_DATA AllocEventData
Definition: mmixer.h:103
PMIXER_OPEN_KEY OpenKey
Definition: mmixer.h:100
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
PMIXER_CLOSE Close
Definition: mmixer.h:98
ULONG SizeOfStruct
Definition: mmixer.h:91
PMIXER_CLOSEKEY CloseKey
Definition: mmixer.h:102
PMIXER_COPY Copy
Definition: mmixer.h:99
PMIXER_QUERY_KEY_VALUE QueryKeyValue
Definition: mmixer.h:101
PMIXER_FREE_EVENT_DATA FreeEventData
Definition: mmixer.h:104
PVOID MixerContext
Definition: mmixer.h:92
PMIXER_OPEN Open
Definition: mmixer.h:97
PMIXER_FREE Free
Definition: mmixer.h:96
PMIXER_ALLOC Alloc
Definition: mmixer.h:94
LIST_ENTRY Entry
Definition: precomp.h:113
LPMIXER_INFO MixerInfo
Definition: precomp.h:119
HANDLE hDevice
Definition: precomp.h:115
HANDLE hDeviceInterfaceKey
Definition: precomp.h:116
LPWSTR DeviceName
Definition: precomp.h:117
ULONG DeviceId
Definition: precomp.h:114
PTOPOLOGY Topology
Definition: precomp.h:118
LIST_ENTRY LineList
Definition: precomp.h:71
MIXERCAPSW MixCaps
Definition: precomp.h:70
ULONG MixerDataCount
Definition: precomp.h:152
LIST_ENTRY MixerData
Definition: precomp.h:153
ULONG MixerListCount
Definition: precomp.h:149
LIST_ENTRY MixerList
Definition: precomp.h:150
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1226
DWORD dwLineID
Definition: mmsystem.h:1258
WCHAR szName[MIXER_LONG_NAME_CHARS]
Definition: mmsystem.h:1266
DWORD dwComponentType
Definition: mmsystem.h:1261
#define MAXULONG
Definition: typedefs.h:251
uint32_t * PULONG
Definition: typedefs.h:59
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184