OSDN Git Service

fix audio and seek operation.
authorNoumi Akira <noumiakira@users.sourceforge.jp>
Thu, 11 Jun 2009 06:17:03 +0000 (15:17 +0900)
committerNoumi Akira <noumiakira@users.sourceforge.jp>
Thu, 11 Jun 2009 06:17:03 +0000 (15:17 +0900)
Lib/QDecoder/QDecoder.vcproj
Lib/QDecoder/QFilter.h
Lib/QDecoder/QPinAudio.h
Lib/QDecoder/QReader.h
Lib/QDecoder/QStreamer.h
Lib/QDecoder/QWaveOutputer.h

index 376d594..343b6ab 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\QStreamer.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\QWaveOutputer.h"
                                >
                        </File>
index 54ef753..bd4654f 100644 (file)
@@ -64,7 +64,7 @@ public:
 
        QFilter() : m_pStreamer(0), m_pFGraph(0), m_pPinVideo(0),
                m_state(State_Stopped),
-               m_StartPos(0)
+               m_StartPos(-1)
        {
                memset(m_Pins, 0, sizeof(m_Pins));
        }
@@ -582,6 +582,7 @@ public:
                        INT64 pos = *pCurrent;
 
                        if (m_pStreamer != 0) {
+                               m_pStreamer->BeginFlush();
                                m_pStreamer->RequestSeek(pos);
                                m_pStreamer->RequestStart();
 
@@ -681,9 +682,9 @@ private:
                                return hRslt;
                        }
 
-                       if (m_StartPos != 0) {
+                       if (m_StartPos != -1) {
                                m_pStreamer->RequestSeek(m_StartPos);
-                               m_StartPos = 0;
+                               m_StartPos = -1;
                        }
                }
 
index a135cc4..026554f 100644 (file)
@@ -92,7 +92,7 @@ public:
                ALLOCATOR_PROPERTIES aprop = { 0 };
 
                rprop.cBuffers = 20;
-               rprop.cbBuffer = 2 * m_WaveHeader.nChannels * m_WaveHeader.nSamplesPerSec / 20;
+               rprop.cbBuffer = 2 * m_WaveHeader.nChannels * m_WaveHeader.nSamplesPerSec / 10;
                rprop.cbAlign  = 1;
                rprop.cbPrefix = 0;
 
index 0d44729..9b1a580 100644 (file)
@@ -106,9 +106,16 @@ public:
        bool Setup()
        {
                INT64 scale = QM_GetTimeCodeScale(m_reader);
+#if 0
                if (scale != 1000*1000) {
                        return false;
                }
+#else
+               // matroska ts -> RT : 1ns -> 100ns
+               m_scale  = (INT32)(scale / 100);
+               // 1s / matroska ts
+               m_ascale = (INT32)(1000*1000*1000 / scale);
+#endif
 
                DOUBLE d = QM_GetDuraion(m_reader);
                m_duration = (INT64)(d * m_scale);
index 69326fc..07823db 100644 (file)
@@ -149,6 +149,10 @@ public:
                IMemAllocator*          alloc,
                const VIDEOINFOHEADER2* v)
        {
+               if (pin == 0) {
+                       return S_OK;
+               }
+
                ATL::CComQIPtr<IPin> vp(pin);
                if (vp == 0) {
                        return E_NOINTERFACE;
@@ -174,6 +178,10 @@ public:
                IMemAllocator*      alloc,
                const WAVEFORMATEX* w)
        {
+               if (pin == 0) {
+                       return S_OK;
+               }
+
                ATL::CComQIPtr<IPin> vp(pin);
                if (vp == 0) {
                        return E_NOINTERFACE;
@@ -232,6 +240,21 @@ public:
 
        /* */
 
+       HRESULT BeginFlush()
+       {
+               if (m_VideoPin != 0) {
+                       m_VideoPin->BeginFlush();
+               }
+
+               if (m_AudioPin != 0) {
+                       m_AudioPin->BeginFlush();
+               }
+
+               return S_OK;
+       }
+
+       /* */
+
        void RequestSeek(INT64 pos)
        {
                ATL::CComCritSecLock<ATL::CComCriticalSection> lock(m_cs);
@@ -381,14 +404,6 @@ private:
 
                                                m_Outputer.Flush();
 
-                                               if (m_VideoPin != 0) {
-                                                       m_VideoPin->BeginFlush();
-                                               }
-
-                                               if (m_AudioPin != 0) {
-                                                       m_AudioPin->BeginFlush();
-                                               }
-
                                                if (!m_pReader->Seek(m_SeekPos)) {
                                                        ATLTRACE("QStreamer::DoStreaming() Seek ERROR!\n");
                                                        break;
index aa0de71..80a9a9b 100644 (file)
@@ -140,6 +140,8 @@ private:
                if (m_sample != 0) {
                        m_sample->SetActualDataLength(m_cbFilled);
 
+                       //ATLTRACE("AS: %d\n", m_cbFilled);
+
                        HRESULT hRslt = pin->Receive(m_sample);
                        if (FAILED(hRslt)) {
                                return false;
@@ -184,6 +186,9 @@ private:
                        m_sample->SetDiscontinuity(TRUE);
                }
 
+               // INT32 ss = (INT32)(rt / (1000*100));
+               // ATLTRACE("A: %d.%02d\n", ss / 100, ss % 100);
+
                return true;
        }