Author: janderwald
Date: Sat Jun 1 23:16:08 2013
New Revision: 59137
URL:
http://svn.reactos.org/svn/reactos?rev=59137&view=rev
Log:
[AUDIO]
- Support zero value tags
CORE-6890 #comment please retest
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp [iso-8859-1] Sat Jun 1
23:16:08 2013
@@ -59,13 +59,19 @@
typedef struct
{
+ PVOID Tag;
+ UCHAR Used;
+}KSSTREAM_TAG, *PKSSTREAM_TAG;
+
+typedef struct
+{
ULONG StreamHeaderCount;
ULONG StreamHeaderIndex;
ULONG TotalStreamData;
PKSSTREAM_HEADER CurStreamHeader;
PVOID * Data;
- PVOID * Tags;
+ PKSSTREAM_TAG Tags;
}KSSTREAM_DATA, *PKSSTREAM_DATA;
#define STREAM_DATA_OFFSET (0)
@@ -208,7 +214,7 @@
if (m_TagSupportEnabled)
{
// allocate array for storing the pointers of the data */
- StreamData->Tags = (PVOID*)AllocateItem(NonPagedPool, sizeof(PVOID) *
StreamData->StreamHeaderCount, TAG_PORTCLASS);
+ StreamData->Tags = (PKSSTREAM_TAG)AllocateItem(NonPagedPool,
sizeof(KSSTREAM_TAG) * StreamData->StreamHeaderCount, TAG_PORTCLASS);
if (!StreamData->Data)
{
// out of memory
@@ -520,7 +526,6 @@
PKSSTREAM_DATA StreamData;
/* sanity checks */
- PC_ASSERT(Tag != NULL);
PC_ASSERT(PhysicalAddress);
PC_ASSERT(VirtualAddress);
PC_ASSERT(ByteCount);
@@ -551,7 +556,11 @@
*VirtualAddress = StreamData->Data[StreamData->StreamHeaderIndex];
// store tag in irp
- StreamData->Tags[StreamData->StreamHeaderIndex] = Tag;
+ StreamData->Tags[StreamData->StreamHeaderIndex].Tag = Tag;
+ StreamData->Tags[StreamData->StreamHeaderIndex].Used = TRUE;
+
+ // increment header index
+ StreamData->StreamHeaderIndex++;
// mapping size
if (m_Descriptor->DataFlow == KSPIN_DATAFLOW_IN)
@@ -571,7 +580,7 @@
m_NumDataAvailable -= StreamData->CurStreamHeader->FrameExtent;
}
- if (StreamData->StreamHeaderIndex + 1 == StreamData->StreamHeaderCount)
+ if (StreamData->StreamHeaderIndex == StreamData->StreamHeaderCount)
{
// last mapping
*Flags = 1;
@@ -587,9 +596,6 @@
{
// one more mapping in the irp
*Flags = 0;
-
- // increment header index
- StreamData->StreamHeaderIndex++;
// move to next header
StreamData->CurStreamHeader =
(PKSSTREAM_HEADER)((ULONG_PTR)StreamData->CurStreamHeader +
StreamData->CurStreamHeader->Size);
@@ -622,10 +628,11 @@
for(Index = 0; Index < StreamData->StreamHeaderIndex; Index++)
{
// check if it is the same tag
- if (StreamData->Tags[Index] == Tag)
+ if (StreamData->Tags[Index].Tag == Tag &&
StreamData->Tags[Index].Used == TRUE)
{
// mark mapping as released
- StreamData->Tags[Index] = NULL;
+ StreamData->Tags[Index].Tag = NULL;
+ StreamData->Tags[Index].Used = FALSE;
// done
return STATUS_SUCCESS;
@@ -648,15 +655,17 @@
StreamData = (PKSSTREAM_DATA)Irp->Tail.Overlay.DriverContext[STREAM_DATA_OFFSET];
// sanity check
- PC_ASSERT(StreamData->StreamHeaderIndex + 1 == StreamData->StreamHeaderCount);
+ PC_ASSERT(StreamData->StreamHeaderIndex == StreamData->StreamHeaderCount);
// check if the released mapping is one of these
for(Index = 0; Index < StreamData->StreamHeaderCount; Index++)
{
- if (StreamData->Tags[Index] == Tag)
+ if (StreamData->Tags[Index].Tag == Tag &&
+ StreamData->Tags[Index].Used == TRUE)
{
// mark mapping as released
- StreamData->Tags[Index] = NULL;
+ StreamData->Tags[Index].Tag = NULL;
+ StreamData->Tags[Index].Used = FALSE;
// done
break;
@@ -668,7 +677,8 @@
// therefore if the current mapping is not the searched one, it must have
been already
// released
//
- PC_ASSERT(StreamData->Tags[Index] == NULL);
+ ASSERT(StreamData->Tags[Index].Tag == NULL);
+ ASSERT(StreamData->Tags[Index].Used == FALSE);
}
}