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)
{
#endif
#include "threads/CriticalSection.h"
#include "PlatformDefs.h"
+#include <queue>
#include "cores/AudioEngine/Utils/AEChannelInfo.h"
class IAEStream;
#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;
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);
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: