ReactOS 0.4.15-dev-8227-g32d615f
wave.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for wave.c:

Go to the source code of this file.

Classes

struct  AUDIO_RANGE
 

Macros

#define AUDIO_TEST_RANGE   (5)
 

Functions

PKSPIN_CONNECT MMixerAllocatePinConnect (IN PMIXER_CONTEXT MixerContext, ULONG DataFormatSize)
 
MIXER_STATUS MMixerGetWaveInfoByIndexAndType (IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
 
VOID MMixerInitializeDataFormat (_Inout_ PKSDATAFORMAT_WAVEFORMATEX DataFormat, _In_ LPWAVEFORMATEX WaveFormatEx, _In_ DWORD cbSize)
 
MIXER_STATUS MMixerGetAudioPinDataRanges (IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
 
MIXER_STATUS MMixerFindAudioDataRange (PKSMULTIPLE_ITEM MultipleItem, PKSDATARANGE_AUDIO *OutDataRangeAudio)
 
MIXER_STATUS MMixerOpenWavePin (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN LPWAVEFORMATEX WaveFormatEx, IN ACCESS_MASK DesiredAccess, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
 
VOID MMixerCheckFormat (IN PKSDATARANGE_AUDIO DataRangeAudio, IN LPWAVE_INFO WaveInfo, IN ULONG bInput)
 
MIXER_STATUS MMixerInitializeWaveInfo (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN LPMIXER_DATA MixerData, IN LPWSTR DeviceName, IN ULONG bWaveIn, IN ULONG PinCount, IN PULONG Pins)
 
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)
 
MIXER_STATUS MMixerWaveInCapabilities (IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEINCAPSW Caps)
 
MIXER_STATUS MMixerWaveOutCapabilities (IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPWAVEOUTCAPSW Caps)
 
ULONG MMixerGetWaveInCount (IN PMIXER_CONTEXT MixerContext)
 
ULONG MMixerGetWaveOutCount (IN PMIXER_CONTEXT MixerContext)
 
MIXER_STATUS MMixerGetWavePosition (_In_ PMIXER_CONTEXT MixerContext, _In_ HANDLE PinHandle, _Out_ PDWORD Position)
 
MIXER_STATUS MMixerSetWaveStatus (IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
 
MIXER_STATUS MMixerSetWaveResetState (IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN ULONG bBegin)
 
MIXER_STATUS MMixerGetWaveDevicePath (IN PMIXER_CONTEXT MixerContext, IN ULONG bWaveIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
 

Variables

const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {0x05589f81L, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}
 
const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
 
const GUID KSDATAFORMAT_TYPE_AUDIO = {0x73647561L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
 
const GUID KSINTERFACESETID_Standard = {0x1A8766A0L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static AUDIO_RANGE TestRange [AUDIO_TEST_RANGE]
 

Macro Definition Documentation

◆ AUDIO_TEST_RANGE

#define AUDIO_TEST_RANGE   (5)

Definition at line 30 of file wave.c.

Function Documentation

◆ MMixerAllocatePinConnect()

PKSPIN_CONNECT MMixerAllocatePinConnect ( IN PMIXER_CONTEXT  MixerContext,
ULONG  DataFormatSize 
)

Definition at line 72 of file wave.c.

75{
76 return MixerContext->Alloc(sizeof(KSPIN_CONNECT) + DataFormatSize);
77}
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
PMIXER_ALLOC Alloc
Definition: mmixer.h:94

Referenced by MMixerOpenMidiPin(), and MMixerOpenWavePin().

◆ MMixerCheckFormat()

VOID MMixerCheckFormat ( IN PKSDATARANGE_AUDIO  DataRangeAudio,
IN LPWAVE_INFO  WaveInfo,
IN ULONG  bInput 
)

Definition at line 298 of file wave.c.

302{
303 ULONG Index, SampleFrequency;
304 ULONG Result = 0;
305
306 for(Index = 0; Index < AUDIO_TEST_RANGE; Index++)
307 {
308 SampleFrequency = TestRange[Index].SampleRate;
309
310 if (DataRangeAudio->MinimumSampleFrequency <= SampleFrequency && DataRangeAudio->MaximumSampleFrequency >= SampleFrequency)
311 {
312 /* the audio adapter supports the sample frequency */
313 if (DataRangeAudio->MinimumBitsPerSample <= 8 && DataRangeAudio->MaximumBitsPerSample >= 8)
314 {
316
317 if (DataRangeAudio->MaximumChannels > 1)
318 {
319 /* check if pin supports the sample rate in 8-Bit Stereo */
321 }
322 }
323
324 if (DataRangeAudio->MinimumBitsPerSample <= 16 && DataRangeAudio->MaximumBitsPerSample >= 16)
325 {
326 /* check if pin supports the sample rate in 16-Bit Mono */
328
329 if (DataRangeAudio->MaximumChannels > 1)
330 {
331 /* check if pin supports the sample rate in 16-Bit Stereo */
333 }
334 }
335 }
336 }
337
338 if (bInput)
339 WaveInfo->u.InCaps.dwFormats = Result;
340 else
341 WaveInfo->u.OutCaps.dwFormats = Result;
342
343 DPRINT("Format %lx bInput %u\n", Result, bInput);
344}
static AUDIO_RANGE TestRange[AUDIO_TEST_RANGE]
Definition: wave.c:32
#define AUDIO_TEST_RANGE
Definition: wave.c:30
#define DPRINT
Definition: sndvol32.h:73
ULONG SampleRate
Definition: wave.c:23
ULONG Bit16Mono
Definition: wave.c:26
ULONG Bit8Stereo
Definition: wave.c:25
ULONG Bit16Stereo
Definition: wave.c:27
ULONG Bit8Mono
Definition: wave.c:24
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_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

Referenced by MMixerInitializeWaveInfo().

◆ MMixerFindAudioDataRange()

MIXER_STATUS MMixerFindAudioDataRange ( PKSMULTIPLE_ITEM  MultipleItem,
PKSDATARANGE_AUDIO OutDataRangeAudio 
)

Definition at line 202 of file wave.c.

205{
206 ULONG Index;
207 PKSDATARANGE_AUDIO DataRangeAudio;
208 PKSDATARANGE DataRange;
209
210 DataRange = (PKSDATARANGE) (MultipleItem + 1);
211 for(Index = 0; Index < MultipleItem->Count; Index++)
212 {
213 if (DataRange->FormatSize == sizeof(KSDATARANGE_AUDIO))
214 {
215 DataRangeAudio = (PKSDATARANGE_AUDIO)DataRange;
219 {
220 DPRINT("Min Sample %u Max Sample %u Min Bits %u Max Bits %u Max Channel %u\n", DataRangeAudio->MinimumSampleFrequency, DataRangeAudio->MaximumSampleFrequency,
221 DataRangeAudio->MinimumBitsPerSample, DataRangeAudio->MaximumBitsPerSample, DataRangeAudio->MaximumChannels);
222 *OutDataRangeAudio = DataRangeAudio;
223 return MM_STATUS_SUCCESS;
224 }
225 }
226 DataRange = (PKSDATARANGE)((ULONG_PTR)DataRange + DataRange->FormatSize);
227 }
229}
union KSDATAFORMAT * PKSDATARANGE
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
struct KSDATARANGE_AUDIO * PKSDATARANGE_AUDIO
@ MM_STATUS_UNSUCCESSFUL
Definition: mmixer.h:11
@ MM_STATUS_SUCCESS
Definition: mmixer.h:5
const GUID KSDATAFORMAT_TYPE_AUDIO
Definition: wave.c:17
const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: wave.c:15
ULONG MaximumChannels
Definition: ksmedia.h:680
ULONG MinimumBitsPerSample
Definition: ksmedia.h:681
ULONG MaximumBitsPerSample
Definition: ksmedia.h:682
ULONG MaximumSampleFrequency
Definition: ksmedia.h:684
KSDATARANGE DataRange
Definition: ksmedia.h:679
ULONG MinimumSampleFrequency
Definition: ksmedia.h:683
ULONG Count
Definition: ks.h:1980
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by MMixerInitializeWaveInfo().

◆ MMixerGetAudioPinDataRanges()

MIXER_STATUS MMixerGetAudioPinDataRanges ( IN PMIXER_CONTEXT  MixerContext,
IN HANDLE  hDevice,
IN ULONG  PinId,
IN OUT PKSMULTIPLE_ITEM OutMultipleItem 
)

Definition at line 157 of file wave.c.

162{
163 KSP_PIN PinProperty;
166 PKSMULTIPLE_ITEM MultipleItem;
167
168 /* retrieve size of data ranges buffer */
169 PinProperty.Reserved = 0;
170 PinProperty.PinId = PinId;
171 PinProperty.Property.Set = KSPROPSETID_Pin;
173 PinProperty.Property.Flags = KSPROPERTY_TYPE_GET;
174
175 Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)NULL, 0, &BytesReturned);
177 {
178 return Status;
179 }
180
181 MultipleItem = MixerContext->Alloc(BytesReturned);
182 if (!MultipleItem)
183 {
184 /* not enough memory */
185 return MM_STATUS_NO_MEMORY;
186 }
187
188 Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned);
190 {
191 /* failed */
192 MixerContext->Free(MultipleItem);
193 return Status;
194 }
195
196 /* save result */
197 *OutMultipleItem = MultipleItem;
198 return Status;
199}
#define NULL
Definition: types.h:112
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
Status
Definition: gdiplustypes.h:25
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPSETID_Pin
Definition: ks.h:617
@ KSPROPERTY_PIN_DATARANGES
Definition: ks.h:628
MIXER_STATUS
Definition: mmixer.h:4
@ MM_STATUS_NO_MEMORY
Definition: mmixer.h:12
@ MM_STATUS_MORE_ENTRIES
Definition: mmixer.h:9
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
GUID Set
Definition: dmksctrl.h:76
Definition: ks.h:642
ULONG Reserved
Definition: ks.h:645
KSPROPERTY Property
Definition: ks.h:643
ULONG PinId
Definition: ks.h:644
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
PMIXER_FREE Free
Definition: mmixer.h:96
_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

Referenced by MMixerInitializeMidiForFilter(), and MMixerInitializeWaveInfo().

◆ MMixerGetWaveDevicePath()

MIXER_STATUS MMixerGetWaveDevicePath ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  bWaveIn,
IN ULONG  DeviceId,
OUT LPWSTR DevicePath 
)

Definition at line 704 of file wave.c.

709{
710 PMIXER_LIST MixerList;
711 LPMIXER_DATA MixerData;
712 LPWAVE_INFO WaveInfo;
715
716 /* verify mixer context */
718
720 {
721 /* invalid context passed */
722 return Status;
723 }
724
725 /* grab mixer list */
727
728 /* find destination wave */
729 Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceId, bWaveIn, &WaveInfo);
731 {
732 /* failed to find wave info */
734 }
735
736 /* get associated device id */
737 MixerData = MMixerGetDataByDeviceId(MixerList, WaveInfo->DeviceId);
738 if (!MixerData)
740
741 /* calculate length */
742 Length = wcslen(MixerData->DeviceName)+1;
743
744 /* allocate destination buffer */
745 *DevicePath = MixerContext->Alloc(Length * sizeof(WCHAR));
746
747 if (!*DevicePath)
748 {
749 /* no memory */
750 return MM_STATUS_NO_MEMORY;
751 }
752
753 /* copy device path */
754 MixerContext->Copy(*DevicePath, MixerData->DeviceName, Length * sizeof(WCHAR));
755
756 /* done */
757 return MM_STATUS_SUCCESS;
758}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
@ MM_STATUS_INVALID_PARAMETER
Definition: mmixer.h:10
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct MIXER_LIST * PMIXER_LIST
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:40
LPMIXER_DATA MMixerGetDataByDeviceId(IN PMIXER_LIST MixerList, IN ULONG DeviceId)
Definition: sup.c:735
MIXER_STATUS MMixerGetWaveInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
Definition: wave.c:80
PMIXER_COPY Copy
Definition: mmixer.h:99
PVOID MixerContext
Definition: mmixer.h:92
LPWSTR DeviceName
Definition: precomp.h:117
ULONG DeviceId
Definition: precomp.h:125
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by WdmAudGetPnpNameByIndexAndType().

◆ MMixerGetWaveInCount()

ULONG MMixerGetWaveInCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 574 of file wave.c.

576{
577 PMIXER_LIST MixerList;
579
580 /* verify mixer context */
582
584 {
585 /* invalid context passed */
586 return Status;
587 }
588
589 /* grab mixer list */
591
592 return MixerList->WaveInListCount;
593}
ULONG WaveInListCount
Definition: precomp.h:155

Referenced by WdmAudGetNumWdmDevsByMMixer(), and WdmAudGetWaveInDeviceCount().

◆ MMixerGetWaveInfoByIndexAndType()

MIXER_STATUS MMixerGetWaveInfoByIndexAndType ( IN PMIXER_LIST  MixerList,
IN ULONG  DeviceIndex,
IN ULONG  bWaveInType,
OUT LPWAVE_INFO OutWaveInfo 
)

Definition at line 80 of file wave.c.

85{
86 ULONG Index = 0;
87 PLIST_ENTRY Entry, ListHead;
88 LPWAVE_INFO WaveInfo;
89
90 if (bWaveInType)
91 ListHead = &MixerList->WaveInList;
92 else
93 ListHead = &MixerList->WaveOutList;
94
95 /* get first entry */
96 Entry = ListHead->Flink;
97
98 while(Entry != ListHead)
99 {
101
102 if (Index == DeviceIndex)
103 {
104 *OutWaveInfo = WaveInfo;
105 return MM_STATUS_SUCCESS;
106 }
107 Index++;
108 Entry = Entry->Flink;
109 }
110
112}
struct WAVE_INFO * LPWAVE_INFO
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by MMixerGetWaveDevicePath(), MMixerOpenWave(), MMixerWaveInCapabilities(), and MMixerWaveOutCapabilities().

◆ MMixerGetWaveOutCount()

ULONG MMixerGetWaveOutCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 596 of file wave.c.

598{
599 PMIXER_LIST MixerList;
601
602 /* verify mixer context */
604
606 {
607 /* invalid context passed */
608 return Status;
609 }
610
611 /* grab mixer list */
613
614 return MixerList->WaveOutListCount;
615}
ULONG WaveOutListCount
Definition: precomp.h:158

Referenced by WdmAudGetMidiOutDeviceCount(), WdmAudGetNumWdmDevsByMMixer(), and WdmAudGetWaveOutDeviceCount().

◆ MMixerGetWavePosition()

MIXER_STATUS MMixerGetWavePosition ( _In_ PMIXER_CONTEXT  MixerContext,
_In_ HANDLE  PinHandle,
_Out_ PDWORD  Position 
)

Definition at line 618 of file wave.c.

622{
623 KSAUDIO_POSITION AudioPosition;
627
628 /* Validate mixer context */
630
632 return Status;
633
637
639 &Property, sizeof(Property),
640 &AudioPosition, sizeof(AudioPosition),
641 &Length);
643 {
644 /* store audio position */
645 *Position = (DWORD)AudioPosition.PlayOffset;
646 }
647
648 return Status;
649}
@ KSPROPERTY_AUDIO_POSITION
Definition: ksmedia.h:1058
#define KSPROPSETID_Audio
Definition: ksmedia.h:1051
#define DWORD
Definition: nt_native.h:44
DWORDLONG PlayOffset
Definition: ksmedia.h:1250
static COORD Position
Definition: mouse.c:34

Referenced by WdmAudGetPosition(), and WdmAudGetWavePositionByMMixer().

◆ MMixerInitializeDataFormat()

VOID MMixerInitializeDataFormat ( _Inout_ PKSDATAFORMAT_WAVEFORMATEX  DataFormat,
_In_ LPWAVEFORMATEX  WaveFormatEx,
_In_ DWORD  cbSize 
)

Definition at line 115 of file wave.c.

119{
120 DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
121 DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels;
122 DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
123 DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
124 DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
125 DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
126 DataFormat->WaveFormatEx.cbSize = cbSize;
127 DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX) + cbSize;
128 DataFormat->DataFormat.Flags = 0;
129 DataFormat->DataFormat.Reserved = 0;
130 DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
131 DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
132 DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
133 DataFormat->DataFormat.SampleSize = 4;
134
135 /* Write additional fields for Extensible audio format */
136 if (WaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
137 {
138 PWAVEFORMATEXTENSIBLE WaveFormatExt = (PWAVEFORMATEXTENSIBLE)&DataFormat->WaveFormatEx;
139 WaveFormatExt->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
140 WaveFormatExt->Samples.wValidBitsPerSample = WaveFormatEx->wBitsPerSample;
141 if (WaveFormatEx->nChannels == 0)
143 else if (WaveFormatEx->nChannels == 1)
144 WaveFormatExt->dwChannelMask = KSAUDIO_SPEAKER_MONO;
145 else if (WaveFormatEx->nChannels == 2)
146 WaveFormatExt->dwChannelMask = KSAUDIO_SPEAKER_STEREO;
147 else if (WaveFormatEx->nChannels == 4)
148 WaveFormatExt->dwChannelMask = KSAUDIO_SPEAKER_QUAD;
149 else if (WaveFormatEx->nChannels == 5)
150 WaveFormatExt->dwChannelMask = KSAUDIO_SPEAKER_5POINT1;
151 else if (WaveFormatEx->nChannels == 7)
152 WaveFormatExt->dwChannelMask = KSAUDIO_SPEAKER_7POINT1;
153 }
154}
#define KSAUDIO_SPEAKER_MONO
Definition: ksmedia.h:1453
#define KSAUDIO_SPEAKER_5POINT1
Definition: ksmedia.h:1459
#define KSAUDIO_SPEAKER_QUAD
Definition: ksmedia.h:1455
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:651
struct WAVEFORMATEXTENSIBLE * PWAVEFORMATEXTENSIBLE
#define KSAUDIO_SPEAKER_STEREO
Definition: ksmedia.h:1454
#define KSAUDIO_SPEAKER_DIRECTOUT
Definition: ksmedia.h:1450
#define KSAUDIO_SPEAKER_7POINT1
Definition: ksmedia.h:1462
if(dx< 0)
Definition: linetemp.h:194
WORD wValidBitsPerSample
Definition: ksmedia.h:641
union WAVEFORMATEXTENSIBLE::@3040 Samples

Referenced by MMixerOpenWavePin().

◆ MMixerInitializeWaveInfo()

MIXER_STATUS MMixerInitializeWaveInfo ( IN PMIXER_CONTEXT  MixerContext,
IN PMIXER_LIST  MixerList,
IN LPMIXER_DATA  MixerData,
IN LPWSTR  DeviceName,
IN ULONG  bWaveIn,
IN ULONG  PinCount,
IN PULONG  Pins 
)

Definition at line 347 of file wave.c.

355{
357 PKSMULTIPLE_ITEM MultipleItem;
358 PKSDATARANGE_AUDIO DataRangeAudio;
359 LPWAVE_INFO WaveInfo;
360
361 WaveInfo = (LPWAVE_INFO)MixerContext->Alloc(sizeof(WAVE_INFO));
362 if (!WaveInfo)
363 return MM_STATUS_NO_MEMORY;
364
365 if (PinCount > 1)
366 {
367 /* FIXME support multiple pins for wave device */
368 DPRINT1("Implement support for multiple pins\n");
369 //ASSERT(PinCount == 1);
370 }
371
372 /* initialize wave info */
373 WaveInfo->DeviceId = MixerData->DeviceId;
374 WaveInfo->PinId = Pins[0];
375
376 /* sanity check */
378
379 /* copy device name */
380 if (bWaveIn)
381 {
382 wcscpy(WaveInfo->u.InCaps.szPname, DeviceName);
383 }
384 else
385 {
386 wcscpy(WaveInfo->u.OutCaps.szPname, DeviceName);
387 }
388
389 /* FIXME determine manufacturer / product id */
390 if (bWaveIn)
391 {
392 WaveInfo->u.InCaps.wMid = MM_MICROSOFT;
393 WaveInfo->u.InCaps.wPid = MM_PID_UNMAPPED;
394 WaveInfo->u.InCaps.vDriverVersion = 1;
395 }
396 else
397 {
398 WaveInfo->u.OutCaps.wMid = MM_MICROSOFT;
399 WaveInfo->u.OutCaps.wPid = MM_PID_UNMAPPED;
400 WaveInfo->u.OutCaps.vDriverVersion = 1;
401 }
402
403 /* get audio pin data ranges */
404 Status = MMixerGetAudioPinDataRanges(MixerContext, MixerData->hDevice, Pins[0], &MultipleItem);
406 {
407 /* failed to get audio pin data ranges */
408 MixerContext->Free(WaveInfo);
410 }
411
412 /* find an KSDATARANGE_AUDIO range */
413 Status = MMixerFindAudioDataRange(MultipleItem, &DataRangeAudio);
415 {
416 /* failed to find audio pin data range */
417 MixerContext->Free(MultipleItem);
418 MixerContext->Free(WaveInfo);
420 }
421
422 /* store channel count */
423 if (bWaveIn)
424 {
425 WaveInfo->u.InCaps.wChannels = DataRangeAudio->MaximumChannels;
426 }
427 else
428 {
429 WaveInfo->u.OutCaps.wChannels = DataRangeAudio->MaximumChannels;
430 }
431
432 /* get all supported formats */
433 MMixerCheckFormat(DataRangeAudio, WaveInfo, bWaveIn);
434
435 /* free dataranges buffer */
436 MixerContext->Free(MultipleItem);
437
438 if (bWaveIn)
439 {
440 InsertTailList(&MixerList->WaveInList, &WaveInfo->Entry);
441 MixerList->WaveInListCount++;
442 }
443 else
444 {
445 InsertTailList(&MixerList->WaveOutList, &WaveInfo->Entry);
446 MixerList->WaveOutListCount++;
447 }
448
449 return MM_STATUS_SUCCESS;
450}
#define DPRINT1
Definition: precomp.h:8
#define InsertTailList(ListHead, Entry)
#define MM_PID_UNMAPPED
Definition: mmreg.h:141
#define MM_MICROSOFT
Definition: mmreg.h:144
#define MAXPNAMELEN
Definition: mmsystem.h:24
#define ASSERT(a)
Definition: mode.c:44
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
VOID MMixerCheckFormat(IN PKSDATARANGE_AUDIO DataRangeAudio, IN LPWAVE_INFO WaveInfo, IN ULONG bInput)
Definition: wave.c:298
MIXER_STATUS MMixerFindAudioDataRange(PKSMULTIPLE_ITEM MultipleItem, PKSDATARANGE_AUDIO *OutDataRangeAudio)
Definition: wave.c:202
MIXER_STATUS MMixerGetAudioPinDataRanges(IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
Definition: wave.c:157
_In_ const GUID _In_ ULONG PinCount
Definition: strmini.h:505
LIST_ENTRY Entry
Definition: precomp.h:124
ULONG PinId
Definition: precomp.h:126
union WAVE_INFO::@4348 u
WAVEOUTCAPSW OutCaps
Definition: precomp.h:129
WAVEINCAPSW InCaps
Definition: precomp.h:130
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1060
MMVERSION vDriverVersion
Definition: mmsystem.h:1059
MMVERSION vDriverVersion
Definition: mmsystem.h:1038
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275

Referenced by MMixerInitializeFilter().

◆ MMixerOpenWave()

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 at line 453 of file wave.c.

461{
462 PMIXER_LIST MixerList;
464 LPWAVE_INFO WaveInfo;
466
467 /* verify mixer context */
469
471 {
472 /* invalid context passed */
473 return Status;
474 }
475
476 /* grab mixer list */
478
479 /* find destination wave */
480 Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, bWaveIn, &WaveInfo);
482 {
483 /* failed to find wave info */
485 }
486
487 /* get desired access */
488 if (bWaveIn)
489 {
491 }
492 else
493 {
495 }
496
497 /* now try open the pin */
498 return MMixerOpenWavePin(MixerContext, MixerList, WaveInfo->DeviceId, WaveInfo->PinId, WaveFormat, DesiredAccess, CreateCallback, Context, PinHandle);
499}
#define GENERIC_READ
Definition: compat.h:135
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define GENERIC_WRITE
Definition: nt_native.h:90
MIXER_STATUS MMixerOpenWavePin(IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN LPWAVEFORMATEX WaveFormatEx, IN ACCESS_MASK DesiredAccess, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
Definition: wave.c:232
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

Referenced by WdmAudControlOpenWave(), and WdmAudSetWaveDeviceFormatByMMixer().

◆ MMixerOpenWavePin()

MIXER_STATUS MMixerOpenWavePin ( IN PMIXER_CONTEXT  MixerContext,
IN PMIXER_LIST  MixerList,
IN ULONG  DeviceId,
IN ULONG  PinId,
IN LPWAVEFORMATEX  WaveFormatEx,
IN ACCESS_MASK  DesiredAccess,
IN PIN_CREATE_CALLBACK  CreateCallback,
IN PVOID  Context,
OUT PHANDLE  PinHandle 
)

Definition at line 232 of file wave.c.

242{
243 PKSPIN_CONNECT PinConnect;
245 LPMIXER_DATA MixerData;
247 MIXER_STATUS MixerStatus;
248 DWORD cbSize;
249
250 MixerData = MMixerGetDataByDeviceId(MixerList, DeviceId);
251 if (!MixerData)
253
254 /* Enforce 0 for WAVE_FORMAT_PCM, which ignores extra information size */
255 cbSize = WaveFormatEx->wFormatTag == WAVE_FORMAT_PCM ? 0 : WaveFormatEx->cbSize;
256
257 /* allocate pin connect */
259 if (!PinConnect)
260 {
261 /* no memory */
262 return MM_STATUS_NO_MEMORY;
263 }
264
265 /* initialize pin connect struct */
266 MMixerInitializePinConnect(PinConnect, PinId);
267
268 /* get offset to dataformat */
269 DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1);
270 /* initialize with requested wave format */
271 MMixerInitializeDataFormat(DataFormat, WaveFormatEx, cbSize);
272
273 if (CreateCallback)
274 {
275 /* let the callback handle the creation */
276 MixerStatus = CreateCallback(Context, DeviceId, PinId, MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
277 }
278 else
279 {
280 /* now create the pin */
281 Status = KsCreatePin(MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
282
283 /* normalize status */
284 if (Status == STATUS_SUCCESS)
285 MixerStatus = MM_STATUS_SUCCESS;
286 else
287 MixerStatus = MM_STATUS_UNSUCCESSFUL;
288 }
289
290 /* free create info */
291 MixerContext->Free(PinConnect);
292
293 /* done */
294 return MixerStatus;
295}
LONG NTSTATUS
Definition: precomp.h:26
#define WAVE_FORMAT_PCM
Definition: constants.h:425
unsigned long DWORD
Definition: ntddk_ex.h:95
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
VOID MMixerInitializePinConnect(IN OUT PKSPIN_CONNECT PinConnect, IN ULONG PinId)
Definition: sup.c:901
VOID MMixerInitializeDataFormat(_Inout_ PKSDATAFORMAT_WAVEFORMATEX DataFormat, _In_ LPWAVEFORMATEX WaveFormatEx, _In_ DWORD cbSize)
Definition: wave.c:115
PKSPIN_CONNECT MMixerAllocatePinConnect(IN PMIXER_CONTEXT MixerContext, ULONG DataFormatSize)
Definition: wave.c:72
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE hDevice
Definition: precomp.h:115

Referenced by MMixerOpenWave().

◆ MMixerSetWaveResetState()

MIXER_STATUS MMixerSetWaveResetState ( IN PMIXER_CONTEXT  MixerContext,
IN HANDLE  PinHandle,
IN ULONG  bBegin 
)

Definition at line 679 of file wave.c.

683{
686 KSRESET Reset;
687
688 /* verify mixer context */
690
692 {
693 /* invalid context passed */
694 return Status;
695 }
696
697 /* begin / stop reset */
698 Reset = (bBegin ? KSRESET_BEGIN : KSRESET_END);
699
700 return MixerContext->Control(PinHandle, IOCTL_KS_RESET_STATE, &Reset, sizeof(KSRESET), NULL, 0, &Length);
701}
KSRESET
Definition: ks.h:1226
@ KSRESET_BEGIN
Definition: ks.h:1227
@ KSRESET_END
Definition: ks.h:1228
#define IOCTL_KS_RESET_STATE
Definition: ks.h:145

Referenced by WdmAudResetStreamByMMixer().

◆ MMixerSetWaveStatus()

MIXER_STATUS MMixerSetWaveStatus ( IN PMIXER_CONTEXT  MixerContext,
IN HANDLE  PinHandle,
IN KSSTATE  State 
)

Definition at line 652 of file wave.c.

656{
660
661 /* verify mixer context */
663
665 {
666 /* invalid context passed */
667 return Status;
668 }
669
670 /* setup property request */
674
675 return MixerContext->Control(PinHandle, IOCTL_KS_PROPERTY, &Property, sizeof(KSPROPERTY), &State, sizeof(KSSTATE), &Length);
676}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
@ KSPROPERTY_CONNECTION_STATE
Definition: ks.h:349
KSSTATE
Definition: ks.h:1214
const GUID KSPROPSETID_Connection
Definition: wave.c:14

Referenced by WdmAudCloseSoundDeviceByMMixer(), WdmAudSetWaveDeviceFormatByMMixer(), and WdmAudSetWaveStateByMMixer().

◆ MMixerWaveInCapabilities()

MIXER_STATUS MMixerWaveInCapabilities ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  DeviceIndex,
OUT LPWAVEINCAPSW  Caps 
)

Definition at line 502 of file wave.c.

506{
507 PMIXER_LIST MixerList;
509 LPWAVE_INFO WaveInfo;
510
511 /* verify mixer context */
513
515 {
516 /* invalid context passed */
517 return Status;
518 }
519
520 /* grab mixer list */
522
523 /* find destination wave */
524 Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, TRUE, &WaveInfo);
526 {
527 /* failed to find wave info */
529 }
530
531 /* copy capabilities */
532 MixerContext->Copy(Caps, &WaveInfo->u.InCaps, sizeof(WAVEINCAPSW));
533
534 return MM_STATUS_SUCCESS;
535}
#define TRUE
Definition: types.h:120

Referenced by WdmAudGetWaveInCapabilities(), and WdmAudWaveCapabilities().

◆ MMixerWaveOutCapabilities()

MIXER_STATUS MMixerWaveOutCapabilities ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  DeviceIndex,
OUT LPWAVEOUTCAPSW  Caps 
)

Definition at line 538 of file wave.c.

542{
543 PMIXER_LIST MixerList;
545 LPWAVE_INFO WaveInfo;
546
547 /* verify mixer context */
549
551 {
552 /* invalid context passed */
553 return Status;
554 }
555
556 /* grab mixer list */
558
559 /* find destination wave */
560 Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, FALSE, &WaveInfo);
562 {
563 /* failed to find wave info */
565 }
566
567 /* copy capabilities */
568 MixerContext->Copy(Caps, &WaveInfo->u.OutCaps, sizeof(WAVEOUTCAPSW));
569
570 return MM_STATUS_SUCCESS;
571}
#define FALSE
Definition: types.h:117

Referenced by WdmAudGetWaveOutCapabilities(), and WdmAudWaveCapabilities().

Variable Documentation

◆ KSDATAFORMAT_SPECIFIER_WAVEFORMATEX

const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX = {0x05589f81L, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}

Definition at line 15 of file wave.c.

Referenced by MMixerFindAudioDataRange(), and MMixerInitializeDataFormat().

◆ KSDATAFORMAT_SUBTYPE_PCM

const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}

Definition at line 16 of file wave.c.

◆ KSDATAFORMAT_TYPE_AUDIO

const GUID KSDATAFORMAT_TYPE_AUDIO = {0x73647561L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}

Definition at line 17 of file wave.c.

Referenced by MMixerFindAudioDataRange(), and MMixerInitializeDataFormat().

◆ KSINTERFACESETID_Standard

const GUID KSINTERFACESETID_Standard = {0x1A8766A0L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}

Definition at line 18 of file wave.c.

◆ KSMEDIUMSETID_Standard

const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}

Definition at line 19 of file wave.c.

◆ KSPROPSETID_Connection

const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}

Definition at line 14 of file wave.c.

Referenced by MMixerSetWaveStatus().

◆ TestRange

AUDIO_RANGE TestRange[AUDIO_TEST_RANGE]
static

Definition at line 32 of file wave.c.

Referenced by MMixerCheckFormat().