dvdplayer: move pts output queue into DVDAudio
authorJoakim Plate <elupus@ecce.se>
Wed, 26 Sep 2012 19:35:05 +0000 (21:35 +0200)
committerxbmc <fernetmenta@online.de>
Sat, 6 Oct 2012 17:18:24 +0000 (19:18 +0200)
xbmc/cores/dvdplayer/DVDAudio.cpp
xbmc/cores/dvdplayer/DVDAudio.h
xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
xbmc/cores/dvdplayer/DVDPlayerAudio.h

index 93f0739..2cbcc84 100644 (file)
 
 using namespace std;
 
+
+CPTSOutputQueue::CPTSOutputQueue()
+{
+  Flush();
+}
+
+void CPTSOutputQueue::Add(double pts, double delay, double duration)
+{
+  CSingleLock lock(m_sync);
+
+  TPTSItem item;
+  item.pts = pts;
+  item.timestamp = CDVDClock::GetAbsoluteClock() + delay;
+  item.duration = duration;
+
+  // first one is applied directly
+  if(m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE)
+    m_current = item;
+  else
+    m_queue.push(item);
+
+  // call function to make sure the queue
+  // doesn't grow should nobody call it
+  Current();
+}
+void CPTSOutputQueue::Flush()
+{
+  CSingleLock lock(m_sync);
+
+  while( !m_queue.empty() ) m_queue.pop();
+  m_current.pts = DVD_NOPTS_VALUE;
+  m_current.timestamp = 0.0;
+  m_current.duration = 0.0;
+}
+
+double CPTSOutputQueue::Current()
+{
+  CSingleLock lock(m_sync);
+
+  if(!m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE)
+  {
+    m_current = m_queue.front();
+    m_queue.pop();
+  }
+
+  while( !m_queue.empty() && CDVDClock::GetAbsoluteClock() >= m_queue.front().timestamp )
+  {
+    m_current = m_queue.front();
+    m_queue.pop();
+  }
+
+  if( m_current.timestamp == 0 ) return m_current.pts;
+
+  return m_current.pts + min(m_current.duration, (CDVDClock::GetAbsoluteClock() - m_current.timestamp));
+}
+
+
 CDVDAudio::CDVDAudio(volatile bool &bStop)
   : m_bStop(bStop)
 {
index 2a3c58f..662dc26 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 #include "threads/CriticalSection.h"
 #include "PlatformDefs.h"
+#include <queue>
 
 #include "cores/AudioEngine/Utils/AEChannelInfo.h"
 class IAEStream;
@@ -46,6 +47,22 @@ extern "C" {
 #endif
 typedef struct stDVDAudioFrame DVDAudioFrame;
 
+
+class CPTSOutputQueue
+{
+private:
+  typedef struct {double pts; double timestamp; double duration;} TPTSItem;
+  TPTSItem m_current;
+  std::queue<TPTSItem> m_queue;
+  CCriticalSection m_sync;
+
+public:
+  CPTSOutputQueue();
+  void Add(double pts, double delay, double duration);
+  void Flush();
+  double Current();
+};
+
 class CSingleLock;
 class IAudioCallback;
 
index cb4bdab..251ffcd 100644 (file)
 
 using namespace std;
 
-CPTSOutputQueue::CPTSOutputQueue()
-{
-  Flush();
-}
-
-void CPTSOutputQueue::Add(double pts, double delay, double duration)
-{
-  CSingleLock lock(m_sync);
-
-  TPTSItem item;
-  item.pts = pts;
-  item.timestamp = CDVDClock::GetAbsoluteClock() + delay;
-  item.duration = duration;
-
-  // first one is applied directly
-  if(m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE)
-    m_current = item;
-  else
-    m_queue.push(item);
-
-  // call function to make sure the queue
-  // doesn't grow should nobody call it
-  Current();
-}
-void CPTSOutputQueue::Flush()
-{
-  CSingleLock lock(m_sync);
-
-  while( !m_queue.empty() ) m_queue.pop();
-  m_current.pts = DVD_NOPTS_VALUE;
-  m_current.timestamp = 0.0;
-  m_current.duration = 0.0;
-}
-
-double CPTSOutputQueue::Current()
-{
-  CSingleLock lock(m_sync);
-
-  if(!m_queue.empty() && m_current.pts == DVD_NOPTS_VALUE)
-  {
-    m_current = m_queue.front();
-    m_queue.pop();
-  }
-
-  while( !m_queue.empty() && CDVDClock::GetAbsoluteClock() >= m_queue.front().timestamp )
-  {
-    m_current = m_queue.front();
-    m_queue.pop();
-  }
-
-  if( m_current.timestamp == 0 ) return m_current.pts;
-
-  return m_current.pts + min(m_current.duration, (CDVDClock::GetAbsoluteClock() - m_current.timestamp));
-}
-
 void CPTSInputQueue::Add(int64_t bytes, double pts)
 {
   CSingleLock lock(m_sync);
index 0523bd4..5537fb7 100644 (file)
@@ -63,21 +63,6 @@ typedef struct stDVDAudioFrame
   bool              passthrough;
 } DVDAudioFrame;
 
-class CPTSOutputQueue
-{
-private:
-  typedef struct {double pts; double timestamp; double duration;} TPTSItem;
-  TPTSItem m_current;
-  std::queue<TPTSItem> m_queue;
-  CCriticalSection m_sync;
-
-public:
-  CPTSOutputQueue();
-  void Add(double pts, double delay, double duration);
-  void Flush();
-  double Current();
-};
-
 class CPTSInputQueue
 {
 private: