[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-client-cvs
Subject:    [Client-cvs] simplecore hxpktq.cpp, 1.1.1.1.4.2,
From:       ching_li () helixcommunity ! org
Date:       2011-08-12 2:39:37
Message-ID: 201108120240.p7C2e4ZQ001622 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/client/simplecore
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv5953

Modified Files:
      Tag: hxclient_3_6_1_atlas
	hxpktq.cpp hxpktq.h hxplay.cpp hxrender.cpp hxscmsgs.h 
	smplaply.cpp smplaply.h 
Log Message:
Change to fix several issues which are related with SoundPool:
1) Rename 'SoundPoolMode' as 'RealTimeMode' and change related logic;
2) Fix bug 13594: HelixPlayer will crash if the data source is non-extension file \
when try to use simple core; 3) For some ogg clips, the stream packet's time stamp is \
not accurate, it could cause data loss. 4) Fix bug 13596: HelixPlayer could block \
SoundPool when decode some ogg clips. The root cause of the last issue is that helix \
can't finish pre-fetching if the last packet can't be decoded, to fix this issue I \
change the control logic in non-real time mode (for working with SoundPool): 1) \
Ensure all decoded data be cached in PCM queue; 2) Finish pre-fetching if got EOF \
marker (after all decoded data have been pushed into PCM queue); 3) Send \
HXMSG_SCN_STOP to player and stop playback after all cached data were written into \
audio device;



Index: hxscmsgs.h
===================================================================
RCS file: /cvsroot/client/simplecore/hxscmsgs.h,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- hxscmsgs.h	18 Apr 2011 17:21:43 -0000	1.2
+++ hxscmsgs.h	12 Aug 2011 02:39:34 -0000	1.2.4.1
@@ -66,5 +66,6 @@
 #define HXMSG_SCN_CLIENTSTATE          (HXMSG_BASE + 21)
 #define HXMSG_SCN_REPORT               (HXMSG_BASE + 22)
 #define HXMSG_SCN_BUFFERING            (HXMSG_BASE + 23)
+#define HXMSG_SCN_STOP                 (HXMSG_BASE + 24)
 
 #endif //_HXSCMSGS_

Index: hxplay.cpp
===================================================================
RCS file: /cvsroot/client/simplecore/hxplay.cpp,v
retrieving revision 1.9.4.3
retrieving revision 1.9.4.4
diff -u -d -r1.9.4.3 -r1.9.4.4
--- hxplay.cpp	5 Jul 2011 06:13:39 -0000	1.9.4.3
+++ hxplay.cpp	12 Aug 2011 02:39:33 -0000	1.9.4.4
@@ -748,17 +748,14 @@
                 }
             }
             break;
+        case HXMSG_SCN_STOP:
+            StopPlayer();
+            break;
         case HXMSG_SCN_ONTIMESYNC:
             {
                 //if we are in PLAYING state, send OnTimeSync to stream/renderer
                 if (m_eClientState == HX_CLIENT_STATE_PLAYING)
                 {
-                    if ( m_pAudioPlayer->SoundPoolMode() )
-                    {
-                        StopPlayer();
-                        break;
-                    }
-
                     ULONG32 ulTime = (ULONG32)msg->m_pParam1;
                     OnTimeSyncAllStreams(ulTime);
                     
@@ -1064,8 +1061,13 @@
 
 HX_RESULT HXSimplePlayer::StreamDone(UINT32 uStreamIndex, ULONG32 ulLastTS)
 {
-    if (uStreamIndex < m_ulNumStreams && m_pHXStreams[uStreamIndex]->IsAudio() && \
ulLastTS) +    if (ulLastTS && uStreamIndex < m_ulNumStreams &&
+        m_pHXStreams[uStreamIndex]->IsAudio() &&
+        m_pAudioPlayer->RealTimeMode())
     {
+        // For non-realtime mode, we will stop playback when
+        // we get EOS marker, so change the end time only
+        // in realtime mode (to avoid loss data).
         m_pAudioPlayer->SetAudioEndTime(ulLastTS);
     }
 }

Index: smplaply.cpp
===================================================================
RCS file: /cvsroot/client/simplecore/smplaply.cpp,v
retrieving revision 1.8.4.8
retrieving revision 1.8.4.9
diff -u -d -r1.8.4.8 -r1.8.4.9
--- smplaply.cpp	11 Jul 2011 04:43:04 -0000	1.8.4.8
+++ smplaply.cpp	12 Aug 2011 02:39:34 -0000	1.8.4.9
@@ -57,6 +57,7 @@
 #include "hxtlogutil.h"
 #include "hxerror.h"
 #include "hxscmsgs.h"
+#include "hxstrm.h"
 
 #define DFLT_PCM_QUEUE_SIZE_MIN 1000   //1s
 #define DFLT_PCM_QUEUE_SIZE_MAX 10000  //10s
@@ -84,21 +85,16 @@
  ,m_pTimeSyncThread(NULL)
  ,m_pTimeSyncQuitEvent(NULL)
  ,m_ulTimeSyncGranularity(DFLT_ONTIMESYNC_GRANULARITY)
- ,m_bSoundPoolMode(FALSE)
+ ,m_bRealTimeMode(TRUE)
 {
     HX_ADDREF(m_pPlayer);
     
 #if defined(HELIX_FEATURE_PREFERENCES)
     // Get preferences interface and info..
     m_pPlayer->QueryInterface(IID_IHXPreferences, (void **) &m_pPreferences);
-    ReadPrefBOOL(m_pPreferences, "SoundPoolMode", m_bSoundPoolMode);
+    ReadPrefBOOL(m_pPreferences, "RealTimeMode", m_bRealTimeMode);
 #endif /* HELIX_FEATURE_PREFERENCES */
 
-    if (m_bSoundPoolMode)
-    {
-        m_ulTimeSyncGranularity = 10;
-    }
-
     // Create the PCM queue
     m_pPCMQueue = new HXLimitedPacketQueue(m_pPlayer, DFLT_PCM_QUEUE_SIZE_MIN, \
DFLT_PCM_QUEUE_SIZE_MAX);  
@@ -471,13 +467,24 @@
 
 void CSimpleAudioPlayer::SetAudioEndTime(ULONG32 ulEndTime)
 {
-  if ( ulEndTime && ulEndTime < m_pPCMQueue->GetMinQueueSizeMS() )
+  if (ulEndTime)
   {
-      m_pPCMQueue->SetMinQueueSizeMS(ulEndTime);
-      
-      if ( HX_CLIENT_STATE_PREFETCHING == m_pPlayer->GetState() )
+      HXBOOL bPCMQueueChanged = FALSE;
+      // For non-real time mode, we must cache all data in PCM queue.
+      if ( !m_bRealTimeMode || ulEndTime < m_pPCMQueue->GetMinQueueSizeMS() )
       {
-          // Since the min duration of the PCM queue has been changed, 
+          m_pPCMQueue->SetMinQueueSizeMS(ulEndTime);
+          bPCMQueueChanged = TRUE;
+      }
+      if ( !m_bRealTimeMode && ulEndTime > m_pPCMQueue->GetMaxQueueSizeMS() )
+      {
+          m_pPCMQueue->SetMaxQueueSizeMS(ulEndTime);
+          bPCMQueueChanged = TRUE;
+      }
+
+      if ( bPCMQueueChanged && HX_CLIENT_STATE_PREFETCHING == m_pPlayer->GetState() \
) +      {
+          // Since the PCM queue has been changed, 
           // report the completion rate again.
           m_pPlayer->PostMessage( HXMSG_SCN_BUFFERING, STREAMNO_PCM,
                           (void *)m_pPCMQueue->BufferingPercent() );
@@ -789,24 +796,17 @@
         {
             ret = m_pPCMQueue->Dequeue(pPacket, TRUE);
         }
-        if (ret == HXR_OK)
+        if (pPacket)
         {
              //timestamp of first packet after start or seek may not to be at \
m_ulTimeBase  //set BaseTime to ts of 1st packet
              if (bFirstPacket)
              {
                  bFirstPacket = FALSE;
-                 if(pPacket)
-                     m_ulBaseTime = pPacket->GetTime();
+                 m_ulBaseTime = pPacket->GetTime();
              }
              
              //TODO: handle timed audio; adjust for gap/overlap of audio packets
-
-             if(pPacket == NULL)
-             {
-                 writeRet = HXR_OK; 
-                 continue;
-             }
              HXAudioData audioData;
              audioData.pData = pPacket->GetBuffer();
              audioData.ulAudioTime = pPacket->GetTime();
@@ -818,6 +818,14 @@
 
              HX_RELEASE(audioData.pData);
              HX_RELEASE(pPacket);
+             if ( !m_bRealTimeMode && m_pPCMQueue->IsEmpty() )
+             {
+                 // For non-real time mode, we must stop playback when
+                 // goto the end, and because we cache all data in the
+                 // PCM queue, so we can send HXMSG_SCN_STOP when PCM
+                 // queue is empty.
+                 m_pPlayer->PostMessage(HXMSG_SCN_STOP, NULL, NULL);
+             }
         }
     }
    return NULL;

Index: smplaply.h
===================================================================
RCS file: /cvsroot/client/simplecore/smplaply.h,v
retrieving revision 1.3.4.2
retrieving revision 1.3.4.3
diff -u -d -r1.3.4.2 -r1.3.4.3
--- smplaply.h	5 Jul 2011 06:13:40 -0000	1.3.4.2
+++ smplaply.h	12 Aug 2011 02:39:34 -0000	1.3.4.3
@@ -117,7 +117,7 @@
 
     ULONG32   GetCurrentPlayBackTime(void);
     ULONG32   GetLastEnqueuedPacketTS() {return m_ulLastEnqueuedPacketTS;}
-    HXBOOL    SoundPoolMode() const {return m_bSoundPoolMode;}
+    HXBOOL    RealTimeMode() const {return m_bRealTimeMode;}
     
     //set when audio data will end; after EndTime, we'll provide clock-based \
OnTimeSync  //EndTime == 0 means that we'll provide a clock-based fake timeline
@@ -155,7 +155,7 @@
     void*        PCMThreadRoutine(void);
     HX_RESULT    CreateAudioDevice(void);
     
-    HXBOOL    m_bSoundPoolMode;
+    HXBOOL    m_bRealTimeMode;
 	
     //the pumping loop
     HX_RESULT Start(void);

Index: hxpktq.cpp
===================================================================
RCS file: /cvsroot/client/simplecore/hxpktq.cpp,v
retrieving revision 1.1.1.1.4.2
retrieving revision 1.1.1.1.4.3
diff -u -d -r1.1.1.1.4.2 -r1.1.1.1.4.3
--- hxpktq.cpp	5 Jul 2011 08:24:45 -0000	1.1.1.1.4.2
+++ hxpktq.cpp	12 Aug 2011 02:39:33 -0000	1.1.1.1.4.3
@@ -249,7 +249,12 @@
     return HXR_OK;
 }
 
-ULONG32 HXPacketQueue::GetSize(void)
+HXBOOL HXPacketQueue::IsEmpty() const
+{
+    return m_pPacketList->IsEmpty();
+}
+
+ULONG32 HXPacketQueue::GetSize(void) const
 {
     //size is based on timestamp difference
     

Index: hxpktq.h
===================================================================
RCS file: /cvsroot/client/simplecore/hxpktq.h,v
retrieving revision 1.1.1.1.4.2
retrieving revision 1.1.1.1.4.3
diff -u -d -r1.1.1.1.4.2 -r1.1.1.1.4.3
--- hxpktq.h	5 Jul 2011 06:13:39 -0000	1.1.1.1.4.2
+++ hxpktq.h	12 Aug 2011 02:39:33 -0000	1.1.1.1.4.3
@@ -71,9 +71,12 @@
         virtual HXBOOL IsLow(void) { return FALSE; }
         virtual UINT32 GetMinQueueSizeMS() const {return 1000;}
         virtual void   SetMinQueueSizeMS(UINT32 nValue) {}
+        virtual UINT32 GetMaxQueueSizeMS() const {return 10000;}
+        virtual void   SetMaxQueueSizeMS(UINT32 nValue) {}
         virtual UINT32 BufferingPercent(void) { return 100; }
         
-        ULONG32 GetSize(void);
+        HXBOOL  IsEmpty() const;
+        ULONG32 GetSize(void) const;
 
         //remove all data in the queue
         virtual HX_RESULT Clear(void);
@@ -114,7 +117,21 @@
       virtual HXBOOL IsFull(void);
       virtual HXBOOL IsLow(void);
       virtual UINT32 GetMinQueueSizeMS() const {return m_ulMsLow;}
-      virtual void   SetMinQueueSizeMS(UINT32 nValue) {m_ulMsLow = nValue;}
+      virtual void   SetMinQueueSizeMS(UINT32 nValue)
+      {
+          if (nValue <= m_ulMsHigh)
+          {
+              m_ulMsLow = nValue;
+          }
+      }
+      virtual UINT32 GetMaxQueueSizeMS() const {return m_ulMsHigh;}
+      virtual void   SetMaxQueueSizeMS(UINT32 nValue)
+      {
+          if (nValue >= m_ulMsLow)
+          {
+              m_ulMsHigh = nValue;
+          }
+      }
       virtual UINT32 BufferingPercent(void);
 
 protected:

Index: hxrender.cpp
===================================================================
RCS file: /cvsroot/client/simplecore/hxrender.cpp,v
retrieving revision 1.2.4.2
retrieving revision 1.2.4.3
diff -u -d -r1.2.4.2 -r1.2.4.3
--- hxrender.cpp	5 Jul 2011 06:13:39 -0000	1.2.4.2
+++ hxrender.cpp	12 Aug 2011 02:39:34 -0000	1.2.4.3
@@ -332,6 +332,14 @@
                     HX_RELEASE(pDryNotification);
 
                     ret = m_pRenderer->OnEndofPackets();
+
+                    if ( HX_CLIENT_STATE_PREFETCHING == m_pPlayer->GetState() )
+                    {
+                        // Since we got the EndofPackets marker,
+                        // we should finish prefetching to avoid
+                        // blocking.
+                        m_pPlayer->PostMessage( HXMSG_SCN_BUFFERING, STREAMNO_PCM, \
(void *)100 ); +                    }
                 }
                 else
                 {            


_______________________________________________
Client-cvs mailing list
Client-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/client-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic