"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.rathinasamy nokia.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)
- {
- 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(KUidAddedDevSoundControlInterface);
- if (ptr)
+ // DevSound creates a new custom interface and ownership is
+ // passed to the client
+ m_pAddedDevSoundCI = static_cast<MAddedDevSoundControl* >
+ (m_pDevSound->CustomInterface(KUidAddedDevSoundControlInterface));
+
+ 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;
|