[Clientapps-cvs] appframeworks/common hxplayerctrlimpl.cpp,1.1,1.2
amsaleem at helixcommunity.org amsaleem at helixcommunity.orgUpdate of /cvsroot/clientapps/appframeworks/common In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv5520 Modified Files: hxplayerctrlimpl.cpp Log Message: "Nokia submits this code under the terms of a commercial contribution agreement with Real Networks, and I am authorized to contribute this code under said agreement." Modified by: saleem.adookkattil at nokia.com Reviewed by: Date: 03/29/2010 Project: symbian_client_apps ErrorId: AJIU-842V2E Synopsis: Phonon backend CHXClientAppFrameWork component release failure due to object reference count problem Overview: Call to release CHXClientAppFrameWork component, failed to released it from memory due to multiple object reference count increment call during the component creation. CHXClientAppFrameWork::CreateInstance(IHXClientAppFrameWork**) creates an instance of CHXClientAppFrameWork component. This method call HX_ADDREF macro after allocating memory for the component and this set the reference count of object to one. CHXClientAppFrameWork::Initialize() method call CHXClientAppFrameWork base class CHXCallbackHandler::Create() and this method call CHXClientAppFrameWork::GetInstance() method. CHXClientAppFrameWork::GetInstance() call reference count increment method and set the reference count of object to two. due to this multiple reference count increment, interface release call on CHXClientAppFrameWork component never bring the reference count to zero and no destructor call made on object. Fixed this reference count issue by setting m_pAppFrameWork = (IHXClientAppFrameWork*)this; in CHXClientAppFrameWork::Initialize() before calling CHXCallbackHandler::Create() and setting m_pAppFrameWork to NULL in CHXClientAppFrameWork::Close. Noticed couple of hidden problem after correcting the above error. They are 1) There was no call made to destroy HXGlobalManagerImp instance (ie, no UninitConfig() method call made to release HXGlobalManagerImp). Added UninitConfig() method call inside CHXClientAppFrameWork ::Close() to release HXGlobalManagerImp instance. In addition, calling close method from base destructor, cause failure to call UninitConfig of derived class(derived class instance destroyed before base instance). So added close method call inside CHXSymbianAppFrameWork::~CHXSymbianAppFrameWork() to close CHXClientAppFrameWork instance derviced class destructor. 2) There was no call to close HXPlayer inside CHXPlayerCtrlImpl instance. Added code close HXPlayer instance in CHXPlayerCtrlImpl::_OnDestroy. 3) Added HX_DISABLE_LOGGING macro call to release log system. Files modified: cvsroot\clientapps\appframeworks\common\hxclientappframework.cpp cvsroot\clientapps\appframeworks\common\hxcallbackhandler.cpp cvsroot\clientapps\appframeworks\common\platform\symbian\hxsymbianappframework.cpp cvsroot\clientapps\appframeworks\common\hxplayerctrlimpl.cpp Files added: Image Size and Heap Use impact: None. Module Release testing (STIF) : No. (There is no stiff test for phonon backend. Tested using phonon test player) Test case(s) Added : No Memory leak check performed : Yes Platforms and Profiles Build Verified: helix-client-symbian-4 Platforms and Profiles Functionality verified: armv5, winscw Branch: 4_2_0_brizo, Head Index: hxplayerctrlimpl.cpp =================================================================== RCS file: /cvsroot/clientapps/appframeworks/common/hxplayerctrlimpl.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hxplayerctrlimpl.cpp 5 Nov 2009 15:28:43 -0000 1.1 +++ hxplayerctrlimpl.cpp 31 Mar 2010 22:19:58 -0000 1.2 @@ -84,6 +84,12 @@ CHXPlayerCtrlImpl::~CHXPlayerCtrlImpl() { + for(short i = 0; i < m_uHandlerCount; i++) + { + HX_RELEASE(m_ppStateHandlers[i]); + } + HX_VECTOR_DELETE(m_ppStateHandlers); + HXCALLBACK_INIT_D(this, CHXPlayerCtrlImpl::_OnDestroy); HXCALLBACK_EXECUTE_D(HRESULT, hr); @@ -91,12 +97,6 @@ HX_RELEASE(m_pMetaDataCache); HX_RELEASE(m_pPlayer2); HX_RELEASE(m_pPlayer); - - for(short i = 0; i < m_uHandlerCount; i++) - { - HX_RELEASE(m_ppStateHandlers[i]); - } - HX_VECTOR_DELETE(m_ppStateHandlers); } STDMETHODIMP CHXPlayerCtrlImpl::QueryInterface(REFIID riid, void** ppvObj) @@ -216,8 +216,18 @@ HX_RESULT hr = m_pPlayer->QueryInterface(IID_IHXPlayer, (void**)&pPlayer); if (SUCCEEDED(hr)) { + hr = UnregisterEvents(pPlayer); + if (SUCCEEDED(hr)) + { + IHXClientEngine* pClientEngine; + hr = pPlayer->GetClientEngine(pClientEngine); + if (SUCCEEDED(hr)) + { + pClientEngine->ClosePlayer(pPlayer); + HX_RELEASE(pClientEngine); + } + } HX_RELEASE(m_pSiteSupplier); - hr = UnregisterEvents(pPlayer); HX_RELEASE(pPlayer); } HXCALLBACK_SET_RETURN(hr);