From 8e4c1cabb751febc282ffda30f3bb212bad97e94 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 7 May 2009 23:33:27 +0000 Subject: [PATCH] - 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 --- reactos/drivers/wdm/audio/backpln/portcls/irpstream.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c index 8e930441804..1015812bd5c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/irpstream.c @@ -142,7 +142,6 @@ IIrpQueue_fnAddMapping( IN PIRP Irp) { PIRP_MAPPING Mapping; - ULONG Index; IIrpQueueImpl * This = (IIrpQueueImpl*)iface; Mapping = AllocateItem(NonPagedPool, sizeof(IRP_MAPPING), TAG_PORTCLASS); @@ -183,8 +182,7 @@ IIrpQueue_fnAddMapping( return STATUS_UNSUCCESSFUL; } ASSERT(Mapping->NumTags < 32); - for(Index = 0; Index < Mapping->NumTags; Index++); - Mapping->References |= (1 << Index); + Mapping->References = (1 << Mapping->NumTags) - 1; This->NumDataAvailable += Mapping->Header->DataUsed; @@ -392,6 +390,7 @@ IIrpQueue_fnGetMappingWithTag( PIRP_MAPPING CurMapping; PLIST_ENTRY CurEntry; ULONG Index; + ULONG Value; IIrpQueueImpl * This = (IIrpQueueImpl*)iface; *Flags = 0; @@ -413,7 +412,8 @@ IIrpQueue_fnGetMappingWithTag( CurMapping = CONTAINING_RECORD(CurEntry, IRP_MAPPING, Entry); 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 */ GetMapping(This, Index, Tag, CurMapping, PhysicalAddress, VirtualAddress, ByteCount, Flags); @@ -460,6 +460,7 @@ IIrpQueue_fnReleaseMappingWithTag( if (CurMapping->Tag[Index] == Tag) { Found = TRUE; + CurMapping->Tag[Index] = NULL; break; } }