ReactOS 0.4.15-dev-8102-g108db8f
midi.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for midi.c:

Go to the source code of this file.

Functions

MIXER_STATUS MMixerGetPinDataFlowAndCommunication (IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice, IN ULONG PinId, OUT PKSPIN_DATAFLOW DataFlow, OUT PKSPIN_COMMUNICATION Communication)
 
MIXER_STATUS MMixerAddMidiPin (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN ULONG bInput, IN LPWSTR DeviceName)
 
VOID MMixerCheckFilterPinMidiSupport (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN LPMIXER_DATA MixerData, IN ULONG PinId, IN PKSMULTIPLE_ITEM MultipleItem, IN LPWSTR szPname)
 
VOID MMixerInitializeMidiForFilter (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN LPMIXER_DATA MixerData, IN PTOPOLOGY Topology)
 
MIXER_STATUS MMixerOpenMidiPin (IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN ACCESS_MASK DesiredAccess, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
 
MIXER_STATUS MMixerGetMidiInfoByIndexAndType (IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bMidiInputType, OUT LPMIDI_INFO *OutMidiInfo)
 
MIXER_STATUS MMixerMidiOutCapabilities (IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIOUTCAPSW Caps)
 
MIXER_STATUS MMixerMidiInCapabilities (IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, OUT LPMIDIINCAPSW Caps)
 
MIXER_STATUS MMixerGetMidiDevicePath (IN PMIXER_CONTEXT MixerContext, IN ULONG bMidiIn, IN ULONG DeviceId, OUT LPWSTR *DevicePath)
 
MIXER_STATUS MMixerSetMidiStatus (IN PMIXER_CONTEXT MixerContext, IN HANDLE PinHandle, IN KSSTATE State)
 
MIXER_STATUS MMixerOpenMidi (IN PMIXER_CONTEXT MixerContext, IN ULONG DeviceIndex, IN ULONG bMidiIn, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
 
ULONG MMixerGetMidiInCount (IN PMIXER_CONTEXT MixerContext)
 
ULONG MMixerGetMidiOutCount (IN PMIXER_CONTEXT MixerContext)
 

Function Documentation

◆ MMixerAddMidiPin()

MIXER_STATUS MMixerAddMidiPin ( IN PMIXER_CONTEXT  MixerContext,
IN PMIXER_LIST  MixerList,
IN ULONG  DeviceId,
IN ULONG  PinId,
IN ULONG  bInput,
IN LPWSTR  DeviceName 
)

Definition at line 51 of file midi.c.

58{
59 LPMIDI_INFO MidiInfo;
60
61 /* allocate midi info */
62 MidiInfo = MixerContext->Alloc(sizeof(MIDI_INFO));
63
64 if (!MidiInfo)
65 {
66 /* no memory */
68 }
69
70 /* initialize midi info */
71 MidiInfo->DeviceId = DeviceId;
72 MidiInfo->PinId = PinId;
73
74 /* sanity check */
76
77 /* copy device name */
78 if (bInput && DeviceName)
79 {
80 wcscpy(MidiInfo->u.InCaps.szPname, DeviceName);
81 }
82 else if (!bInput && DeviceName)
83 {
84 wcscpy(MidiInfo->u.OutCaps.szPname, DeviceName);
85 }
86
87 /* FIXME determine manufacturer / product id */
88 if (bInput)
89 {
90 MidiInfo->u.InCaps.dwSupport = 0;
91 MidiInfo->u.InCaps.wMid = MM_MICROSOFT;
92 MidiInfo->u.InCaps.wPid = MM_PID_UNMAPPED;
93 MidiInfo->u.InCaps.vDriverVersion = 1;
94 }
95 else
96 {
97 MidiInfo->u.OutCaps.dwSupport = 0;
98 MidiInfo->u.OutCaps.wMid = MM_MICROSOFT;
99 MidiInfo->u.OutCaps.wPid = MM_PID_UNMAPPED;
100 MidiInfo->u.OutCaps.vDriverVersion = 1;
101 }
102
103 if (bInput)
104 {
105 /* insert into list */
106 InsertTailList(&MixerList->MidiInList, &MidiInfo->Entry);
107 MixerList->MidiInListCount++;
108 }
109 else
110 {
111 /* insert into list */
112 InsertTailList(&MixerList->MidiOutList, &MidiInfo->Entry);
113 MixerList->MidiOutListCount++;
114 }
115
116 return MM_STATUS_SUCCESS;
117}
MIXER_CONTEXT MixerContext
Definition: mmixer.c:41
#define InsertTailList(ListHead, Entry)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
@ MM_STATUS_NO_MEMORY
Definition: mmixer.h:12
@ MM_STATUS_SUCCESS
Definition: mmixer.h:5
#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)
ULONG PinId
Definition: precomp.h:138
MIDIOUTCAPSW OutCaps
Definition: precomp.h:141
union MIDI_INFO::@4340 u
MIDIINCAPSW InCaps
Definition: precomp.h:142
LIST_ENTRY Entry
Definition: precomp.h:136
ULONG DeviceId
Definition: precomp.h:137
PMIXER_ALLOC Alloc
Definition: mmixer.h:94
MMVERSION vDriverVersion
Definition: mmsystem.h:1145
DWORD dwSupport
Definition: mmsystem.h:1147
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1146
MMVERSION vDriverVersion
Definition: mmsystem.h:1125
WCHAR szPname[MAXPNAMELEN]
Definition: mmsystem.h:1126
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275

Referenced by MMixerCheckFilterPinMidiSupport().

◆ MMixerCheckFilterPinMidiSupport()

VOID MMixerCheckFilterPinMidiSupport ( IN PMIXER_CONTEXT  MixerContext,
IN PMIXER_LIST  MixerList,
IN LPMIXER_DATA  MixerData,
IN ULONG  PinId,
IN PKSMULTIPLE_ITEM  MultipleItem,
IN LPWSTR  szPname 
)

Definition at line 120 of file midi.c.

127{
128 ULONG Index;
129 PKSDATARANGE DataRange;
130 KSPIN_COMMUNICATION Communication;
132
133 /* get first datarange */
134 DataRange = (PKSDATARANGE)(MultipleItem + 1);
135
136 /* alignment assert */
137 ASSERT(((ULONG_PTR)DataRange & 0x7) == 0);
138
139 /* iterate through all data ranges */
140 for(Index = 0; Index < MultipleItem->Count; Index++)
141 {
145 {
146 /* pin supports midi datarange */
147 if (MMixerGetPinDataFlowAndCommunication(MixerContext, MixerData->hDevice, PinId, &DataFlow, &Communication) == MM_STATUS_SUCCESS)
148 {
149 if (DataFlow == KSPIN_DATAFLOW_IN && Communication == KSPIN_COMMUNICATION_SINK)
150 {
151 MMixerAddMidiPin(MixerContext, MixerList, MixerData->DeviceId, PinId, FALSE, szPname);
152 }
153 else if (DataFlow == KSPIN_DATAFLOW_OUT && Communication == KSPIN_COMMUNICATION_SOURCE)
154 {
155 MMixerAddMidiPin(MixerContext, MixerList, MixerData->DeviceId, PinId, TRUE, szPname);
156 }
157 }
158 }
159
160 /* move to next datarange */
161 DataRange = (PKSDATARANGE)((ULONG_PTR)DataRange + DataRange->FormatSize);
162
163 /* alignment assert */
164 ASSERT(((ULONG_PTR)DataRange & 0x7) == 0);
165
166 /* data ranges are 64-bit aligned */
167 DataRange = (PVOID)(((ULONG_PTR)DataRange + 0x7) & ~0x7);
168 }
169}
DataFlow
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KSDATAFORMAT_SPECIFIER_NONE
Definition: ks.h:1157
KSPIN_DATAFLOW
Definition: ks.h:1248
@ KSPIN_DATAFLOW_IN
Definition: ks.h:1249
@ KSPIN_DATAFLOW_OUT
Definition: ks.h:1250
KSPIN_COMMUNICATION
Definition: ks.h:1253
@ KSPIN_COMMUNICATION_SOURCE
Definition: ks.h:1256
@ KSPIN_COMMUNICATION_SINK
Definition: ks.h:1255
union KSDATAFORMAT * PKSDATARANGE
#define KSDATAFORMAT_TYPE_MUSIC
Definition: ksmedia.h:1005
#define KSDATAFORMAT_SUBTYPE_MIDI
Definition: ksmedia.h:1016
MIXER_STATUS MMixerAddMidiPin(IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN ULONG bInput, IN LPWSTR DeviceName)
Definition: midi.c:51
MIXER_STATUS MMixerGetPinDataFlowAndCommunication(IN PMIXER_CONTEXT MixerContext, IN HANDLE hDevice, IN ULONG PinId, OUT PKSPIN_DATAFLOW DataFlow, OUT PKSPIN_COMMUNICATION Communication)
Definition: midi.c:15
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by MMixerInitializeMidiForFilter().

◆ MMixerGetMidiDevicePath()

MIXER_STATUS MMixerGetMidiDevicePath ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  bMidiIn,
IN ULONG  DeviceId,
OUT LPWSTR DevicePath 
)

Definition at line 380 of file midi.c.

385{
386 PMIXER_LIST MixerList;
387 LPMIXER_DATA MixerData;
388 LPMIDI_INFO MidiInfo;
391
392 /* verify mixer context */
394
396 {
397 /* invalid context passed */
398 return Status;
399 }
400
401 /* grab mixer list */
403
404 /* find destination midi */
405 Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceId, bMidiIn, &MidiInfo);
407 {
408 /* failed to find midi info */
410 }
411
412 /* get associated device id */
413 MixerData = MMixerGetDataByDeviceId(MixerList, MidiInfo->DeviceId);
414 if (!MixerData)
416
417 /* calculate length */
418 Length = wcslen(MixerData->DeviceName)+1;
419
420 /* allocate destination buffer */
421 *DevicePath = MixerContext->Alloc(Length * sizeof(WCHAR));
422
423 if (!*DevicePath)
424 {
425 /* no memory */
426 return MM_STATUS_NO_MEMORY;
427 }
428
429 /* copy device path */
430 MixerContext->Copy(*DevicePath, MixerData->DeviceName, Length * sizeof(WCHAR));
431
432 /* done */
433 return MM_STATUS_SUCCESS;
434}
Status
Definition: gdiplustypes.h:25
MIXER_STATUS
Definition: mmixer.h:4
@ MM_STATUS_INVALID_PARAMETER
Definition: mmixer.h:10
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
MIXER_STATUS MMixerGetMidiInfoByIndexAndType(IN PMIXER_LIST MixerList, IN ULONG DeviceIndex, IN ULONG bMidiInputType, OUT LPMIDI_INFO *OutMidiInfo)
Definition: midi.c:273
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
PMIXER_COPY Copy
Definition: mmixer.h:99
PVOID MixerContext
Definition: mmixer.h:92
LPWSTR DeviceName
Definition: precomp.h:117
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by WdmAudGetPnpNameByIndexAndType().

◆ MMixerGetMidiInCount()

ULONG MMixerGetMidiInCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 502 of file midi.c.

504{
505 PMIXER_LIST MixerList;
507
508 /* verify mixer context */
510
512 {
513 /* invalid context passed */
514 return Status;
515 }
516
517 /* grab mixer list */
519
520 return MixerList->MidiInListCount;
521}
ULONG MidiInListCount
Definition: precomp.h:161

Referenced by WdmAudGetMidiInDeviceCount().

◆ MMixerGetMidiInfoByIndexAndType()

MIXER_STATUS MMixerGetMidiInfoByIndexAndType ( IN PMIXER_LIST  MixerList,
IN ULONG  DeviceIndex,
IN ULONG  bMidiInputType,
OUT LPMIDI_INFO OutMidiInfo 
)

Definition at line 273 of file midi.c.

278{
279 ULONG Index = 0;
280 PLIST_ENTRY Entry, ListHead;
281 LPMIDI_INFO MidiInfo;
282
283 if (bMidiInputType)
284 ListHead = &MixerList->MidiInList;
285 else
286 ListHead = &MixerList->MidiOutList;
287
288 /* get first entry */
289 Entry = ListHead->Flink;
290
291 while(Entry != ListHead)
292 {
294
295 if (Index == DeviceIndex)
296 {
297 *OutMidiInfo = MidiInfo;
298 return MM_STATUS_SUCCESS;
299 }
300 Index++;
301 Entry = Entry->Flink;
302 }
303
305}
struct MIDI_INFO * LPMIDI_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 MMixerGetMidiDevicePath(), MMixerMidiInCapabilities(), MMixerMidiOutCapabilities(), and MMixerOpenMidi().

◆ MMixerGetMidiOutCount()

ULONG MMixerGetMidiOutCount ( IN PMIXER_CONTEXT  MixerContext)

Definition at line 524 of file midi.c.

526{
527 PMIXER_LIST MixerList;
529
530 /* verify mixer context */
532
534 {
535 /* invalid context passed */
536 return Status;
537 }
538
539 /* grab mixer list */
541
542 return MixerList->MidiOutListCount;
543}
ULONG MidiOutListCount
Definition: precomp.h:164

◆ MMixerGetPinDataFlowAndCommunication()

MIXER_STATUS MMixerGetPinDataFlowAndCommunication ( IN PMIXER_CONTEXT  MixerContext,
IN HANDLE  hDevice,
IN ULONG  PinId,
OUT PKSPIN_DATAFLOW  DataFlow,
OUT PKSPIN_COMMUNICATION  Communication 
)

Definition at line 15 of file midi.c.

21{
25
26 /* setup request */
27 Pin.PinId = PinId;
28 Pin.Reserved = 0;
29 Pin.Property.Flags = KSPROPERTY_TYPE_GET;
30 Pin.Property.Id = KSPROPERTY_PIN_DATAFLOW;
31 Pin.Property.Set = KSPROPSETID_Pin;
32
33 /* get pin dataflow */
36 {
37 /* failed to retrieve dataflow */
38 return Status;
39 }
40
41 /* setup communication request */
43
44 /* get pin communication */
45 Status = MixerContext->Control(hDevice, IOCTL_KS_PROPERTY, (PVOID)&Pin, sizeof(KSP_PIN), (PVOID)Communication, sizeof(KSPIN_COMMUNICATION), &BytesReturned);
46
47 return Status;
48}
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define KSPROPSETID_Pin
Definition: ks.h:617
@ KSPROPERTY_PIN_COMMUNICATION
Definition: ks.h:632
@ KSPROPERTY_PIN_DATAFLOW
Definition: ks.h:627
Definition: ks.h:642
PMIXER_DEVICE_CONTROL Control
Definition: mmixer.h:95
ULONG Flags
Definition: ntfs.h:536
_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 MMixerCheckFilterPinMidiSupport(), and MMixerGetComponentAndTargetType().

◆ MMixerInitializeMidiForFilter()

VOID MMixerInitializeMidiForFilter ( IN PMIXER_CONTEXT  MixerContext,
IN PMIXER_LIST  MixerList,
IN LPMIXER_DATA  MixerData,
IN PTOPOLOGY  Topology 
)

Definition at line 172 of file midi.c.

177{
180 PKSMULTIPLE_ITEM MultipleItem;
181 WCHAR szPname[MAXPNAMELEN];
182
183 /* get filter pin count */
185
186 /* get mixer name */
187 if (MMixerGetDeviceName(MixerContext, szPname, MixerData->hDeviceInterfaceKey) != MM_STATUS_SUCCESS)
188 {
189 /* clear name */
190 szPname[0] = 0;
191 }
192
193 /* iterate all pins and check for KSDATARANGE_MUSIC support */
194 for(Index = 0; Index < PinCount; Index++)
195 {
196 /* get audio pin data ranges */
197 Status = MMixerGetAudioPinDataRanges(MixerContext, MixerData->hDevice, Index, &MultipleItem);
198
199 /* check for success */
201 {
202 /* check if there is support KSDATARANGE_MUSIC */
203 MMixerCheckFilterPinMidiSupport(MixerContext, MixerList, MixerData, Index, MultipleItem, szPname);
204 }
205 }
206}
VOID MMixerCheckFilterPinMidiSupport(IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN LPMIXER_DATA MixerData, IN ULONG PinId, IN PKSMULTIPLE_ITEM MultipleItem, IN LPWSTR szPname)
Definition: midi.c:120
VOID MMixerGetTopologyPinCount(IN PTOPOLOGY Topology, OUT PULONG PinCount)
Definition: topology.c:1004
MIXER_STATUS MMixerGetDeviceName(IN PMIXER_CONTEXT MixerContext, OUT LPWSTR DeviceName, IN HANDLE hKey)
Definition: sup.c:852
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

◆ MMixerMidiInCapabilities()

MIXER_STATUS MMixerMidiInCapabilities ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  DeviceIndex,
OUT LPMIDIINCAPSW  Caps 
)

Definition at line 344 of file midi.c.

348{
349 PMIXER_LIST MixerList;
351 LPMIDI_INFO MidiInfo;
352
353 /* verify mixer context */
355
357 {
358 /* invalid context passed */
359 return Status;
360 }
361
362 /* grab mixer list */
364
365 /* find destination midi */
366 Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, TRUE, &MidiInfo);
368 {
369 /* failed to find midi info */
371 }
372
373 /* copy capabilities */
374 MixerContext->Copy(Caps, &MidiInfo->u.InCaps, sizeof(MIDIINCAPSW));
375
376 return MM_STATUS_SUCCESS;
377}
@ MM_STATUS_UNSUCCESSFUL
Definition: mmixer.h:11

Referenced by WdmAudMidiCapabilities().

◆ MMixerMidiOutCapabilities()

MIXER_STATUS MMixerMidiOutCapabilities ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  DeviceIndex,
OUT LPMIDIOUTCAPSW  Caps 
)

Definition at line 308 of file midi.c.

312{
313 PMIXER_LIST MixerList;
315 LPMIDI_INFO MidiInfo;
316
317 /* verify mixer context */
319
321 {
322 /* invalid context passed */
323 return Status;
324 }
325
326 /* grab mixer list */
328
329 /* find destination midi */
330 Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, FALSE, &MidiInfo);
332 {
333 /* failed to find midi info */
335 }
336
337 /* copy capabilities */
338 MixerContext->Copy(Caps, &MidiInfo->u.OutCaps, sizeof(MIDIOUTCAPSW));
339
340 return MM_STATUS_SUCCESS;
341}

Referenced by WdmAudMidiCapabilities().

◆ MMixerOpenMidi()

MIXER_STATUS MMixerOpenMidi ( IN PMIXER_CONTEXT  MixerContext,
IN ULONG  DeviceIndex,
IN ULONG  bMidiIn,
IN PIN_CREATE_CALLBACK  CreateCallback,
IN PVOID  Context,
OUT PHANDLE  PinHandle 
)

Definition at line 454 of file midi.c.

461{
462 PMIXER_LIST MixerList;
464 LPMIDI_INFO MidiInfo;
466
467 /* verify mixer context */
469
471 {
472 /* invalid context passed */
473 return Status;
474 }
475
476 /* grab mixer list */
478
479 /* find destination midi */
480 Status = MMixerGetMidiInfoByIndexAndType(MixerList, DeviceIndex, bMidiIn, &MidiInfo);
482 {
483 /* failed to find midi info */
485 }
486
487 /* get desired access */
488 if (bMidiIn)
489 {
491 }
492 else
493 {
495 }
496
497 /* now try open the pin */
498 return MMixerOpenMidiPin(MixerContext, MixerList, MidiInfo->DeviceId, MidiInfo->PinId, 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 MMixerOpenMidiPin(IN PMIXER_CONTEXT MixerContext, IN PMIXER_LIST MixerList, IN ULONG DeviceId, IN ULONG PinId, IN ACCESS_MASK DesiredAccess, IN PIN_CREATE_CALLBACK CreateCallback, IN PVOID Context, OUT PHANDLE PinHandle)
Definition: midi.c:209
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

Referenced by WdmAudControlOpenMidi().

◆ MMixerOpenMidiPin()

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

Definition at line 209 of file midi.c.

218{
219 PKSPIN_CONNECT PinConnect;
221 LPMIXER_DATA MixerData;
223 MIXER_STATUS MixerStatus;
224
225 MixerData = MMixerGetDataByDeviceId(MixerList, DeviceId);
226 if (!MixerData)
228
229 /* allocate pin connect */
231 if (!PinConnect)
232 {
233 /* no memory */
234 return MM_STATUS_NO_MEMORY;
235 }
236
237 /* initialize pin connect struct */
238 MMixerInitializePinConnect(PinConnect, PinId);
239
240 /* get offset to dataformat */
241 DataFormat = (PKSDATAFORMAT) (PinConnect + 1);
242
243 /* initialize data format */
244 RtlMoveMemory(&DataFormat->MajorFormat, &KSDATAFORMAT_TYPE_MUSIC, sizeof(GUID));
247
248 if (CreateCallback)
249 {
250 /* let the callback handle the creation */
251 MixerStatus = CreateCallback(Context, DeviceId, PinId, MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
252 }
253 else
254 {
255 /* now create the pin */
256 Status = KsCreatePin(MixerData->hDevice, PinConnect, DesiredAccess, PinHandle);
257
258 /* normalize status */
259 if (Status == STATUS_SUCCESS)
260 MixerStatus = MM_STATUS_SUCCESS;
261 else
262 MixerStatus = MM_STATUS_UNSUCCESSFUL;
263 }
264
265 /* free create info */
266 MixerContext->Free(PinConnect);
267
268 /* done */
269 return MixerStatus;
270}
LONG NTSTATUS
Definition: precomp.h:26
KSDATAFORMAT * PKSDATAFORMAT
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
VOID MMixerInitializePinConnect(IN OUT PKSPIN_CONNECT PinConnect, IN ULONG PinId)
Definition: sup.c:901
#define STATUS_SUCCESS
Definition: shellext.h:65
PMIXER_FREE Free
Definition: mmixer.h:96
HANDLE hDevice
Definition: precomp.h:115
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by MMixerOpenMidi().

◆ MMixerSetMidiStatus()

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

Definition at line 437 of file midi.c.

441{
444
445 /* setup property request */
449
450 return MixerContext->Control(PinHandle, IOCTL_KS_PROPERTY, &Property, sizeof(KSPROPERTY), &State, sizeof(KSSTATE), &Length);
451}
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
@ KSPROPERTY_CONNECTION_STATE
Definition: ks.h:349
KSSTATE
Definition: ks.h:1214
#define KSPROPSETID_Connection
Definition: ks.h:346

Referenced by WdmAudSetWaveStateByMMixer().