ReactOS 0.4.15-dev-8207-gd73a838
pin_wavepci.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for pin_wavepci.cpp:

Go to the source code of this file.

Classes

class  CPortPinWavePci
 
struct  SETSTREAM_CONTEXT
 

Macros

#define NDEBUG
 

Typedefs

typedef struct SETSTREAM_CONTEXTPSETSTREAM_CONTEXT
 

Functions

NTSTATUS NTAPI PinWavePciState (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciDataFormat (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciAudioPosition (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
NTSTATUS NTAPI PinWavePciAllocatorFraming (IN PIRP Irp, IN PKSIDENTIFIER Request, IN OUT PVOID Data)
 
 DEFINE_KSPROPERTY_CONNECTIONSET (PinWavePciConnectionSet, PinWavePciState, PinWavePciDataFormat, PinWavePciAllocatorFraming)
 
 DEFINE_KSPROPERTY_AUDIOSET (PinWavePciAudioSet, PinWavePciAudioPosition)
 
NTSTATUS NewPortPinWavePci (OUT IPortPinWavePci **OutPin)
 

Variables

KSPROPERTY_SET PinWavePciPropertySet []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pin_wavepci.cpp.

Typedef Documentation

◆ PSETSTREAM_CONTEXT

Function Documentation

◆ DEFINE_KSPROPERTY_AUDIOSET()

DEFINE_KSPROPERTY_AUDIOSET ( PinWavePciAudioSet  ,
PinWavePciAudioPosition   
)

◆ DEFINE_KSPROPERTY_CONNECTIONSET()

DEFINE_KSPROPERTY_CONNECTIONSET ( PinWavePciConnectionSet  ,
PinWavePciState  ,
PinWavePciDataFormat  ,
PinWavePciAllocatorFraming   
)

◆ NewPortPinWavePci()

NTSTATUS NewPortPinWavePci ( OUT IPortPinWavePci **  OutPin)

Definition at line 968 of file pin_wavepci.cpp.

970{
972
974 if (!This)
976
977 This->AddRef();
978
979 // store result
980 *OutPin = (IPortPinWavePci*)This;
981
982 return STATUS_SUCCESS;
983}
#define NULL
Definition: types.h:112
#define NonPagedPool
Definition: env_spec_w32.h:307
#define TAG_PORTCLASS
Definition: private.hpp:24
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

◆ PinWavePciAllocatorFraming()

NTSTATUS NTAPI PinWavePciAllocatorFraming ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 95 of file pin_wavepci.cpp.

99{
102
103 // get sub device descriptor
104 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
105
106 // sanity check
108 PC_ASSERT(Descriptor->PortPin);
110
111 // cast to pin impl
112 Pin = (CPortPinWavePci*)Descriptor->PortPin;
113
115 {
116 // copy pin framing
117 RtlMoveMemory(Data, &Pin->m_AllocatorFraming, sizeof(KSALLOCATOR_FRAMING));
118
119 Irp->IoStatus.Information = sizeof(KSALLOCATOR_FRAMING);
120 return STATUS_SUCCESS;
121 }
122
123 // not supported
125}
struct SUBDEVICE_DESCRIPTOR * PSUBDEVICE_DESCRIPTOR
_In_ PIRP Irp
Definition: csq.h:116
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
if(dx< 0)
Definition: linetemp.h:194
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define PC_ASSERT_IRQL(x)
Definition: private.hpp:30
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

◆ PinWavePciAudioPosition()

NTSTATUS NTAPI PinWavePciAudioPosition ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 129 of file pin_wavepci.cpp.

133{
136
137 // get sub device descriptor
138 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
139
140 // sanity check
142 PC_ASSERT(Descriptor->PortPin);
144
145 // cast to pin impl
146 Pin = (CPortPinWavePci*)Descriptor->PortPin;
147
148 //sanity check
149 PC_ASSERT(Pin->m_Stream);
150
151 if (Request->Flags & KSPROPERTY_TYPE_GET)
152 {
153 // FIXME non multithreading-safe
154 // copy audio position
155 RtlMoveMemory(Data, &Pin->m_Position, sizeof(KSAUDIO_POSITION));
156
157 DPRINT("Play %lu Record %lu\n", Pin->m_Position.PlayOffset, Pin->m_Position.WriteOffset);
158 Irp->IoStatus.Information = sizeof(KSAUDIO_POSITION);
159 return STATUS_SUCCESS;
160 }
161
162 // not supported
164}
#define DPRINT
Definition: sndvol32.h:73

◆ PinWavePciDataFormat()

NTSTATUS NTAPI PinWavePciDataFormat ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 254 of file pin_wavepci.cpp.

258{
262 PIO_STACK_LOCATION IoStack;
263
264 // get current irp stack location
266
267 // get sub device descriptor
268 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
269
270 // sanity check
272 PC_ASSERT(Descriptor->PortPin);
273
274 // cast to pin impl
275 Pin = (CPortPinWavePci*)Descriptor->PortPin;
276
277 //sanity check
278 PC_ASSERT(Pin->m_Stream);
279 PC_ASSERT(Pin->m_Format);
280
281 if (Request->Flags & KSPROPERTY_TYPE_SET)
282 {
283 // try to change data format
284 PKSDATAFORMAT NewDataFormat, DataFormat = (PKSDATAFORMAT)Irp->UserBuffer;
285 ULONG Size = min(Pin->m_Format->FormatSize, DataFormat->FormatSize);
286
287 if (RtlCompareMemory(DataFormat, Pin->m_Format, Size) == Size)
288 {
289 // format is identical
290 Irp->IoStatus.Information = DataFormat->FormatSize;
291 return STATUS_SUCCESS;
292 }
293
294 // new change request
295 PC_ASSERT(Pin->m_State == KSSTATE_STOP);
296 // FIXME queue a work item when Irql != PASSIVE_LEVEL
298
299 // allocate new data format
300 NewDataFormat = (PKSDATAFORMAT)AllocateItem(NonPagedPool, DataFormat->FormatSize, TAG_PORTCLASS);
301 if (!NewDataFormat)
302 {
303 // not enough memory
304 return STATUS_NO_MEMORY;
305 }
306
307 // copy new data format
308 RtlMoveMemory(NewDataFormat, DataFormat, DataFormat->FormatSize);
309
310 // set new format
311 Status = Pin->m_Stream->SetFormat(NewDataFormat);
312 if (NT_SUCCESS(Status))
313 {
314 // free old format
315 FreeItem(Pin->m_Format, TAG_PORTCLASS);
316
317 // store new format
318 Pin->m_Format = NewDataFormat;
319 Irp->IoStatus.Information = NewDataFormat->FormatSize;
320
321#if 0
322 PC_ASSERT(NewDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX));
326
327 DPRINT("NewDataFormat: Channels %u Bits %u Samples %u\n", ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nChannels,
328 ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.wBitsPerSample,
329 ((PKSDATAFORMAT_WAVEFORMATEX)NewDataFormat)->WaveFormatEx.nSamplesPerSec);
330#endif
331
332 }
333 else
334 {
335 // failed to set format
336 FreeItem(NewDataFormat, TAG_PORTCLASS);
337 }
338
339 // done
340 return Status;
341 }
342 else if (Request->Flags & KSPROPERTY_TYPE_GET)
343 {
344 // get current data format
345 PC_ASSERT(Pin->m_Format);
346
347 if (Pin->m_Format->FormatSize > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
348 {
349 // buffer too small
350 Irp->IoStatus.Information = Pin->m_Format->FormatSize;
351 return STATUS_MORE_ENTRIES;
352 }
353 // copy data format
354 RtlMoveMemory(Data, Pin->m_Format, Pin->m_Format->FormatSize);
355 // store result size
356 Irp->IoStatus.Information = Pin->m_Format->FormatSize;
357
358 // done
359 return STATUS_SUCCESS;
360 }
361
362 // unsupported request
364}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
KSDATAFORMAT * PKSDATAFORMAT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
Status
Definition: gdiplustypes.h:25
@ KSSTATE_STOP
Definition: ks.h:1215
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
#define min(a, b)
Definition: monoChain.cc:55
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
union _IO_STACK_LOCATION::@1573 Parameters
struct _IO_STACK_LOCATION::@1573::@1574 DeviceIoControl
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

◆ PinWavePciState()

NTSTATUS NTAPI PinWavePciState ( IN PIRP  Irp,
IN PKSIDENTIFIER  Request,
IN OUT PVOID  Data 
)

Definition at line 168 of file pin_wavepci.cpp.

172{
176 PVOID FirstTag, LastTag;
177 ULONG MappingsRevoked;
179
180 // get sub device descriptor
181 Descriptor = (PSUBDEVICE_DESCRIPTOR)KSPROPERTY_ITEM_IRP_STORAGE(Irp);
182
183 // sanity check
185 PC_ASSERT(Descriptor->PortPin);
187
188 // cast to pin impl
189 Pin = (CPortPinWavePci*)Descriptor->PortPin;
190
191 //sanity check
192 PC_ASSERT(Pin->m_Stream);
193
194 if (Request->Flags & KSPROPERTY_TYPE_SET)
195 {
196 // try set stream
197 Status = Pin->m_Stream->SetState(*State);
198
199 DPRINT("Setting state %u %x\n", *State, Status);
200 if (NT_SUCCESS(Status))
201 {
202 // store new state
203 Pin->m_State = *State;
204 if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING && Pin->m_State == KSSTATE_STOP)
205 {
206 // FIXME
207 // complete with successful state
208 Pin->m_IrpQueue->CancelBuffers();
209 while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
210 {
211 Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
212 DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
214 }
215 Pin->m_Position.PlayOffset = 0;
216 Pin->m_Position.WriteOffset = 0;
217 }
218 else if (Pin->m_State == KSSTATE_STOP)
219 {
220 Pin->m_IrpQueue->CancelBuffers();
221 while(Pin->m_IrpQueue->GetAcquiredTagRange(&FirstTag, &LastTag))
222 {
223 Status = Pin->m_Stream->RevokeMappings(FirstTag, LastTag, &MappingsRevoked);
224 DPRINT("RevokeMappings Status %lx MappingsRevoked: %lu\n", Status, MappingsRevoked);
226 }
227 Pin->m_Position.PlayOffset = 0;
228 Pin->m_Position.WriteOffset = 0;
229 }
230 // store result
231 Irp->IoStatus.Information = sizeof(KSSTATE);
232
233 }
234 // store result
235 Irp->IoStatus.Information = sizeof(KSSTATE);
236 return Status;
237 }
238 else if (Request->Flags & KSPROPERTY_TYPE_GET)
239 {
240 // get current stream state
241 *State = Pin->m_State;
242 // store result
243 Irp->IoStatus.Information = sizeof(KSSTATE);
244
245 return STATUS_SUCCESS;
246 }
247
248 // unsupported request
250}
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
enum KSSTATE * PKSSTATE
KSSTATE
Definition: ks.h:1214
@ KSINTERFACE_STANDARD_LOOPED_STREAMING
Definition: ks.h:284

Variable Documentation

◆ PinWavePciPropertySet

KSPROPERTY_SET PinWavePciPropertySet[]
Initial value:
=
{
{
sizeof(PinWavePciConnectionSet) / sizeof(KSPROPERTY_ITEM),
(const KSPROPERTY_ITEM*)&PinWavePciConnectionSet,
0,
},
{
sizeof(PinWavePciAudioSet) / sizeof(KSPROPERTY_ITEM),
(const KSPROPERTY_ITEM*)&PinWavePciAudioSet,
0,
}
}
#define KSPROPSETID_Connection
Definition: ks.h:346
#define KSPROPSETID_Audio
Definition: ksmedia.h:1051

Definition at line 75 of file pin_wavepci.cpp.