"Nokia submits this code under the terms of a commercial contribution
agreement with RealNetworks, and I am authorized to contribute this code
under said agreement."

        Modified by:  [EMAIL PROTECTED]

        Reviewed by: 

        Date: 09-Apr-2007

        Project: SymbianMmf

        ErrorId:  106-1545 - Audio Effects support for Helix Engine
                    
        Synopsis:  CR: Enabling Audio Effects II
          When the change was introduced the usage of DevSound from MMF
Controller was not enabled because of an error in the symbian. There was
a timing issue with the new changes which was resulting in crash. The
crash was happening when the DevSound was reinitialized with new
observer when ever replayed or stopped. With the new proposed change the
Observer initialized with devsound always remains the same. The
CHXMMFDevSound delegates the callbacks to the actual callback handler if
registered.

        This completes the feature for ARM Audio effects. Need to have
similar changes on DSP side to use the CHXMMFDevSound.

          
        Root Cause of the problem: New Feature

         
        Files Modified:
        Platform/symbian/common/CHXMMFDevSound.cpp
        Platform/symbian/common/CHXBaseAudioSession.cpp
        pub/platform/symbian/CHXBaseAudioSession.h
        pub/platform/symbian/CHXMMFDevSound.h
        common/hxmmfbasectrl.cpp

        Image Size and Heap Use impact: minor impact

        Module Release testing (STIF) :  STIF passed for both audio
session configurations (Standalone & Server-Client)

        Test case(s) Added  :  No. Existing test cases covers most of
the changes. Effects changes needs to be tested with application.

        Memory leak check performed : Yes.  No new leaks introduced.  

        Platforms and Profiles Build Verified:
helix-client-s60-32-mmf-mdf-arm

        Platforms and Profiles Functionality verified: armv5, winscw 

      Branch: Head & 210CayS
 <<cvs_diff_1.txt>> 


Index: platform/symbian/common/CHXBaseAudioSession.cpp
===================================================================
RCS file: 
/cvsroot/audio/device/platform/symbian/common/CHXBaseAudioSession.cpp,v
retrieving revision 1.1
diff -w -u -b -r1.1 CHXBaseAudioSession.cpp
--- platform/symbian/common/CHXBaseAudioSession.cpp     3 Apr 2007 18:20:08 
-0000       1.1
+++ platform/symbian/common/CHXBaseAudioSession.cpp     13 Apr 2007 22:56:50 
-0000
@@ -265,40 +265,31 @@
     Trans(CLOSED);
 }
 
-CHXMMFDevSound* CHXBaseAudioSession::GetHxDevSound()
-{
-    CHXMMFDevSound* pRet = NULL;
-    CHXMMFDevSound** pInstance = NULL;
-    HXGlobalManager* pGM = HXGlobalManager::Instance();
-    
-    if(pGM != NULL)
-    {
-        pInstance = reinterpret_cast<CHXMMFDevSound**>(pGM->Get((const 
*)SYMBIAN_GLOBAL_AUDIO_DEVSOUND_ID));
-        if(pInstance != NULL)
-        {
-            pRet = *pInstance;
-        }
-    }
-    
-    HXLOGL3(HXLOG_ADEV, "CHXBaseAudioSession::GetHxDevSound(): DevSound:%x", 
pRet);
-    return pRet;
-
-}
-
 TInt CHXBaseAudioSession::CreateDevSound()
 {
     TInt lRetval = KErrNone;
     CHXMMFDevSound* pHxDevSound = NULL;
     
-    pHxDevSound = GetHxDevSound();
+    // check for the existence of global devsound
+    pHxDevSound = CHXMMFDevSound::Get();
     if (pHxDevSound == NULL)
     {
         TRAP(lRetval, (m_pStream = CMMFDevSound::NewL()));
+        if(lRetval == KErrNone)
+        {
+            TRAP(lRetval, (m_pStream->InitializeL(*this, EMMFStatePlaying)));
+        }
     }
     else
     {
-        m_pStream = pHxDevSound->DevSound();
         m_bDevSoundOwned = FALSE;
+        m_pStream = pHxDevSound->DevSound();
+        // Assumption is that the initilization is already completed
+        // CHXMMFDevSound is initialized already during creation
+        // So we just need to set observer and call overselves initialized
+        pHxDevSound->RegisterObserver(this);
+        InitializeComplete(KErrNone);
+        lRetval = m_lastPlayError;
     }
     
     HXLOGL2(HXLOG_ADEV, "CHXBaseAudioSession::CreateDevSound(): DevSound:%x 
Owned:%d",
@@ -356,11 +347,6 @@
             Trans(OPEN_PENDING);
             HX_ASSERT(!m_pStream);
             lRetval = CreateDevSound();
-            if(KErrNone == lRetval)
-            {
-                HXLOGL3(HXLOG_ADEV, "CHXBaseAudioSession::Init(): calling 
InitializeL for newly allocated dev sound");
-                TRAP(lRetval, (m_pStream->InitializeL(*this, 
EMMFStatePlaying)));
-            }
             if( KErrNone != lRetval )
             {
                 Trans(CLOSED);
@@ -814,12 +800,14 @@
     }
     else
     {
-        CHXMMFDevSound* pHxDevSound = GetHxDevSound();
+        CHXMMFDevSound* pHxDevSound = CHXMMFDevSound::Get();
         
         HXLOGL2(HXLOG_ADEV, "CHXBaseAudioSession::InitClosedState() Resetting 
Global DevSound :%x", pHxDevSound);
         HX_ASSERT(pHxDevSound);
 
-        pHxDevSound->Reset();
+        // CHXMMFDevvsound is not owned by AudioSession. So it needs to 
+        // remove itself from observing callbacks
+        pHxDevSound->UnRegisterObserver();
         m_pStream = NULL;
         m_bDevSoundOwned = TRUE;
     }
Index: platform/symbian/common/CHXMMFDevSound.cpp
===================================================================
RCS file: /cvsroot/audio/device/platform/symbian/common/CHXMMFDevSound.cpp,v
retrieving revision 1.1
diff -w -u -b -r1.1 CHXMMFDevSound.cpp
--- platform/symbian/common/CHXMMFDevSound.cpp  3 Apr 2007 18:20:08 -0000       
1.1
+++ platform/symbian/common/CHXMMFDevSound.cpp  13 Apr 2007 22:56:50 -0000
@@ -64,6 +64,9 @@
 #include "debug.h"
 #include "hxtlogutil.h"
 #include "CHXMMFDevSound.h"
+#include "hxglobalmgr.h"
+#include "hxassert.h"
+#include "symbian_gm_inst.h"
 
 //
 //  Constructor
@@ -72,6 +75,7 @@
 : m_pStream(NULL)
 , m_pActiveSchedulerWait(NULL)
 , m_bDevInitCompleted(FALSE)   
+, m_pDevSoundObserver(NULL)    
 {
 
 }
@@ -105,6 +109,28 @@
 }
 
 //
+//  CHXMMFDevSound::Get()
+//  Fetches HXMMFDevSound from global manager
+//
+CHXMMFDevSound* CHXMMFDevSound::Get()
+{
+    CHXMMFDevSound* pRet = NULL;
+    CHXMMFDevSound** pInstance = NULL;
+    HXGlobalManager* pGM = HXGlobalManager::Instance();
+    
+    if(pGM != NULL)
+    {
+        pInstance = reinterpret_cast<CHXMMFDevSound**>(pGM->Get((const 
*)SYMBIAN_GLOBAL_AUDIO_DEVSOUND_ID));
+        if(pInstance != NULL)
+        {
+            pRet = *pInstance;
+        }
+    }
+    
+    HXLOGL3(HXLOG_ADEV, "CHXMMFDevSound::Get(): DevSound:%x", pRet);
+    return pRet;
+}
+
 //  CHXMMFDevSound::Destroy()
 //  Static function to delete CHXMMFDevSound object
 //  
@@ -131,6 +157,11 @@
         HX_DELETE(m_pStream);
         lRetval = KErrNoMemory;
     }
+    else
+    {
+        lRetval = Initialize();
+    }
+
     return lRetval;
 }
 
@@ -146,12 +177,14 @@
 
 //
 //  CHXMMFDevSound::Reset()
-//  re-Initializes with a new observer(dummy observer)
+//  re-Initializes with a default observer
 //
-void CHXMMFDevSound::Reset()
+TInt CHXMMFDevSound::Initialize()
 {
-    TInt lRetval = KErrNone;
+    TInt lRetval = KErrNotReady;
+
     HXLOGL2(HXLOG_ADEV, "CHXMMFDevSound::Reset()");
+
     if( (m_pStream != NULL) &&
         (m_pActiveSchedulerWait != NULL) )
     {
@@ -164,6 +197,32 @@
             m_pActiveSchedulerWait->Start();
         }
     }
+
+    return lRetval;
+}
+
+//
+//  CHXMMFDevSound::RegisterObserver()
+//  Updates the CHXMMFDevSound's observer
+//
+TInt CHXMMFDevSound::RegisterObserver(MDevSoundObserver *pObserver)
+{
+    m_pDevSoundObserver = pObserver;
+    return KErrNone;
+}
+
+//
+//  CHXMMFDevSound::ReInitialize()
+//  Updates the CHXMMFDevSound's observer
+//  and initializes with the new fourcc
+//
+TInt CHXMMFDevSound::ReInitialize(MDevSoundObserver *pObserver, TFourCC fourcc)
+{
+    TInt lRetval = KErrNone;
+    m_pDevSoundObserver = pObserver;
+    HX_ASSERT(m_pStream);
+    TRAP(lRetval, (m_pStream->InitializeL(*this, fourcc, EMMFStatePlaying)));
+    return lRetval;
 }
 
 //
@@ -182,4 +241,40 @@
     {
         m_pActiveSchedulerWait->AsyncStop();
     }
+    else
+    {
+        if(m_pDevSoundObserver != NULL)
+        {
+            m_pDevSoundObserver->InitializeComplete(aError);
+        }
+    }
+}
+
+//
+//  CHXMMFDevSound::BufferToBeFilled
+//  Passes on the call to the observer
+//
+void CHXMMFDevSound::BufferToBeFilled(CMMFBuffer* aBuffer)
+{
+    if(m_pDevSoundObserver != NULL)
+    {
+        m_pDevSoundObserver->BufferToBeFilled(aBuffer);
+    }
+    else
+    {
+        HXLOGL1(HXLOG_ADEV, "CHXMMFDevSound::BufferToBeFilled(): ERROR ");
+    }
+}
+
+//
+//  CHXMMFDevSound::PlayError
+//  Passes on the call to the observer
+//
+void CHXMMFDevSound::PlayError(TInt aError)
+{
+    HXLOGL1(HXLOG_ADEV, "CHXMMFDevSound::PlayError() Err:%d Obs:%x", aError, 
m_pDevSoundObserver);
+    if(m_pDevSoundObserver != NULL)
+    {
+        m_pDevSoundObserver->PlayError(aError);
+    }
 }
Index: pub/platform/symbian/CHXBaseAudioSession.h
===================================================================
RCS file: /cvsroot/audio/device/pub/platform/symbian/CHXBaseAudioSession.h,v
retrieving revision 1.1
diff -w -u -b -r1.1 CHXBaseAudioSession.h
--- pub/platform/symbian/CHXBaseAudioSession.h  3 Apr 2007 18:21:57 -0000       
1.1
+++ pub/platform/symbian/CHXBaseAudioSession.h  13 Apr 2007 22:56:50 -0000
@@ -140,7 +140,6 @@
     
     // helpers
     TInt CreateDevSound();
-    CHXMMFDevSound* GetHxDevSound();
     void DoPlayInit(HXBOOL setPriority = TRUE);
     void PrepareForDeviceReset();
     void FreePendingBuffers();
Index: pub/platform/symbian/CHXMMFDevSound.h
===================================================================
RCS file: /cvsroot/audio/device/pub/platform/symbian/CHXMMFDevSound.h,v
retrieving revision 1.1
diff -w -u -b -r1.1 CHXMMFDevSound.h
--- pub/platform/symbian/CHXMMFDevSound.h       3 Apr 2007 18:21:57 -0000       
1.1
+++ pub/platform/symbian/CHXMMFDevSound.h       13 Apr 2007 22:56:50 -0000
@@ -80,16 +80,25 @@
 public:
     static CHXMMFDevSound* Create();
     static void Destroy(void *pDevSound);
+    static CHXMMFDevSound* Get();
 
     inline CMMFDevSound* DevSound() {return m_pStream;}
 
-    void Reset();
+    // Sets the new observer
+    TInt RegisterObserver(MDevSoundObserver *pObserver);
+    inline void UnRegisterObserver() {RegisterObserver(NULL);}
+    // Sets the new observer and re-intializes the 
+    // devsound with the specified fourcc
+    TInt ReInitialize(MDevSoundObserver *pObserver, TFourCC fourcc);
+    TInt Initialize();
     void Close();
 
     ~CHXMMFDevSound();
 
     //MDevSoundObserver callbacks
     void InitializeComplete(TInt aError);
+    void BufferToBeFilled(CMMFBuffer* aBuffer);
+    void PlayError(TInt aError);
 
 private:
     CHXMMFDevSound();
@@ -99,6 +108,7 @@
     CMMFDevSound*           m_pStream;
     CActiveSchedulerWait*   m_pActiveSchedulerWait;
     HXBOOL                  m_bDevInitCompleted;
+    MDevSoundObserver*      m_pDevSoundObserver;
     
 };
 
Index: common/hxmmfbasectrl.cpp
===================================================================
RCS file: /cvsroot/clientapps/symbianMmf/common/hxmmfbasectrl.cpp,v
retrieving revision 1.1.2.15
diff -w -u -b -r1.1.2.15 hxmmfbasectrl.cpp
--- common/hxmmfbasectrl.cpp    3 Apr 2007 18:41:56 -0000       1.1.2.15
+++ common/hxmmfbasectrl.cpp    13 Apr 2007 22:57:37 -0000
@@ -572,11 +572,8 @@
                     MHXControllerProperties* pProp,
                     HXBOOL bVideoController)
 {
-    m_pLogSink = new (ELeave) HXMMFErrorLogSink();
-    m_pStateCtrl = HXMMFStateCtrl::NewL(m_pPrefs, pObs, pProp, 
bVideoController);
-    HX_ADDREF(m_pStateCtrl);
-#if 0
-    // The following code will be enabled later. Disabled due to error in sdk  
  
+
+#ifdef HELIX_CONFIG_AUDIO_SESSION_STANDALONE
     
     // Create the Global DevSound and store it in global mgr
     CHXMMFDevSound* pDevSound = NULL;
@@ -593,6 +590,12 @@
         User::Leave(KErrNoMemory);
     }
 #endif    
+
+
+    m_pLogSink = new (ELeave) HXMMFErrorLogSink();
+    m_pStateCtrl = HXMMFStateCtrl::NewL(m_pPrefs, pObs, pProp, 
bVideoController);
+    HX_ADDREF(m_pStateCtrl);
+
     HXLOGL1(HXLOG_SMMF, "HXMMFBaseCtrl::InitResourcesL() Created StateCtrl");
     HXLOGL1(HXLOG_SMMF, "MMF Controller Version: %s", TARVER_STR_PLATFORM);
 
_______________________________________________
Audio-dev mailing list
[EMAIL PROTECTED]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev

Reply via email to