+ // get stream data
+ StreamData = (PKSSTREAM_DATA)Irp->Tail.Overlay.DriverContext[STREAM_DATA_OFFSET];
+
+ // sanity check
+ PC_ASSERT(StreamData->StreamHeaderIndex + 1 == StreamData->StreamHeaderCount);
+
+ // check if the released mapping is one of these
+ for(Index = 0; Index < StreamData->StreamHeaderCount; Index++)
+ {
+ if (StreamData->Tags[Index] == Tag)
+ {
+ // mark mapping as released
+ StreamData->Tags[Index] = NULL;
+
+ // done
+ break;
+ }
+ else
+ {
+ //
+ // we assume that mappings are released in the same order as they have been acquired
+ // therefore if the current mapping is not the searched one, it must have been already
+ // released
+ //
+ PC_ASSERT(StreamData->Tags[Index] == NULL);
+ }
+ }
+
+ // check if this is the last one released mapping
+ if (Index + 1 == StreamData->StreamHeaderCount)
+ {
+ // last mapping released
+ // now check if this is a looped buffer
+ if (m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
+ {
+ // looped buffers are not completed when they have been played
+ // they are completed when the stream is set to stop
+
+ // reset stream header index
+ StreamData->StreamHeaderIndex = 0;
+
+ // reset stream header
+ StreamData->CurStreamHeader = (PKSSTREAM_HEADER)Irp->AssociatedIrp.SystemBuffer;