- When acquiring a mapping check if the mapping hasn't already been used

- Set tag value to zero when releasing a mapping

svn path=/trunk/; revision=40832
This commit is contained in:
Johannes Anderwald 2009-05-07 23:33:27 +00:00
parent 94d54b18f9
commit 8e4c1cabb7

View file

@ -142,7 +142,6 @@ IIrpQueue_fnAddMapping(
IN PIRP Irp) IN PIRP Irp)
{ {
PIRP_MAPPING Mapping; PIRP_MAPPING Mapping;
ULONG Index;
IIrpQueueImpl * This = (IIrpQueueImpl*)iface; IIrpQueueImpl * This = (IIrpQueueImpl*)iface;
Mapping = AllocateItem(NonPagedPool, sizeof(IRP_MAPPING), TAG_PORTCLASS); Mapping = AllocateItem(NonPagedPool, sizeof(IRP_MAPPING), TAG_PORTCLASS);
@ -183,8 +182,7 @@ IIrpQueue_fnAddMapping(
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
ASSERT(Mapping->NumTags < 32); ASSERT(Mapping->NumTags < 32);
for(Index = 0; Index < Mapping->NumTags; Index++); Mapping->References = (1 << Mapping->NumTags) - 1;
Mapping->References |= (1 << Index);
This->NumDataAvailable += Mapping->Header->DataUsed; This->NumDataAvailable += Mapping->Header->DataUsed;
@ -392,6 +390,7 @@ IIrpQueue_fnGetMappingWithTag(
PIRP_MAPPING CurMapping; PIRP_MAPPING CurMapping;
PLIST_ENTRY CurEntry; PLIST_ENTRY CurEntry;
ULONG Index; ULONG Index;
ULONG Value;
IIrpQueueImpl * This = (IIrpQueueImpl*)iface; IIrpQueueImpl * This = (IIrpQueueImpl*)iface;
*Flags = 0; *Flags = 0;
@ -413,7 +412,8 @@ IIrpQueue_fnGetMappingWithTag(
CurMapping = CONTAINING_RECORD(CurEntry, IRP_MAPPING, Entry); CurMapping = CONTAINING_RECORD(CurEntry, IRP_MAPPING, Entry);
for(Index = 0; Index < CurMapping->NumTags; Index++) for(Index = 0; Index < CurMapping->NumTags; Index++)
{ {
if (CurMapping->Tag[Index] == NULL) Value = CurMapping->References & ( 1 << Index);
if (CurMapping->Tag[Index] == NULL && Value)
{ {
/* found a free mapping within audio irp */ /* found a free mapping within audio irp */
GetMapping(This, Index, Tag, CurMapping, PhysicalAddress, VirtualAddress, ByteCount, Flags); GetMapping(This, Index, Tag, CurMapping, PhysicalAddress, VirtualAddress, ByteCount, Flags);
@ -460,6 +460,7 @@ IIrpQueue_fnReleaseMappingWithTag(
if (CurMapping->Tag[Index] == Tag) if (CurMapping->Tag[Index] == Tag)
{ {
Found = TRUE; Found = TRUE;
CurMapping->Tag[Index] = NULL;
break; break;
} }
} }