- Fix retrieving audio position
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 31 Oct 2009 10:38:25 +0000 (10:38 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 31 Oct 2009 10:38:25 +0000 (10:38 +0000)
svn path=/trunk/; revision=43869

reactos/drivers/wdm/audio/backpln/portcls/interfaces.hpp
reactos/drivers/wdm/audio/backpln/portcls/irpstream.cpp
reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp

index 031a00f..bf9057b 100644 (file)
@@ -354,7 +354,7 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown)
         IN PVOID Tag) PURE;
 
     STDMETHOD_(BOOL, HasLastMappingFailed)(THIS) PURE;
-    STDMETHOD_(VOID, PrintQueueStatus)(THIS) PURE;
+    STDMETHOD_(ULONG, GetCurrentIrpOffset)(THIS) PURE;
     STDMETHOD_(VOID, SetMinimumDataThreshold)(THIS_
         IN ULONG MinimumDataThreshold) PURE;
     STDMETHOD_(ULONG, GetMinimumDataThreshold)(THIS) PURE;
@@ -403,7 +403,7 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown)
         IN PVOID Tag);                                 \
                                                        \
     STDMETHODIMP_(BOOL) HasLastMappingFailed(THIS);    \
-    STDMETHODIMP_(VOID) PrintQueueStatus(THIS);        \
+    STDMETHODIMP_(ULONG) GetCurrentIrpOffset(THIS);    \
     STDMETHODIMP_(VOID) SetMinimumDataThreshold(       \
         IN ULONG MinimumDataThreshold);                \
     STDMETHODIMP_(ULONG) GetMinimumDataThreshold(VOID)
index 3759585..e699964 100644 (file)
@@ -35,7 +35,7 @@ public:
     virtual ~CIrpQueue(){}
 
 protected:
-    ULONG m_CurrentOffset;
+    volatile ULONG m_CurrentOffset;
     LONG m_NumMappings;
     ULONG m_NumDataAvailable;
     BOOL m_StartStream;
@@ -312,7 +312,7 @@ CIrpQueue::UpdateMapping(
    // ASSERT(StreamHeader);
 
     // add to current offset
-    m_CurrentOffset += BytesWritten;
+    InterlockedExchangeAdd((volatile PLONG)&m_CurrentOffset, (LONG)BytesWritten);
 
     // decrement available data counter
     m_NumDataAvailable -= BytesWritten;
@@ -559,11 +559,12 @@ CIrpQueue::HasLastMappingFailed()
     return m_OutOfMapping;
 }
 
-VOID
+ULONG
 NTAPI
-CIrpQueue::PrintQueueStatus()
+CIrpQueue::GetCurrentIrpOffset()
 {
 
+    return m_CurrentOffset;
 }
 
 VOID
index 759b261..e4b4aaf 100644 (file)
@@ -218,7 +218,8 @@ PinWaveCyclicAudioPosition(
         else if (Pin->m_ConnectDetails->Interface.Id == KSINTERFACE_STANDARD_LOOPED_STREAMING)
         {
             Position->PlayOffset = Pin->m_Position.PlayOffset % Pin->m_Position.WriteOffset;
-            Position->WriteOffset = Pin->m_IrpQueue->NumData();
+            Position->WriteOffset = (ULONGLONG)Pin->m_IrpQueue->GetCurrentIrpOffset();
+            DPRINT("Play %lu Write %lu\n", Position->PlayOffset, Position->WriteOffset);
         }
 
 
@@ -606,10 +607,7 @@ CPortPinWaveCyclic::HandleKsStream(
 
     if (NT_SUCCESS(Status))
     {
-        if (m_Capture)
-            m_Position.WriteOffset += Data;
-        else
-            m_Position.WriteOffset += Data;
+        m_Position.WriteOffset += Data;
 
         return STATUS_PENDING;
     }