ReactOS  0.4.14-dev-41-g31d7680
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 YDEBUG
 
#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 (IN PKSDATAFORMAT_WAVEFORMATEX DataFormat, LPWAVEFORMATEX WaveFormatEx)
 
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 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.

◆ YDEBUG

#define YDEBUG

Definition at line 11 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:46
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 279 of file wave.c.

283 {
284  ULONG Index, SampleFrequency;
285  ULONG Result = 0;
286 
287  for(Index = 0; Index < AUDIO_TEST_RANGE; Index++)
288  {
289  SampleFrequency = TestRange[Index].SampleRate;
290 
291  if (DataRangeAudio->MinimumSampleFrequency <= SampleFrequency && DataRangeAudio->MaximumSampleFrequency >= SampleFrequency)
292  {
293  /* the audio adapter supports the sample frequency */
294  if (DataRangeAudio->MinimumBitsPerSample <= 8 && DataRangeAudio->MaximumBitsPerSample >= 8)
295  {
297 
298  if (DataRangeAudio->MaximumChannels > 1)
299  {
300  /* check if pin supports the sample rate in 8-Bit Stereo */
302  }
303  }
304 
305  if (DataRangeAudio->MinimumBitsPerSample <= 16 && DataRangeAudio->MaximumBitsPerSample >= 16)
306  {
307  /* check if pin supports the sample rate in 16-Bit Mono */
309 
310 
311  if (DataRangeAudio->MaximumChannels > 1)
312  {
313  /* check if pin supports the sample rate in 16-Bit Stereo */
315  }
316  }
317  }
318  }
319 
320 
321  if (bInput)
322  WaveInfo->u.InCaps.dwFormats = Result;
323  else
324  WaveInfo->u.OutCaps.dwFormats = Result;
325 
326  DPRINT("Format %lx bInput %u\n", Result, bInput);
327 }
ULONG Bit16Stereo
Definition: wave.c:27
ULONG Bit8Stereo
Definition: wave.c:25
ULONG Bit8Mono
Definition: wave.c:24
ULONG SampleRate
Definition: wave.c:23
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void DPRINT(...)
Definition: polytest.cpp:61
static const UCHAR Index[8]
Definition: usbohci.c:18
static AUDIO_RANGE TestRange[AUDIO_TEST_RANGE]
Definition: wave.c:32
#define AUDIO_TEST_RANGE
Definition: wave.c:30
unsigned int ULONG
Definition: retypes.h:1
ULONG Bit16Mono
Definition: wave.c:26

Referenced by MMixerInitializeWaveInfo().

◆ MMixerFindAudioDataRange()

MIXER_STATUS MMixerFindAudioDataRange ( PKSMULTIPLE_ITEM  MultipleItem,
PKSDATARANGE_AUDIO OutDataRangeAudio 
)

Definition at line 187 of file wave.c.

190 {
191  ULONG Index;
192  PKSDATARANGE_AUDIO DataRangeAudio;
193  PKSDATARANGE DataRange;
194 
195  DataRange = (PKSDATARANGE) (MultipleItem + 1);
196  for(Index = 0; Index < MultipleItem->Count; Index++)
197  {
198  if (DataRange->FormatSize == sizeof(KSDATARANGE_AUDIO))
199  {
200  DataRangeAudio = (PKSDATARANGE_AUDIO)DataRange;
204  {
205  DPRINT("Min Sample %u Max Sample %u Min Bits %u Max Bits %u Max Channel %u\n", DataRangeAudio->MinimumSampleFrequency, DataRangeAudio->MaximumSampleFrequency,
206  DataRangeAudio->MinimumBitsPerSample, DataRangeAudio->MaximumBitsPerSample, DataRangeAudio->MaximumChannels);
207  *OutDataRangeAudio = DataRangeAudio;
208  return MM_STATUS_SUCCESS;
209  }
210  }
211  DataRange = (PKSDATARANGE)((ULONG_PTR)DataRange + DataRange->FormatSize);
212  }
213  return MM_STATUS_UNSUCCESSFUL;
214 }
ULONG Count
Definition: ks.h:1980
const GUID KSDATAFORMAT_TYPE_AUDIO
Definition: wave.c:17
ULONG MaximumBitsPerSample
Definition: ksmedia.h:582
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
uint32_t ULONG_PTR
Definition: typedefs.h:63
const GUID KSDATAFORMAT_SUBTYPE_PCM
Definition: wave.c:16
KSDATARANGE DataRange
Definition: ksmedia.h:579
void DPRINT(...)
Definition: polytest.cpp:61
ULONG MinimumSampleFrequency
Definition: ksmedia.h:583
static const UCHAR Index[8]
Definition: usbohci.c:18
ULONG MaximumChannels
Definition: ksmedia.h:580
struct KSDATARANGE_AUDIO * PKSDATARANGE_AUDIO
union KSDATAFORMAT * PKSDATARANGE
ULONG MaximumSampleFrequency
Definition: ksmedia.h:584
ULONG MinimumBitsPerSample
Definition: ksmedia.h:581
unsigned int ULONG
Definition: retypes.h:1
const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: wave.c:15

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 142 of file wave.c.

147 {
148  KSP_PIN PinProperty;
149  ULONG BytesReturned = 0;
151  PKSMULTIPLE_ITEM MultipleItem;
152 
153  /* retrieve size of data ranges buffer */
154  PinProperty.Reserved = 0;
155  PinProperty.PinId = PinId;
156  PinProperty.Property.Set = KSPROPSETID_Pin;
157  PinProperty.Property.Id = KSPROPERTY_PIN_DATARANGES;
158  PinProperty.Property.Flags = KSPROPERTY_TYPE_GET;
159 
160  Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)NULL, 0, &BytesReturned);
162  {
163  return Status;
164  }
165 
166  MultipleItem = MixerContext->Alloc(BytesReturned);
167  if (!MultipleItem)
168  {
169  /* not enough memory */
170  return MM_STATUS_NO_MEMORY;
171  }
172 
173  Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&PinProperty, sizeof(KSP_PIN), (PVOID)MultipleItem, BytesReturned, &BytesReturned);
174  if (Status != MM_STATUS_SUCCESS)
175  {
176  /* failed */
177  MixerContext->Free(MultipleItem);
178  return Status;
179  }
180 
181  /* save result */
182  *OutMultipleItem = MultipleItem;
183  return Status;
184 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
GUID Set
Definition: dmksctrl.h:76
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
KSPROPERTY Property
Definition: ks.h:643
smooth NULL
Definition: ftsmooth.c:416
ULONG PinId
Definition: ks.h:644
Definition: ks.h:642
PMIXER_FREE Free
Definition: mmixer.h:96
ULONG Id
Definition: dmksctrl.h:77
ULONG Flags
Definition: dmksctrl.h:78
ULONG Reserved
Definition: ks.h:645
PMIXER_ALLOC Alloc
Definition: mmixer.h:94
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define KSPROPSETID_Pin
Definition: ks.h:617
unsigned int ULONG
Definition: retypes.h:1

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 659 of file wave.c.

664 {
665  PMIXER_LIST MixerList;
666  LPMIXER_DATA MixerData;
667  LPWAVE_INFO WaveInfo;
668  SIZE_T Length;
670 
671  /* verify mixer context */
673 
674  if (Status != MM_STATUS_SUCCESS)
675  {
676  /* invalid context passed */
677  return Status;
678  }
679 
680  /* grab mixer list */
681  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
682 
683  /* find destination wave */
684  Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceId, bWaveIn, &WaveInfo);
685  if (Status != MM_STATUS_SUCCESS)
686  {
687  /* failed to find wave info */
689  }
690 
691  /* get associated device id */
692  MixerData = MMixerGetDataByDeviceId(MixerList, WaveInfo->DeviceId);
693  if (!MixerData)
695 
696  /* calculate length */
697  Length = wcslen(MixerData->DeviceName)+1;
698 
699  /* allocate destination buffer */
700  *DevicePath = MixerContext->Alloc(Length * sizeof(WCHAR));
701 
702  if (!*DevicePath)
703  {
704  /* no memory */
705  return MM_STATUS_NO_MEMORY;
706  }
707 
708  /* copy device path */
709  MixerContext->Copy(*DevicePath, MixerData->DeviceName, Length * sizeof(WCHAR));
710 
711  /* done */
712  return MM_STATUS_SUCCESS;
713 }
MIXER_STATUS MMixerGetWaveInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
Definition: wave.c:80
LPWSTR DeviceName
Definition: precomp.h:117
LPMIXER_DATA MMixerGetDataByDeviceId(IN PMIXER_LIST MixerList, IN ULONG DeviceId)
Definition: sup.c:736
ULONG DeviceId
Definition: precomp.h:125
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PMIXER_ALLOC Alloc
Definition: mmixer.h:94
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
struct MIXER_LIST * PMIXER_LIST
PMIXER_COPY Copy
Definition: mmixer.h:99
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by WdmAudGetPnpNameByIndexAndType().

◆ MMixerGetWaveInCount()

ULONG MMixerGetWaveInCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 563 of file wave.c.

565 {
566  PMIXER_LIST MixerList;
568 
569  /* verify mixer context */
571 
572  if (Status != MM_STATUS_SUCCESS)
573  {
574  /* invalid context passed */
575  return Status;
576  }
577 
578  /* grab mixer list */
579  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
580 
581  return MixerList->WaveInListCount;
582 }
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
struct MIXER_LIST * PMIXER_LIST
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 _Entry Entry
Definition: kefuncs.h:640
struct WAVE_INFO * LPWAVE_INFO
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static const UCHAR Index[8]
Definition: usbohci.c:18
Definition: typedefs.h:117
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82

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

◆ MMixerGetWaveOutCount()

ULONG MMixerGetWaveOutCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 585 of file wave.c.

587 {
588  PMIXER_LIST MixerList;
590 
591  /* verify mixer context */
593 
594  if (Status != MM_STATUS_SUCCESS)
595  {
596  /* invalid context passed */
597  return Status;
598  }
599 
600  /* grab mixer list */
601  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
602 
603  return MixerList->WaveOutListCount;
604 }
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
struct MIXER_LIST * PMIXER_LIST
ULONG WaveOutListCount
Definition: precomp.h:158

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

◆ MMixerInitializeDataFormat()

VOID MMixerInitializeDataFormat ( IN PKSDATAFORMAT_WAVEFORMATEX  DataFormat,
LPWAVEFORMATEX  WaveFormatEx 
)

Definition at line 118 of file wave.c.

121 {
122 
123  DataFormat->WaveFormatEx.wFormatTag = WaveFormatEx->wFormatTag;
124  DataFormat->WaveFormatEx.nChannels = WaveFormatEx->nChannels;
125  DataFormat->WaveFormatEx.nSamplesPerSec = WaveFormatEx->nSamplesPerSec;
126  DataFormat->WaveFormatEx.nBlockAlign = WaveFormatEx->nBlockAlign;
127  DataFormat->WaveFormatEx.nAvgBytesPerSec = WaveFormatEx->nAvgBytesPerSec;
128  DataFormat->WaveFormatEx.wBitsPerSample = WaveFormatEx->wBitsPerSample;
129  DataFormat->WaveFormatEx.cbSize = 0;
130  DataFormat->DataFormat.FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX);
131  DataFormat->DataFormat.Flags = 0;
132  DataFormat->DataFormat.Reserved = 0;
133  DataFormat->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
134 
135  DataFormat->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
136  DataFormat->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
137  DataFormat->DataFormat.SampleSize = 4;
138 }
const GUID KSDATAFORMAT_TYPE_AUDIO
Definition: wave.c:17
DWORD nAvgBytesPerSec
Definition: mmreg.h:81
WORD nChannels
Definition: mmreg.h:79
const GUID KSDATAFORMAT_SUBTYPE_PCM
Definition: wave.c:16
WORD wFormatTag
Definition: mmreg.h:78
DWORD nSamplesPerSec
Definition: mmreg.h:80
WORD nBlockAlign
Definition: mmreg.h:82
WORD wBitsPerSample
Definition: mmreg.h:83
const GUID KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: wave.c:15

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 330 of file wave.c.

338 {
340  PKSMULTIPLE_ITEM MultipleItem;
341  PKSDATARANGE_AUDIO DataRangeAudio;
342  LPWAVE_INFO WaveInfo;
343 
344  WaveInfo = (LPWAVE_INFO)MixerContext->Alloc(sizeof(WAVE_INFO));
345  if (!WaveInfo)
346  return MM_STATUS_NO_MEMORY;
347 
348  if (PinCount > 1)
349  {
350  /* FIXME support multiple pins for wave device */
351  DPRINT1("Implement support for multiple pins\n");
352  //ASSERT(PinCount == 1);
353  }
354 
355  /* initialize wave info */
356  WaveInfo->DeviceId = MixerData->DeviceId;
357  WaveInfo->PinId = Pins[0];
358 
359  /* sanity check */
361 
362  /* copy device name */
363  if (bWaveIn)
364  {
365  wcscpy(WaveInfo->u.InCaps.szPname, DeviceName);
366  }
367  else
368  {
369  wcscpy(WaveInfo->u.OutCaps.szPname, DeviceName);
370  }
371 
372  /* FIXME determine manufacturer / product id */
373  if (bWaveIn)
374  {
375  WaveInfo->u.InCaps.wMid = MM_MICROSOFT;
376  WaveInfo->u.InCaps.wPid = MM_PID_UNMAPPED;
377  WaveInfo->u.InCaps.vDriverVersion = 1;
378  }
379  else
380  {
381  WaveInfo->u.OutCaps.wMid = MM_MICROSOFT;
382  WaveInfo->u.OutCaps.wPid = MM_PID_UNMAPPED;
383  WaveInfo->u.OutCaps.vDriverVersion = 1;
384  }
385 
386  /* get audio pin data ranges */
387  Status = MMixerGetAudioPinDataRanges(MixerContext, MixerData->hDevice, Pins[0], &MultipleItem);
388  if (Status != MM_STATUS_SUCCESS)
389  {
390  /* failed to get audio pin data ranges */
391  MixerContext->Free(WaveInfo);
392  return MM_STATUS_UNSUCCESSFUL;
393  }
394 
395  /* find an KSDATARANGE_AUDIO range */
396  Status = MMixerFindAudioDataRange(MultipleItem, &DataRangeAudio);
397  if (Status != MM_STATUS_SUCCESS)
398  {
399  /* failed to find audio pin data range */
400  MixerContext->Free(MultipleItem);
401  MixerContext->Free(WaveInfo);
402  return MM_STATUS_UNSUCCESSFUL;
403  }
404 
405  /* store channel count */
406  if (bWaveIn)
407  {
408  WaveInfo->u.InCaps.wChannels = DataRangeAudio->MaximumChannels;
409  }
410  else
411  {
412  WaveInfo->u.OutCaps.wChannels = DataRangeAudio->MaximumChannels;
413  }
414 
415  /* get all supported formats */
416  MMixerCheckFormat(DataRangeAudio, WaveInfo, bWaveIn);
417 
418  /* free dataranges buffer */
419  MixerContext->Free(MultipleItem);
420 
421  if (bWaveIn)
422  {
423  InsertTailList(&MixerList->WaveInList, &WaveInfo->Entry);
424  MixerList->WaveInListCount++;
425  }
426  else
427  {
428  InsertTailList(&MixerList->WaveOutList, &WaveInfo->Entry);
429  MixerList->WaveOutListCount++;
430  }
431 
432  return MM_STATUS_SUCCESS;
433 }
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1060
struct WAVE_INFO * LPWAVE_INFO
MIXER_STATUS MMixerGetAudioPinDataRanges(IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice, IN ULONG PinId, IN OUT PKSMULTIPLE_ITEM *OutMultipleItem)
Definition: wave.c:142
union WAVE_INFO::@3944 u
LIST_ENTRY Entry
Definition: precomp.h:124
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define InsertTailList(ListHead, Entry)
_In_ const GUID _In_ ULONG PinCount
Definition: strmini.h:504
ULONG DeviceId
Definition: precomp.h:125
ULONG PinId
Definition: precomp.h:126
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
MMVERSION vDriverVersion
Definition: mmsystem.h:1059
#define MM_PID_UNMAPPED
Definition: mmreg.h:141
MIXER_STATUS MMixerFindAudioDataRange(PKSMULTIPLE_ITEM MultipleItem, PKSDATARANGE_AUDIO *OutDataRangeAudio)
Definition: wave.c:187
VOID MMixerCheckFormat(IN PKSDATARANGE_AUDIO DataRangeAudio, IN LPWAVE_INFO WaveInfo, IN ULONG bInput)
Definition: wave.c:279
PMIXER_FREE Free
Definition: mmixer.h:96
WAVEINCAPSW InCaps
Definition: precomp.h:130
ULONG MaximumChannels
Definition: ksmedia.h:580
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1039
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define MM_MICROSOFT
Definition: mmreg.h:144
WAVEOUTCAPSW OutCaps
Definition: precomp.h:129
PMIXER_ALLOC Alloc
Definition: mmixer.h:94
Status
Definition: gdiplustypes.h:24
MMVERSION vDriverVersion
Definition: mmsystem.h:1038
MIXER_STATUS
Definition: mmixer.h:3
#define MAXPNAMELEN
Definition: mmsystem.h:24
#define DPRINT1
Definition: precomp.h:8
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 436 of file wave.c.

444 {
445  PMIXER_LIST MixerList;
447  LPWAVE_INFO WaveInfo;
449 
450  /* verify mixer context */
452 
453  if (Status != MM_STATUS_SUCCESS)
454  {
455  /* invalid context passed */
456  return Status;
457  }
458 
459  /* grab mixer list */
460  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
461 
462  if (WaveFormat->wFormatTag != WAVE_FORMAT_PCM)
463  {
464  /* not implemented */
466  }
467 
468  /* find destination wave */
469  Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, bWaveIn, &WaveInfo);
470  if (Status != MM_STATUS_SUCCESS)
471  {
472  /* failed to find wave info */
474  }
475 
476  /* get desired access */
477  if (bWaveIn)
478  {
480  }
481  else
482  {
484  }
485 
486  /* now try open the pin */
487  return MMixerOpenWavePin(MixerContext, MixerList, WaveInfo->DeviceId, WaveInfo->PinId, WaveFormat, DesiredAccess, CreateCallback, Context, PinHandle);
488 }
MIXER_STATUS MMixerGetWaveInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
Definition: wave.c:80
ULONG DeviceId
Definition: precomp.h:125
#define WAVE_FORMAT_PCM
Definition: constants.h:425
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
ULONG PinId
Definition: precomp.h:126
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
#define GENERIC_WRITE
Definition: nt_native.h:90
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
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:217
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
struct MIXER_LIST * PMIXER_LIST
ULONG ACCESS_MASK
Definition: nt_native.h:40

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 217 of file wave.c.

227 {
228  PKSPIN_CONNECT PinConnect;
230  LPMIXER_DATA MixerData;
232  MIXER_STATUS MixerStatus;
233 
234  MixerData = MMixerGetDataByDeviceId(MixerList, DeviceId);
235  if (!MixerData)
237 
238  /* allocate pin connect */
240  if (!PinConnect)
241  {
242  /* no memory */
243  return MM_STATUS_NO_MEMORY;
244  }
245 
246  /* initialize pin connect struct */
247  MMixerInitializePinConnect(PinConnect, PinId);
248 
249  /* get offset to dataformat */
250  DataFormat = (PKSDATAFORMAT_WAVEFORMATEX) (PinConnect + 1);
251  /* initialize with requested wave format */
252  MMixerInitializeDataFormat(DataFormat, WaveFormatEx);
253 
254  if (CreateCallback)
255  {
256  /* let the callback handle the creation */
257  MixerStatus = CreateCallback(Context, DeviceId, PinId, MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
258  }
259  else
260  {
261  /* now create the pin */
262  Status = KsCreatePin(MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
263 
264  /* normalize status */
265  if (Status == STATUS_SUCCESS)
266  MixerStatus = MM_STATUS_SUCCESS;
267  else
268  MixerStatus = MM_STATUS_UNSUCCESSFUL;
269  }
270 
271  /* free create info */
272  MixerContext->Free(PinConnect);
273 
274  /* done */
275  return MixerStatus;
276 }
VOID MMixerInitializeDataFormat(IN PKSDATAFORMAT_WAVEFORMATEX DataFormat, LPWAVEFORMATEX WaveFormatEx)
Definition: wave.c:118
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
PKSPIN_CONNECT MMixerAllocatePinConnect(IN PMIXER_CONTEXT MixerContext, ULONG DataFormatSize)
Definition: wave.c:72
LONG NTSTATUS
Definition: precomp.h:26
LPMIXER_DATA MMixerGetDataByDeviceId(IN PMIXER_LIST MixerList, IN ULONG DeviceId)
Definition: sup.c:736
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
HANDLE hDevice
Definition: precomp.h:115
PMIXER_FREE Free
Definition: mmixer.h:96
Status
Definition: gdiplustypes.h:24
struct KSDATAFORMAT_WAVEFORMATEX * PKSDATAFORMAT_WAVEFORMATEX
MIXER_STATUS
Definition: mmixer.h:3
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
return STATUS_SUCCESS
Definition: btrfs.c:2966
VOID MMixerInitializePinConnect(IN OUT PKSPIN_CONNECT PinConnect, IN ULONG PinId)
Definition: sup.c:901

Referenced by MMixerOpenWave().

◆ MMixerSetWaveResetState()

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

Definition at line 634 of file wave.c.

638 {
639  ULONG Length;
641  KSRESET Reset;
642 
643  /* verify mixer context */
645 
646  if (Status != MM_STATUS_SUCCESS)
647  {
648  /* invalid context passed */
649  return Status;
650  }
651 
652  /* begin / stop reset */
653  Reset = (bBegin ? KSRESET_BEGIN : KSRESET_END);
654 
655  return MixerContext->Control(PinHandle, IOCTL_KS_RESET_STATE, &Reset, sizeof(KSRESET), NULL, 0, &Length);
656 }
#define IOCTL_KS_RESET_STATE
Definition: ks.h:145
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
unsigned int ULONG
Definition: retypes.h:1
KSRESET
Definition: ks.h:1226

Referenced by WdmAudResetStreamByMMixer().

◆ MMixerSetWaveStatus()

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

Definition at line 607 of file wave.c.

611 {
613  ULONG Length;
615 
616  /* verify mixer context */
618 
619  if (Status != MM_STATUS_SUCCESS)
620  {
621  /* invalid context passed */
622  return Status;
623  }
624 
625  /* setup property request */
629 
630  return MixerContext->Control(PinHandle, IOCTL_KS_PROPERTY, &Property, sizeof(KSPROPERTY), &State, sizeof(KSSTATE), &Length);
631 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
const GUID KSPROPSETID_Connection
Definition: wave.c:14
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
_In_ DWORD Property
Definition: setupapi.h:1545
KSSTATE
Definition: ks.h:1214
MIXER_STATUS
Definition: mmixer.h:3
unsigned int ULONG
Definition: retypes.h:1
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43

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

◆ MMixerWaveInCapabilities()

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

Definition at line 491 of file wave.c.

495 {
496  PMIXER_LIST MixerList;
498  LPWAVE_INFO WaveInfo;
499 
500  /* verify mixer context */
502 
503  if (Status != MM_STATUS_SUCCESS)
504  {
505  /* invalid context passed */
506  return Status;
507  }
508 
509  /* grab mixer list */
510  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
511 
512  /* find destination wave */
513  Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, TRUE, &WaveInfo);
514  if (Status != MM_STATUS_SUCCESS)
515  {
516  /* failed to find wave info */
517  return MM_STATUS_UNSUCCESSFUL;
518  }
519 
520  /* copy capabilities */
521  MixerContext->Copy(Caps, &WaveInfo->u.InCaps, sizeof(WAVEINCAPSW));
522 
523  return MM_STATUS_SUCCESS;
524 }
#define TRUE
Definition: types.h:120
MIXER_STATUS MMixerGetWaveInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
Definition: wave.c:80
union WAVE_INFO::@3944 u
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
WAVEINCAPSW InCaps
Definition: precomp.h:130
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
struct MIXER_LIST * PMIXER_LIST
PMIXER_COPY Copy
Definition: mmixer.h:99

Referenced by WdmAudGetWaveInCapabilities(), and WdmAudWaveCapabilities().

◆ MMixerWaveOutCapabilities()

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

Definition at line 527 of file wave.c.

531 {
532  PMIXER_LIST MixerList;
534  LPWAVE_INFO WaveInfo;
535 
536  /* verify mixer context */
538 
539  if (Status != MM_STATUS_SUCCESS)
540  {
541  /* invalid context passed */
542  return Status;
543  }
544 
545  /* grab mixer list */
546  MixerList = (PMIXER_LIST)MixerContext->MixerContext;
547 
548  /* find destination wave */
549  Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceIndex, FALSE, &WaveInfo);
550  if (Status != MM_STATUS_SUCCESS)
551  {
552  /* failed to find wave info */
553  return MM_STATUS_UNSUCCESSFUL;
554  }
555 
556  /* copy capabilities */
557  MixerContext->Copy(Caps, &WaveInfo->u.OutCaps, sizeof(WAVEOUTCAPSW));
558 
559  return MM_STATUS_SUCCESS;
560 }
MIXER_STATUS MMixerGetWaveInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bWaveInType, OUT LPWAVE_INFO *OutWaveInfo)
Definition: wave.c:80
union WAVE_INFO::@3944 u
MIXER_STATUS MMixerVerifyContext(IN PMIXER_CONTEXT MixerContext)
Definition: sup.c:41
MIXER_CONTEXT MixerContext
Definition: mmixer.c:46
WAVEOUTCAPSW OutCaps
Definition: precomp.h:129
Status
Definition: gdiplustypes.h:24
MIXER_STATUS
Definition: mmixer.h:3
PVOID MixerContext
Definition: mmixer.h:92
struct MIXER_LIST * PMIXER_LIST
PMIXER_COPY Copy
Definition: mmixer.h:99

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}}

◆ 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().