List Info

Thread: CR: Fix for Dev sound custom interface memory leak




CR: Fix for Dev sound custom interface memory leak
user name
2008-03-27 10:06:20

    "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: rajesh.rathinasamynokia.com

    Reviewed by:

    Date: 25-Mar-2008

    Project: SymbianMmf_rel

    ErrorId: TBD
               ;
    Synopsis: CR: Fix for Dev sound custom interface memory leak

    Custom interfaces (AddedDevSoundCustomInterface) created from dev sound were not deleted.
    Since we dont have the dsp devsound running on emulator, the memory leak was never captured before.

    Also changed the code flow to avoid creation of custom interfaces when dev sound initialization fails.

     
    Root Cause of the problem: API change
     
    Files Modified:
    ===========
    Datatype/mdf/audio/dspdevsound.h
    Datatype/mdf/audio/dspdevsound.cpp

    Image Size and Heap Use impact: no major impact

    Module Release testing (STIF) :  Passed.

    Test case(s) Added ; :  No.

    Memory leak check performed : No. (No support for DSP devsound on emulator)

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

    Platforms and Profiles Functionality verified: armv5

    Branch: 221Cays, 210CayS, Head


Index: mdfdevsound.cpp
===================================================================
RCS file: /cvsroot/datatype/mdf/audio/dsp/mdfdevsound.cpp,v
retrieving revision 1.1.2.17
diff -w -u -b -r1.1.2.17 mdfdevsound.cpp
--- mdfdevsound.cpp   ;  15 Jan 2008 19:31:46 -0000 ;     1.1.2.17
+++ mdfdevsound.cpp   ;  27 Mar 2008 14:56:53 -0000
-123,6 +123,7
           ;  m_pDevSound(NULL),
           ;  m_pDevSoundBuffer(NULL),
           ;  m_devStatus(DevNone),  ;           ;  //init. status
+         ;   m_pAddedDevSoundCI(NULL),
           ;  m_pAudioFormat(pFormat),
           ;  m_devMode(TransferByFrame), ;        //default mode
           ;  m_ulDevTime(0),
-219,6 +220,9
         Close();
     }

+    HXLOGL1(HXLOG_MDFA, "---devsnd:~devsnd Deleting DevSound Custom interface :%p", m_pAddedDevSoundCI);
+    HX_DELETE(m_pAddedDevSoundCI);
+
     if(m_bDevSoundOwned == TRUE)
     {
         HXLOGL2(HXLOG_MDFA, "CMDFDevSound::~CMDFDevSound() Deleting DevSound :%x", m_pDevSound);
-326,15 +330,9
     //
     if (m_devStatus!=DevPlaying)
     {
-        TAny* ptr = m_pDevSound->CustomInterface(KUidAddedDevSoundControlInterface);
-        if (ptr)
-        {
- &nbsp; &nbsp; &nbsp;   ; &nbsp; lError = (static_cast<MAddedDevSoundControl * >(ptr))->PauseAndFlush();
- &nbsp; &nbsp; &nbsp;   ;  }
- &nbsp; &nbsp; &nbsp;  else
- &nbsp; &nbsp; &nbsp;   ;  {
- &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  lError = KErrArgument;
- &nbsp; &nbsp; &nbsp;   ;  }
+ &nbsp; &nbsp; &nbsp;  HX_ASSERT(m_pAddedDevSoundCI);
+ &nbsp; &nbsp; &nbsp;  lError = m_pAddedDevSoundCI-&gt;PauseAndFlush();
+
 &nbsp; &nbsp; &nbsp; &nbsp; if (lError!=KErrNone) return HXR_FAIL;

 &nbsp; &nbsp; #if defined(HELIX_FEATURE_LOGLEVEL_4)
-468,9 +466,10
 //
 HX_RESULT CMDFDevSound::Open(HXMDFAudioFormat *pFormat, TMMFPrioritySettings *pPrioritySettings, HXBOOL bSecureAudio)
 {
- &nbsp;  HXLOGL4(HXLOG_MDFA, "---devsnd:Open < %sn", pFormat-&gt;m_fourCC);
+ &nbsp;  HXLOGL2(HXLOG_MDFA, "---devsnd:Open < %sn", pFormat-&gt;m_fourCC);

- &nbsp;  HX_RESULT&nbsp; hxr = HXR_OK;
+ &nbsp;  HX_RESULT&nbsp; hxr = HXR_FAIL;
+ &nbsp;  TInt   ; &nbsp;  lError = KErrNone;

 &nbsp; &nbsp; m_pAudioFormat = pFormat;
 &nbsp; &nbsp; if (pPrioritySettings != NULL)
-500,39 +499,46

 &nbsp; &nbsp; HXLOGL3(HXLOG_MDFA, "---devsnd:Open .. tFourCC found n");

- &nbsp;  TInt err = KErrNone;
+
 &nbsp; &nbsp; if(m_bDevSoundOwned == TRUE)
 &nbsp; &nbsp; {
- &nbsp; &nbsp; &nbsp;  TRAP(err, m_pDevSound->InitializeL(*this, m_fourCC, EMMFStatePlaying));
+ &nbsp; &nbsp; &nbsp;  TRAP(lError, m_pDevSound->InitializeL(*this, m_fourCC, EMMFStatePlaying));
 &nbsp; &nbsp; }
 &nbsp; &nbsp; else
 &nbsp; &nbsp; {
 &nbsp; &nbsp; &nbsp; &nbsp; CHXMMFDevSound* pHxDevSound = CHXMMFDevSound::Get();

 &nbsp; &nbsp; &nbsp; &nbsp; HX_ASSERT(pHxDevSound);
- &nbsp; &nbsp; &nbsp;  err = pHxDevSound->ReInitialize(this, m_fourCC);
+ &nbsp; &nbsp; &nbsp;  lError = pHxDevSound->ReInitialize(this, m_fourCC);
 &nbsp; &nbsp; }

- &nbsp;  if (err != KErrNone)
+ &nbsp;  if(lError == KErrNone)
 &nbsp; &nbsp; {
- &nbsp; &nbsp; &nbsp;  HXLOGL1(HXLOG_MDFA, "---devsnd:Open .. InitializeL failed.&quot;);
- &nbsp; &nbsp; &nbsp;  hxr = HXR_FAIL;
- &nbsp;  }
+ &nbsp; &nbsp; &nbsp;  HX_DELETE(m_pAddedDevSoundCI);

 &nbsp; &nbsp; // Set up TRUE PAUSE. No need for S60 4.0
- &nbsp;  TAny *ptr = m_pDevSound->CustomInterface(KUidAddedDevSoundControlInterface);
- &nbsp;  if (ptr)
+ &nbsp; &nbsp; &nbsp;  // DevSound creates a new custom interface and ownership is
+ &nbsp; &nbsp; &nbsp;  // passed to the client
+ &nbsp; &nbsp; &nbsp;  m_pAddedDevSoundCI = static_cast<MAddedDevSoundControl* >
+ &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp;  (m_pDevSound->CustomInterface(KUidAddedDevSoundControlInterface));
+
+ &nbsp; &nbsp; &nbsp;  HXLOGL1(HXLOG_MDFA, "---devsnd:Open&nbsp; Added DevSound Custom interface :%p", m_pAddedDevSoundCI);
+
+ &nbsp; &nbsp; &nbsp;  if (m_pAddedDevSoundCI != NULL)
+ &nbsp; &nbsp; &nbsp;  {
+ &nbsp; &nbsp; &nbsp;   ; &nbsp; if(m_pAddedDevSoundCI->SetHwAwareness(ETrue) == KErrNone)
 &nbsp; &nbsp; {
- &nbsp; &nbsp; &nbsp;  (static_cast<MAddedDevSoundControl * >(ptr))->SetHwAwareness(ETrue);
+ &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; // Based on fourcc, load specific custom interface
+ &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; hxr = LoadCustomInterfaces();
+ &nbsp; &nbsp; &nbsp;   ; &nbsp; }
+ &nbsp; &nbsp; &nbsp;  }
+
+ &nbsp; &nbsp; &nbsp;  HXLOGL2(HXLOG_MDFA, "---devsnd:Open LoadCustomInterface:%dn", hxr);
 &nbsp; &nbsp; }
 &nbsp; &nbsp; else
 &nbsp; &nbsp; {
- &nbsp; &nbsp; &nbsp;  return HXR_FAIL;
+ &nbsp; &nbsp; &nbsp;  HXLOGL1(HXLOG_MDFA, "---devsnd:Open .. InitializeL failed. :%d", lError);
 &nbsp; &nbsp; }
- &nbsp;  HXLOGL3(HXLOG_MDFA, "---devsnd:Open .. True Pause is OKn");
-
- &nbsp;  // Based on fourcc, load specific custom interface
- &nbsp; &nbsp; &nbsp; hxr = LoadCustomInterfaces();

 #endif

Index: mdfdevsound.h
===================================================================
RCS file: /cvsroot/datatype/mdf/audio/dsp/mdfdevsound.h,v
retrieving revision 1.1.2.8
diff -w -u -b -r1.1.2.8 mdfdevsound.h
--- mdfdevsound.h &nbsp; &nbsp;   16 May 2007 22:10:45 -0000 ; &nbsp; &nbsp; 1.1.2.8
+++ mdfdevsound.h &nbsp; &nbsp;   27 Mar 2008 14:56:53 -0000
-66,6 +66,8
 class CHXMDFAudioDeviceObserver;
 class CHXMMFDevSound;

+class MAddedDevSoundControl;
+
 ///
 typedef struct _FourCCMap
 {
-166,6 +168,8
 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; CMMFBuffer* &nbsp; &nbsp; &nbsp; &nbsp; m_pDevSoundBuffer;
 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; DevSoundStatus &nbsp;   ; m_devStatus;

+ &nbsp; &nbsp; &nbsp;  MAddedDevSoundControl* m_pAddedDevSoundCI;
+
 &nbsp; &nbsp; &nbsp; &nbsp; UINT16&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  m_uDevVolume;
 &nbsp; &nbsp; &nbsp; &nbsp; UINT16&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  m_uDevVolumeMin;
 &nbsp; &nbsp; &nbsp; &nbsp; UINT16&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  m_uDevVolumeMax;

RE: CR: Fix for Dev sound custom interface memory leak
country flaguser name
United States
2008-03-27 10:12:10
Looks good.

=============================================
Eric Hyche (ehychereal.com)
Technical Lead
RealNetworks, Inc.  

> -----Original Message-----
> From: datatype-dev-bounceshelixcommunity.org 
> [mailto:datatype-dev-bounceshelixcommunity.org] On
Behalf Of 
> rajesh.rathinasamynokia.com
> Sent: Thursday, March 27, 2008 11:06 AM
> To: datatype-devhelixcommunity.org; 
> porting-symbianhelixcommunity.org
> Subject: [datatype-dev] CR: Fix for Dev sound custom 
> interface memory leak
> 
> 	"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: rajesh.rathinasamynokia.com 
> 
> 	Reviewed by: 
> 
> 	Date: 25-Mar-2008 
> 
> 	Project: SymbianMmf_rel 
> 
> 	ErrorId: TBD 
> 	            
> 	Synopsis: CR: Fix for Dev sound custom interface
memory leak 
> 
> 	Custom interfaces (AddedDevSoundCustomInterface) 
> created from dev sound were not deleted. 
> 	Since we dont have the dsp devsound running on 
> emulator, the memory leak was never captured before. 
> 
> 	Also changed the code flow to avoid creation of custom

> interfaces when dev sound initialization fails. 
> 
> 	  
> 	Root Cause of the problem: API change 
> 	  
> 	Files Modified: 
> 	=========== 
> 	Datatype/mdf/audio/dspdevsound.h 
> 	Datatype/mdf/audio/dspdevsound.cpp 
> 
> 	Image Size and Heap Use impact: no major impact 
> 
> 	Module Release testing (STIF) :  Passed. 
> 
> 	Test case(s) Added  :  No. 
> 
> 	Memory leak check performed : No. (No support for DSP

> devsound on emulator) 
> 
> 	Platforms and Profiles Build Verified: 
> helix-client-s60-32-mmf-mdf-dsp 
> 
> 	Platforms and Profiles Functionality verified: armv5 
> 
> 	Branch: 221Cays, 210CayS, Head 
> 
> 
> Index: mdfdevsound.cpp 
>
============================================================
======= 
> RCS file:
/cvsroot/datatype/mdf/audio/dsp/mdfdevsound.cpp,v 
> retrieving revision 1.1.2.17 
> diff -w -u -b -r1.1.2.17 mdfdevsound.cpp 
> --- mdfdevsound.cpp     15 Jan 2008 19:31:46 -0000     
1.1.2.17 
> +++ mdfdevsound.cpp     27 Mar 2008 14:56:53 -0000 
>  -123,6 +123,7  
>              m_pDevSound(NULL), 
>              m_pDevSoundBuffer(NULL), 
>              m_devStatus(DevNone),              
//init. status 
> +            m_pAddedDevSoundCI(NULL), 
>              m_pAudioFormat(pFormat), 
>              m_devMode(TransferByFrame),        
//default mode 
>              m_ulDevTime(0), 
>  -219,6 +220,9  
>          Close(); 
>      } 
> 
> +    HXLOGL1(HXLOG_MDFA, "---devsnd:~devsnd
Deleting DevSound 
> Custom interface :%p", m_pAddedDevSoundCI); 
> +    HX_DELETE(m_pAddedDevSoundCI); 
> + 
>      if(m_bDevSoundOwned == TRUE) 
>      { 
>          HXLOGL2(HXLOG_MDFA,
"CMDFDevSound::~CMDFDevSound() 
> Deleting DevSound :%x", m_pDevSound); 
>  -326,15 +330,9  
>      // 
>      if (m_devStatus!=DevPlaying) 
>      { 
> -        TAny* ptr = 
>
m_pDevSound->CustomInterface(KUidAddedDevSoundControlInte
rface); 
> -        if (ptr) 
> -        { 
> -            lError =
(static_cast<MAddedDevSoundControl * 
> >(ptr))->PauseAndFlush(); 
> -           } 
> -        else 
> -           { 
> -                   lError = KErrArgument; 
> -           } 
> +        HX_ASSERT(m_pAddedDevSoundCI); 
> +        lError =
m_pAddedDevSoundCI->PauseAndFlush(); 
> + 
>          if (lError!=KErrNone) return HXR_FAIL; 
> 
>      #if defined(HELIX_FEATURE_LOGLEVEL_4) 
>  -468,9 +466,10  
>  // 
>  HX_RESULT CMDFDevSound::Open(HXMDFAudioFormat
*pFormat, 
> TMMFPrioritySettings *pPrioritySettings, HXBOOL
bSecureAudio) 
>  { 
> -    HXLOGL4(HXLOG_MDFA, "---devsnd:Open <
%sn", pFormat->m_fourCC); 
> +    HXLOGL2(HXLOG_MDFA, "---devsnd:Open <
%sn", pFormat->m_fourCC); 
> 
> -    HX_RESULT  hxr = HXR_OK; 
> +    HX_RESULT  hxr = HXR_FAIL; 
> +    TInt       lError = KErrNone; 
> 
>      m_pAudioFormat = pFormat; 
>      if (pPrioritySettings != NULL) 
>  -500,39 +499,46  
> 
>      HXLOGL3(HXLOG_MDFA, "---devsnd:Open ..
tFourCC found n"); 
> 
> -    TInt err = KErrNone; 
> + 
>      if(m_bDevSoundOwned == TRUE) 
>      { 
> -        TRAP(err, m_pDevSound->InitializeL(*this,
m_fourCC, 
> EMMFStatePlaying)); 
> +        TRAP(lError,
m_pDevSound->InitializeL(*this, 
> m_fourCC, EMMFStatePlaying)); 
>      } 
>      else 
>      { 
>          CHXMMFDevSound* pHxDevSound =
CHXMMFDevSound::Get(); 
> 
>          HX_ASSERT(pHxDevSound); 
> -        err = pHxDevSound->ReInitialize(this,
m_fourCC); 
> +        lError = pHxDevSound->ReInitialize(this,
m_fourCC); 
>      } 
> 
> -    if (err != KErrNone) 
> +    if(lError == KErrNone) 
>      { 
> -        HXLOGL1(HXLOG_MDFA, "---devsnd:Open ..
InitializeL 
> failed."); 
> -        hxr = HXR_FAIL; 
> -    } 
> +        HX_DELETE(m_pAddedDevSoundCI); 
> 
>      // Set up TRUE PAUSE. No need for S60 4.0 
> -    TAny *ptr = 
>
m_pDevSound->CustomInterface(KUidAddedDevSoundControlInte
rface); 
> -    if (ptr) 
> +        // DevSound creates a new custom interface and
ownership is 
> +        // passed to the client 
> +        m_pAddedDevSoundCI =
static_cast<MAddedDevSoundControl* > 
> +                            
>
(m_pDevSound->CustomInterface(KUidAddedDevSoundControlInt
erface)); 
> + 
> +        HXLOGL1(HXLOG_MDFA, "---devsnd:Open 
Added DevSound 
> Custom interface :%p", m_pAddedDevSoundCI); 
> + 
> +        if (m_pAddedDevSoundCI != NULL) 
> +        { 
> +           
if(m_pAddedDevSoundCI->SetHwAwareness(ETrue) == 
> KErrNone) 
>      { 
> -        (static_cast<MAddedDevSoundControl * 
> >(ptr))->SetHwAwareness(ETrue); 
> +                // Based on fourcc, load specific
custom interface 
> +                hxr = LoadCustomInterfaces(); 
> +            } 
> +        } 
> + 
> +        HXLOGL2(HXLOG_MDFA, "---devsnd:Open 
> LoadCustomInterface:%dn", hxr); 
>      } 
>      else 
>      { 
> -        return HXR_FAIL; 
> +        HXLOGL1(HXLOG_MDFA, "---devsnd:Open ..
InitializeL 
> failed. :%d", lError); 
>      } 
> -    HXLOGL3(HXLOG_MDFA, "---devsnd:Open .. True
Pause is OKn"); 
> - 
> -    // Based on fourcc, load specific custom interface

> -       hxr = LoadCustomInterfaces(); 
> 
>  #endif 
> 
> Index: mdfdevsound.h 
>
============================================================
======= 
> RCS file:
/cvsroot/datatype/mdf/audio/dsp/mdfdevsound.h,v 
> retrieving revision 1.1.2.8 
> diff -w -u -b -r1.1.2.8 mdfdevsound.h 
> --- mdfdevsound.h       16 May 2007 22:10:45 -0000     
1.1.2.8 
> +++ mdfdevsound.h       27 Mar 2008 14:56:53 -0000 
>  -66,6 +66,8  
>  class CHXMDFAudioDeviceObserver; 
>  class CHXMMFDevSound; 
> 
> +class MAddedDevSoundControl; 
> + 
>  /// 
>  typedef struct _FourCCMap 
>  { 
>  -166,6 +168,8  
>                 CMMFBuffer*         m_pDevSoundBuffer;

>                 DevSoundStatus      m_devStatus; 
> 
> +        MAddedDevSoundControl* m_pAddedDevSoundCI; 
> + 
>          UINT16              m_uDevVolume; 
>          UINT16              m_uDevVolumeMin; 
>          UINT16              m_uDevVolumeMax; 
> 
> 


_______________________________________________
Datatype-dev mailing list
Datatype-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/da
tatype-dev

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )