Change to the unique_ptr
authorKyungYoun <ky99.won@samsung.com>
Mon, 25 Mar 2013 01:36:15 +0000 (10:36 +0900)
committerKyungYoun <ky99.won@samsung.com>
Mon, 25 Mar 2013 01:36:15 +0000 (10:36 +0900)
Change-Id: Icae24a3230ba85dae262536a72452fab95934b90
Signed-off-by: KyungYoun <ky99.won@samsung.com>
29 files changed:
src/FMediaAudioRecorder.cpp
src/FMediaCamera.cpp
src/FMediaCapability.cpp
src/FMediaVideoRecorder.cpp
src/FMedia_AudioRecorderEvent.cpp
src/FMedia_AudioRecorderImpl.cpp
src/FMedia_AudioRecorderImpl.h
src/FMedia_CamPtrUtil.h
src/FMedia_CameraCapability.cpp
src/FMedia_CameraCapability.h
src/FMedia_CameraCoordinator.cpp
src/FMedia_CameraCoordinator.h
src/FMedia_CameraEvent.cpp
src/FMedia_CameraEvent.h
src/FMedia_CameraEventArg.cpp
src/FMedia_CameraEventArg.h
src/FMedia_CameraImpl.cpp
src/FMedia_CameraManager.cpp
src/FMedia_CameraManager.h
src/FMedia_CapabilityImpl.cpp
src/FMedia_RecorderEventArg.cpp
src/FMedia_RecorderEventArg.h
src/FMedia_RecorderManager.cpp
src/FMedia_RecorderManager.h
src/FMedia_VideoFrameImpl.cpp
src/FMedia_VideoRecorderEvent.cpp
src/FMedia_VideoRecorderImpl.cpp
src/FMedia_VideoRecorderImpl.h
src/inc/FMedia_CapabilityImpl.h

index e64f979..e63f954 100755 (executable)
  * @brief              This file contains the implementation of the %AudioRecorder class.
  */
 
+#include <unique_ptr.h>
 #include <FMediaAudioRecorder.h>
 #include <FBaseSysLog.h>
 #include <FSec_AccessController.h>
 #include "FMedia_RecorderTypes.h"
 #include "FMedia_AudioRecorderImpl.h"
+#include "FMedia_CamPtrUtil.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -53,22 +55,13 @@ AudioRecorder::Construct(IAudioRecorderEventListener& listener)
        SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
        result r = E_SUCCESS;
 
-       //Create impl
-       _AudioRecorderImpl* pImpl = new (std::nothrow) _AudioRecorderImpl();
-       SysTryCatch(NID_MEDIA, pImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       std::unique_ptr <_AudioRecorderImpl> pImpl (new (std::nothrow) _AudioRecorderImpl());
+       SysTryReturn(NID_MEDIA, pImpl.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        r = pImpl->Construct(listener);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       __pImpl = pImpl;
-       return r;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-CATCH:
-       if (pImpl != null)
-       {
-               delete pImpl;
-               pImpl = null;
-       }
+       __pImpl = pImpl.release();
        return r;
 }
 
@@ -347,22 +340,12 @@ AudioRecorder::GetSupportedCodecListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       ArrayListT <CodecType>* pDestListT = null;
        ClearLastResult();
 
-       pDestListT = __pImpl->GetSupportedCodecListN();
+       std::unique_ptr <IListT<CodecType>, _ListPtrUtil::Remover> pDestListT (__pImpl->GetSupportedCodecListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-       return pDestListT;
-
-CATCH:
-       if (pDestListT != null)
-       {
-               pDestListT->RemoveAll();
-               delete pDestListT;
-       }
-
-       return null;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       return pDestListT.release();
 }
 
 Tizen::Base::Collection::IListT <MediaContainerType>*
@@ -370,23 +353,12 @@ AudioRecorder::GetSupportedContainerListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       ArrayListT <MediaContainerType>* pDestListT = null;
        ClearLastResult();
 
-       pDestListT = __pImpl->GetSupportedContainerListN();
+       std::unique_ptr <IListT<MediaContainerType>, _ListPtrUtil::Remover> pDestListT (__pImpl->GetSupportedContainerListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pDestListT;
-
-CATCH:
-       if (pDestListT != null)
-       {
-               pDestListT->RemoveAll();
-               delete pDestListT;
-       }
-
-       return null;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+       return pDestListT.release();
 }
 
 result
index 7d995b6..1e34798 100755 (executable)
@@ -47,24 +47,14 @@ result
 Camera::Construct(ICameraEventListener& listener, CameraSelection camSel)
 {
        SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
-
        result r = E_SUCCESS;
 
-       // Create impl
-       _CameraImpl* pImpl = new (std::nothrow) _CameraImpl();
-       SysTryCatch(NID_MEDIA, pImpl !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       std::unique_ptr <_CameraImpl> pImpl (new (std::nothrow) _CameraImpl());
+       SysTryReturn(NID_MEDIA, pImpl.get() !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
        r = pImpl->Construct(listener, camSel);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       __pImpl = pImpl;
-       return r;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-CATCH:
-       if (pImpl != null)
-       {
-               delete pImpl;
-               pImpl = null;
-       }
+       __pImpl = pImpl.release();
        return r;
 }
 
@@ -350,23 +340,13 @@ Camera::GetSupportedPreviewResolutionListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IList* pList = null;
        ClearLastResult();
 
-       pList = __pImpl->GetSupportedPreviewResolutionListN();
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pList (__pImpl->GetSupportedPreviewResolutionListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pList;
-
-CATCH:
-       if (pList != null)
-       {
-               pList->RemoveAll(true);
-               delete pList;
-       }
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return null;
+       return pList.release();
 }
 
 
@@ -408,23 +388,13 @@ Camera::GetSupportedCaptureResolutionListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IList* pList = null;
        ClearLastResult();
 
-       pList = __pImpl->GetSupportedCaptureResolutionListN();
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pList (__pImpl->GetSupportedCaptureResolutionListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pList;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-CATCH:
-       if (pList != null)
-       {
-               pList->RemoveAll(true);
-               delete pList;
-       }
-
-       return null;
+       return pList.release();
 }
 
 
@@ -714,23 +684,13 @@ Camera::GetSupportedCaptureFormatListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IListT <PixelFormat>* pListT = null;
        ClearLastResult();
 
-       pListT = __pImpl->GetSupportedCaptureFormatListN();
+       std::unique_ptr <IListT<PixelFormat>, _ListPtrUtil::Remover> pListT (__pImpl->GetSupportedCaptureFormatListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pListT;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-CATCH:
-       if (pListT != null)
-       {
-               pListT->RemoveAll();
-               delete pListT;
-       }
-
-       return null;
+       return pListT.release();
 }
 
 result
@@ -772,24 +732,13 @@ Camera::GetSupportedPreviewFormatListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IListT <PixelFormat>* pListT = null;
        ClearLastResult();
 
-       pListT = __pImpl->GetSupportedPreviewFormatListN();
+       std::unique_ptr <IListT<PixelFormat>, _ListPtrUtil::Remover> pListT (__pImpl->GetSupportedPreviewFormatListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pListT;
-
-CATCH:
-       if (pListT != null)
-       {
-               pListT->RemoveAll();
-               delete pListT;
-       }
-
-       return null;
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       return pListT.release();
 }
 
 result
@@ -863,23 +812,13 @@ Camera::GetSupportedPreviewFrameRateListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IListT <int>* pListT = null;
        ClearLastResult();
 
-       pListT = __pImpl->GetSupportedPreviewFrameRateListN();
+       std::unique_ptr <IListT<int>, _ListPtrUtil::Remover> pListT (__pImpl->GetSupportedPreviewFrameRateListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pListT;
-
-CATCH:
-       if (pListT != null)
-       {
-               pListT->RemoveAll();
-               delete pListT;
-       }
-
-       return null;
+       return pListT.release();
 }
 
 Tizen::Base::Collection::IListT <int>*
@@ -887,23 +826,13 @@ Camera::GetSupportedPreviewFrameRateListN(const Tizen::Graphics::Dimension& dim)
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       IListT <int>* pListT = null;
        ClearLastResult();
 
-       pListT = __pImpl->GetSupportedPreviewFrameRateListN(dim);
+       std::unique_ptr <IListT<int>, _ListPtrUtil::Remover> pListT (__pImpl->GetSupportedPreviewFrameRateListN(dim), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pListT;
-
-CATCH:
-       if (pListT != null)
-       {
-               pListT->RemoveAll();
-               delete pListT;
-       }
-
-       return null;
+       return pListT.release();
 }
 
 
index 6a28f6d..cbe84ba 100755 (executable)
 #include <FMediaCameraTypes.h>
 #include <FBaseSysLog.h>
 #include "FMedia_CapabilityImpl.h"
+#include "FMedia_CamPtrUtil.h"
 
 using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
 
 namespace Tizen { namespace Media
 {
@@ -193,30 +195,21 @@ Tizen::Base::Collection::IList*
 MediaCapability::GetValueN(const Tizen::Base::String& key)
 {
        result r = E_SUCCESS;
-       Tizen::Base::Collection::ArrayList* pList = null;
        ClearLastResult();
 
        _CapabilityImpl* pImpl = _CapabilityImpl::GetInstance();
-       SysTryCatch(NID_MEDIA, pImpl != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
+       SysTryReturn(NID_MEDIA, pImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Internal object is not found.");
 
-       pList = new (std::nothrow) Tizen::Base::Collection::ArrayList();
-       SysTryCatch(NID_MEDIA, pList !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       std::unique_ptr <ArrayList, _ListPtrUtil::Remover> pList (new (std::nothrow) Tizen::Base::Collection::ArrayList(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pList.get() !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        r = pList->Construct();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        r = pImpl->GetValueN(key, *pList);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       return pList;
-
-CATCH:
-       if (pList != null)
-       {
-               delete pList;
-       }
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return null;
+       return pList.release();
 }
 
 
index 2a330d0..9bdaad9 100755 (executable)
@@ -24,6 +24,7 @@
 #include <FBaseSysLog.h>
 #include <FSec_AccessController.h>
 #include "FMedia_VideoRecorderImpl.h"
+#include "FMedia_CamPtrUtil.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -43,7 +44,6 @@ VideoRecorder::~VideoRecorder(void)
        if (__pImpl != null)
        {
                delete __pImpl;
-               __pImpl = null;
        }
 }
 
@@ -53,21 +53,12 @@ VideoRecorder::Construct(IVideoRecorderEventListener& listener, const Camera& ca
        SysAssertf(__pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
        result r = E_SUCCESS;
 
-       _VideoRecorderImpl* pImpl = new (std::nothrow) _VideoRecorderImpl();
-       SysTryCatch(NID_MEDIA, pImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       std::unique_ptr <_VideoRecorderImpl> pImpl (new (std::nothrow) _VideoRecorderImpl());
+       SysTryReturn(NID_MEDIA, pImpl.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
        r = pImpl->Construct(listener, camera);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
-       __pImpl = pImpl;
-       return r;
-
-CATCH:
-       if (pImpl != null)
-       {
-               delete pImpl;
-               pImpl = null;
-       }
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       __pImpl = pImpl.release();
        return r;
 }
 
@@ -318,24 +309,14 @@ VideoRecorder::GetSupportedCodecListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       Tizen::Base::Collection::IList* pCodecList = null;
        ClearLastResult();
 
-       pCodecList = __pImpl->GetSupportedCodecListN();
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pCodecList (__pImpl->GetSupportedCodecListN(), _ListPtrUtil::remover);
+       SysTryReturn(NID_MEDIA, pCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-
-       return pCodecList;
-
-CATCH:
-       if (pCodecList != null)
-       {
-               pCodecList->RemoveAll(true);
-               delete pCodecList;
-       }
-
-       return null;
+       return pCodecList.release();
 }
 
 result
@@ -404,22 +385,13 @@ VideoRecorder::GetSupportedAudioCodecListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       ArrayListT <CodecType>* pDestList = null;
        ClearLastResult();
 
-       pDestList = __pImpl->GetSupportedAudioCodecListN();
+       std::unique_ptr <IListT<CodecType>, _ListPtrUtil::Remover> pDestList (__pImpl->GetSupportedAudioCodecListN());
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pDestList;
-
-CATCH:
-       if (pDestList != null)
-       {
-               pDestList->RemoveAll();
-               delete pDestList;
-       }
-       return null;
+       return pDestList.release();
 }
 
 Tizen::Base::Collection::IListT <CodecType>*
@@ -427,22 +399,13 @@ VideoRecorder::GetSupportedVideoCodecListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       ArrayListT <CodecType>* pDestList = null;
        ClearLastResult();
 
-       pDestList = __pImpl->GetSupportedVideoCodecListN();
+       std::unique_ptr <IListT<CodecType>, _ListPtrUtil::Remover> pDestList (__pImpl->GetSupportedVideoCodecListN());
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pDestList;
-
-CATCH:
-       if (pDestList != null)
-       {
-               pDestList->RemoveAll();
-               delete pDestList;
-       }
-       return null;
+       return pDestList.release();
 }
 
 Tizen::Base::Collection::IListT <MediaContainerType>*
@@ -450,23 +413,13 @@ VideoRecorder::GetSupportedContainerListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       ArrayListT <MediaContainerType>* pDestList = null;
        ClearLastResult();
 
-       pDestList = __pImpl->GetSupportedContainerListN();
+       std::unique_ptr <IListT<MediaContainerType>, _ListPtrUtil::Remover> pDestList (__pImpl->GetSupportedContainerListN());
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pDestList;
-
-CATCH:
-       if (pDestList != null)
-       {
-               pDestList->RemoveAll();
-               delete pDestList;
-       }
-       return null;
+       return pDestList.release();
 }
 
 result
@@ -573,22 +526,13 @@ VideoRecorder::GetSupportedRecordingResolutionListN(void) const
 {
        SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
        result r = E_SUCCESS;
-       Tizen::Base::Collection::IList* pResolutionList = null;
        ClearLastResult();
 
-       pResolutionList = __pImpl->GetSupportedRecordingResolutionListN();
+       std::unique_ptr <IList, _ListPtrUtil::Remover> pResolutionList (__pImpl->GetSupportedRecordingResolutionListN(), _ListPtrUtil::remover);
        r = GetLastResult();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       return pResolutionList;
-
-CATCH:
-       if (pResolutionList != null)
-       {
-               pResolutionList->RemoveAll(true);
-               delete pResolutionList;
-       }
-       return null;
+       return pResolutionList.release();
 }
 
 int
index 5ccc81c..4bb2e2f 100755 (executable)
@@ -75,11 +75,11 @@ void
 _AudioRecorderEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
 {
        IAudioRecorderEventListener* pAudioRecorderEventListener = dynamic_cast <IAudioRecorderEventListener*>(&listener);
-       SysTryReturn(NID_MEDIA, pAudioRecorderEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pAudioRecorderEventListener != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
 
        Tizen::Base::Runtime::IEventArg* pTtempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
        _RecorderEventArg* pArg = dynamic_cast <_RecorderEventArg*>(pTtempArg);
-       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pArg != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
 
        switch (pArg->GetEventType())
        {
index 2ca79c0..992ea40 100755 (executable)
@@ -135,11 +135,6 @@ _AudioRecorderImpl::~_AudioRecorderImpl(void)
                __handle = MM_INVALID_HANDLE;
        }
 
-       if (__pAudioRecorderEvent != null)
-       {
-               delete __pAudioRecorderEvent;
-       }
-
        if (__pRecorderManager != null)
        {
                _RecorderManager::Release(_RECORDER_DEVICE_AUDIO);
@@ -168,8 +163,8 @@ _AudioRecorderImpl::Construct(IAudioRecorderEventListener& listener)
        SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. A device is already constructed.");
 
        //Create Event
-       __pAudioRecorderEvent = new (std::nothrow) _AudioRecorderEvent();
-       SysTryReturn(NID_MEDIA, __pAudioRecorderEvent !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       __pAudioRecorderEvent.reset(new (std::nothrow) _AudioRecorderEvent());
+       SysTryReturn(NID_MEDIA, __pAudioRecorderEvent.get() !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
        r = __pAudioRecorderEvent->Construct(*this);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -251,11 +246,7 @@ CATCH:
                __pAudioRecorderEventListener = null;
        }
 
-       if (__pAudioRecorderEvent != null)
-       {
-               delete __pAudioRecorderEvent;
-               __pAudioRecorderEvent = null;
-       }
+       __pAudioRecorderEvent.reset(null);
 
        return r;
 }
@@ -1093,7 +1084,7 @@ _AudioRecorderImpl::GetStateChangeReason(void) const
 _AudioRecorderEvent*
 _AudioRecorderImpl::GetEvent(void) const
 {
-       return __pAudioRecorderEvent;
+       return __pAudioRecorderEvent.get();
 }
 
 void
@@ -1103,8 +1094,8 @@ _AudioRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e c
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>( pUserData);
        int tableTotalCount = 0;
        int i = 0;
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
        SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
 
        tableTotalCount = sizeof(_AUDIO_CALLBACK_EVENT) / sizeof(_AUDIO_CALLBACK_EVENT[0]);
@@ -1114,19 +1105,19 @@ _AudioRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e c
                if (previous == _AUDIO_CALLBACK_EVENT[i].prevState && current == _AUDIO_CALLBACK_EVENT[i].postState && pObj->GetStateChangeReason() == _AUDIO_CALLBACK_EVENT[i].reason)
                {
                        r = pObj->GetEvent()->SendEvent(_AUDIO_CALLBACK_EVENT[i].event, _AUDIO_CALLBACK_EVENT[i].error, E_SUCCESS);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
                        break;
                }
        }
-       SysTryReturn(NID_MEDIA, i != tableTotalCount, , E_INVALID_STATE, "[E_INVALID_STATE] Not found. ");
+       SysTryReturnVoidResult(NID_MEDIA, i != tableTotalCount, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Not found. ");
 }
 
 void
 _AudioRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
 {
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
 
        SysLog(NID_MEDIA, " FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
 
@@ -1139,9 +1130,9 @@ _AudioRecorderImpl::AudioStreamCb(void* pStream, int size, audio_sample_type_e f
 {
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
        int samplingRate =0;
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
-       SysTryReturn(NID_MEDIA, pStream != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. Stream data is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pStream != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. Stream data is null.");
 
        if (pObj->__audioStreamCallback == true)
        {
@@ -1155,8 +1146,8 @@ _AudioRecorderImpl::LimitReachedCb(recorder_recording_limit_type_e type, void *p
 {
        result r = E_SUCCESS;
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
 
        SysLog(NID_MEDIA, "Type:%d", type);
 
@@ -1199,13 +1190,13 @@ _AudioRecorderImpl::ErrorCb(recorder_error_e error, recorder_state_e state, void
 {
        result r = E_SUCCESS;
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
 
        SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
 
        r = pObj->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return;
 }
@@ -1214,8 +1205,8 @@ void
 _AudioRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
 {
        _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _AudioRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pObj != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pObj _AudioRecorderImpl is not available. pObj is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pObj _AudioRecorderImpl is not available. pObj is null.");
 
        SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
 }
index 6217dd8..b8a7aab 100755 (executable)
@@ -595,7 +595,7 @@ private:
        _AudioRecorderImpl(const _AudioRecorderImpl&);
        _AudioRecorderImpl& operator =(const _AudioRecorderImpl& _AudioRecorderImpl);
 
-       _AudioRecorderEvent* __pAudioRecorderEvent;
+       std::unique_ptr <_AudioRecorderEvent> __pAudioRecorderEvent;
        IAudioRecorderEventListener* __pAudioRecorderEventListener;
        _RecorderManager* __pRecorderManager;
        bool __isConstructed;
index a9dd0cb..f440f2e 100755 (executable)
 #include <camera.h>
 #include <FBaseColIList.h>
 #include <FBaseColIListT.h>
+#include <FBaseColLinkedListT.h>
 #include <FBaseColQueue.h>
 #include <FGrpPixelFormat.h>
 #include <FMediaTypes.h>
 #include <FMediaIAudioStreamFilter.h>
 #include <FMediaIVideoStreamFilter.h>
 #include "FMedia_CameraTypes.h"
+#include "FMedia_ICameraCoordinatorListener.h"
 
 namespace Tizen { namespace Media
 {
@@ -128,6 +130,15 @@ public:
                        }
                }
 
+               void operator() (Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>* pList) const
+               {
+                       if (pList != null)
+                       {
+                               pList->RemoveAll();
+                               delete pList;
+                       }
+               }
+
                void operator() (Tizen::Base::Collection::Queue* pQueue) const
                {
                        if (pQueue != null)
index b44740d..8ac2db8 100755 (executable)
@@ -56,7 +56,7 @@ _CameraCapabilitySafeHashMapT::RemoveItems(void)
        result r = E_SUCCESS;
 
        std::unique_ptr<IListT<_CameraDeviceType>, _ListPtrUtil::Remover> pList (GetKeysN(), _ListPtrUtil::remover);
-       SysTryReturn(NID_MEDIA, pList.get() != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+       SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
 
        for (int i = 0; i < GetCount(); i++)
        {
@@ -345,38 +345,33 @@ _CameraCapability::AddInstance(_CameraDeviceType cameraDevice)
        {
                pthread_once(&once_block, InitSafeHashMapInst);
                r = GetLastResult();
-               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        r = __pMap->ContainsKey(cameraDevice, out);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (out)
        {
                r = __pMap->GetValue(cameraDevice, pCapability);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCapability != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS && pCapability != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        else
        {
-               pCapability = new (std::nothrow) _CameraCapability();
-               SysTryCatch(NID_MEDIA, pCapability !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+               std::unique_ptr <_CameraCapability> pCap (new (std::nothrow) _CameraCapability());
+               SysTryReturn(NID_MEDIA, pCap.get() !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+               r = pCap->Construct(cameraDevice);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = pCapability->Construct(cameraDevice);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = __pMap->Add(cameraDevice, pCap.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = __pMap->Add(cameraDevice, pCapability);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               pCapability = pCap.release();
        }
 
        pCapability->AddRefCount();
        return pCapability;
-
-CATCH:
-       if (pCapability != null)
-       {
-               delete pCapability;
-       }
-       return null;
 }
 
 void
@@ -388,13 +383,13 @@ _CameraCapability::Release(_CameraDeviceType cameraDevice)
        {
                _CameraCapability* pCameraCapability = null;
                r = __pMap->GetValue(cameraDevice, pCameraCapability);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                if (pCameraCapability->ReleaseRefCount() == 0)
                {
                        delete pCameraCapability;
                        r = __pMap->Remove(cameraDevice);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
 }
index 240eae0..44ddeed 100755 (executable)
@@ -106,6 +106,12 @@ public:
        static Tizen::Base::Object* GetValueN(_CameraOperationType key, _QueryType queryType, _ResultType& itemType);
 
        /**
+       *       The destructor.
+       *       Resources are deallocated by this method.
+       */
+       virtual ~_CameraCapability(void);
+
+       /**
        * Gets the device selection.
        *
        * @return                  The device selection
@@ -186,12 +192,6 @@ private:
        _CameraCapability(void);
 
        /**
-       *       The destructor.
-       *       Resources are deallocated by this method.
-       */
-       ~_CameraCapability(void);
-
-       /**
        * Initializes this instance of _CamcorderCoordinator.
        *
        * @return               An error code
index d2a3469..8cbe446 100755 (executable)
@@ -91,12 +91,11 @@ _CameraCoordinatorSafeHashMapT::~_CameraCoordinatorSafeHashMapT(void)
 void
 _CameraCoordinatorSafeHashMapT::RemoveItems(void)
 {
-       IListT <_CameraDeviceType>* pList = null;
        _CameraCoordinator* pCoordinator = null;
        result r = E_SUCCESS;
 
-       pList = GetKeysN();
-       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+       std::unique_ptr <IListT <_CameraDeviceType>, _ListPtrUtil::Remover> pList (GetKeysN(), _ListPtrUtil::remover);
+       SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
        for (int i = 0; i < GetCount(); i++)
        {
                _CameraDeviceType deviceType = _CAMERA_DEVICE_NONE;
@@ -113,9 +112,6 @@ _CameraCoordinatorSafeHashMapT::RemoveItems(void)
                }
                delete pCoordinator;
        }
-       pList->RemoveAll();
-       delete pList;
-       RemoveAll();
 }
 
 _CameraCoordinator::_CameraCoordinator()
@@ -123,7 +119,7 @@ _CameraCoordinator::_CameraCoordinator()
        , __cameraHandle(MM_INVALID_HANDLE)
        , __recorderHandle(MM_INVALID_HANDLE)
        , __mode(_CAMERA_MODE_NONE)
-       , __pListenerList(null)
+       , __pListenerList(null, _ListPtrUtil::remover)
        , __orientationFlag(0)
        , __cameraOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT)
        , __recordingRotation(RECORDING_ROTATION_NONE)
@@ -132,12 +128,6 @@ _CameraCoordinator::_CameraCoordinator()
 
 _CameraCoordinator::~_CameraCoordinator()
 {
-       if (__pListenerList != null)
-       {
-               __pListenerList->RemoveAll();
-               delete __pListenerList;
-       }
-
        _CameraManager::Release(__cameraDevice);
        SysLog(NID_MEDIA, "Camera manager released");
 }
@@ -155,16 +145,13 @@ _CameraCoordinator::Construct(_CameraDeviceType cameraDevice)
 
        __cameraHandle = pCameraManager->GetHandle();
 
-       __pListenerList = new (std::nothrow) LinkedListT <_ICameraCoordinatorListener*>();
-       SysTryCatch(NID_MEDIA, __pListenerList !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       __pListenerList.reset(new (std::nothrow) LinkedListT <_ICameraCoordinatorListener*>());
+       SysTryReturn(NID_MEDIA, __pListenerList.get() !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        __cameraDevice = cameraDevice;
        __mode = _CAMERA_MODE_IMAGE;
 
        return r;
-
-CATCH:
-       return r;
 }
 
 result
@@ -212,40 +199,35 @@ _CameraCoordinator::AddInstance(_CameraDeviceType cameraDevice)
        if (!isMapConstructed)
        {
                r = map.Construct();
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
                isMapConstructed = true;
                __pMap = &map;
        }
 
        r = map.ContainsKey(cameraDevice, out);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (out)
        {
                r = map.GetValue(cameraDevice, pCoordinator);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pCoordinator != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS && pCoordinator != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        else
        {
-               pCoordinator = new (std::nothrow) _CameraCoordinator();
-               SysTryCatch(NID_MEDIA, pCoordinator !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+               std::unique_ptr <_CameraCoordinator> pCoord (new (std::nothrow) _CameraCoordinator());
+               SysTryReturn(NID_MEDIA, pCoord.get() !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
-               r = pCoordinator->Construct(cameraDevice);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = pCoord->Construct(cameraDevice);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = map.Add(cameraDevice, pCoordinator);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = map.Add(cameraDevice, pCoord.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pCoordinator = pCoord.release();
        }
 
        pCoordinator->AddRefCount();
        return pCoordinator;
-
-CATCH:
-       if (pCoordinator != null)
-       {
-               delete pCoordinator;
-       }
-       return null;
 }
 
 _CameraCoordinator*
@@ -293,13 +275,13 @@ _CameraCoordinator::Release(_CameraDeviceType cameraDevice)
        {
                _CameraCoordinator* pCoordinator = null;
                r = __pMap->GetValue(cameraDevice, pCoordinator);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                if (pCoordinator->ReleaseRefCount() == 0)
                {
                        delete pCoordinator;
                        r = __pMap->Remove(cameraDevice);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
 }
@@ -426,32 +408,20 @@ result
 _CameraCoordinator::NotifyModeChangePrepared(_CameraMode mode)
 {
        result r = E_SUCCESS;
-       IEnumeratorT <_ICameraCoordinatorListener*>* pEnum = null;
        _ICameraCoordinatorListener* pListener = null;
        SysLog(NID_MEDIA, "mode:%d", mode);
 
-       pEnum = __pListenerList->GetEnumeratorN();
-       r = GetLastResult();
-       SysTryCatch(NID_MEDIA, pEnum != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr <IEnumeratorT <_ICameraCoordinatorListener*> > pEnum (__pListenerList->GetEnumeratorN());
+       SysTryReturn(NID_MEDIA, pEnum.get() != null, GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        while (pEnum->MoveNext() == E_SUCCESS)
        {
                r = pEnum->GetCurrent(pListener);
-               SysTryCatch(NID_MEDIA, pListener != null && r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+               SysTryReturn(NID_MEDIA, pListener != null && r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
                                   "[E_SYSTEM] A system error has been occurred.  The listener is not proper");
 
                r = pListener->OnCameraCoordinatorModeChangePrepared(mode);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-
-       delete pEnum;
-       return r;
-
-CATCH:
-       if (pEnum != null)
-       {
-               delete pEnum;
-               pEnum = null;
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        return r;
 }
@@ -460,32 +430,20 @@ result
 _CameraCoordinator::NotifyModeChanged(_CameraMode mode)
 {
        result r = E_SUCCESS;
-       IEnumeratorT <_ICameraCoordinatorListener*>* pEnum = null;
        _ICameraCoordinatorListener* pListener = null;
        SysLog(NID_MEDIA, "mode:%d", mode);
 
-       pEnum = __pListenerList->GetEnumeratorN();
-       r = GetLastResult();
-       SysTryCatch(NID_MEDIA, pEnum != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+       std::unique_ptr <IEnumeratorT <_ICameraCoordinatorListener*> > pEnum (__pListenerList->GetEnumeratorN());
+       SysTryReturn(NID_MEDIA, pEnum.get() != null, GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        while (pEnum->MoveNext() == E_SUCCESS)
        {
                r = pEnum->GetCurrent(pListener);
-               SysTryCatch(NID_MEDIA, pListener != null && r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM,
+               SysTryReturn(NID_MEDIA, pListener != null && r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
                                   "[E_SYSTEM] A system error has been occurred.  The listener is not proper");
 
                r = pListener->OnCameraCoordinatorModeChanged(mode);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-       }
-
-       delete pEnum;
-       return r;
-
-CATCH:
-       if (pEnum != null)
-       {
-               delete pEnum;
-               pEnum = null;
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        return r;
 }
index e0a52fa..3740229 100755 (executable)
@@ -24,6 +24,7 @@
 #ifndef _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
 #define _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
 
+#include <unique_ptr.h>
 #include <camera.h>
 #include <recorder.h>
 #include <FBaseColLinkedListT.h>
@@ -33,6 +34,7 @@
 #include "FMedia_CameraTypes.h"
 #include "FMedia_RecorderTypes.h"
 #include "FMedia_CameraRefHelper.h"
+#include "FMedia_CamPtrUtil.h"
 
 namespace Tizen { namespace Media
 {
@@ -111,6 +113,15 @@ public:
        static _CameraCoordinator* HasInstance(_RecorderDeviceType recorderDevice);
 
        /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraCoordinator(void);
+
+       /**
        * Adds the listener to this object. @n
        * Added listeners are called after this object's callbacks are called from the camera.
        *
@@ -287,15 +298,6 @@ private:
        _CameraCoordinator(void);
 
        /**
-        * This is the destructor for this class. @n
-        * All allocated resources are deallocated by this method. This method should be called in the same thread
-        * where the Construct() method is called.
-        *
-        * @see                 Construct()
-        */
-       virtual ~_CameraCoordinator(void);
-
-       /**
        * Initializes this instance of _CameraCoordinator.
        *
        * @return               An error code
@@ -397,7 +399,7 @@ private:
        _CameraHandle __cameraHandle;
        _RecorderHandle __recorderHandle;
        _CameraMode __mode;
-       Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>* __pListenerList;
+       std::unique_ptr<Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>, _ListPtrUtil::Remover> __pListenerList;
        int __orientationFlag;
        CameraExifOrientation __cameraOrientation;
        RecordingRotation __recordingRotation;
index 7f35cd3..a3c3e55 100755 (executable)
@@ -58,7 +58,7 @@ _CameraEvent::Construct(_CameraImpl& cameraImpl)
 }
 
 result
-_CameraEvent::SendEvent(_CameraEventType event, CameraErrorReason err, result res, const ByteBuffer* pByteBuffer)
+_CameraEvent::SendEvent(_CameraEventType event, CameraErrorReason err, result res, ByteBuffer* pByteBuffer)
 {
        result r = E_SUCCESS;
        std::unique_ptr <_CameraEventArg> pCameraEventArg (new (std::nothrow) _CameraEventArg());
@@ -80,11 +80,11 @@ void
 _CameraEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
 {
        ICameraEventListener* pCameraEventListener = dynamic_cast <ICameraEventListener*>(&listener);
-       SysTryReturn(NID_MEDIA, pCameraEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pCameraEventListener != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
 
        Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
        _CameraEventArg* pArg = dynamic_cast <_CameraEventArg*>(pTempArg);
-       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pArg != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
 
        result r = E_SUCCESS;
        switch (pArg->GetEventType())
@@ -139,8 +139,8 @@ _CameraEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tiz
 
        case _CAMERA_EVENT_PREVIEWED_DATA:
        {
-               _CameraBuffer* pBuffer = __pCameraImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW);
-               SysTryReturn(NID_MEDIA, pBuffer != null, , E_INVALID_DATA, "[E_INVALID_DATA] Invalid preview data.");
+               std::unique_ptr <_CameraBuffer> pBuffer (__pCameraImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW));
+               SysTryReturnVoidResult(NID_MEDIA, pBuffer.get() != null, E_INVALID_DATA, "[E_INVALID_DATA] Invalid preview data.");
 
                MediaPixelFormat mediaSrcFormat = pBuffer->GetPixelFormat();
 
@@ -163,30 +163,27 @@ _CameraEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tiz
 
                        SysLog(NID_MEDIA, "Preview callback. MM format should be converted from %d to %d", mediaSrcFormat, mediaUserFormat);
                        r = cvt.Construct(mediaSrcFormat, width, height, mediaUserFormat, width, height);
-                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                        convertedBufSize = _ImageUtil::GetBufferSize(mediaUserFormat, width, height);
-                       SysTryCatch(NID_MEDIA, convertedBufSize > 0, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+                       SysTryReturnVoidResult(NID_MEDIA, convertedBufSize > 0, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
                        r = dstCameraBuffer.Construct(convertedBufSize, _CAMERA_BUFFER_PREVIEW, mediaUserFormat, width, height);
-                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. size:%d", GetErrorMessage(r), convertedBufSize);
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating. size:%d", GetErrorMessage(r), convertedBufSize);
 
                        pConvertedBuf = const_cast<byte*>(dstCameraBuffer.GetPointer());
-                       SysTryCatch(NID_MEDIA, pConvertedBuf != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] byte instance is not available. dstCameraBuffer.GetPointer() is null.");
+                       SysTryReturnVoidResult(NID_MEDIA, pConvertedBuf != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] byte instance is not available. dstCameraBuffer.GetPointer() is null.");
 
                        r = cvt.Convert(pSrcBuf, pBuffer->GetCapacity(), pConvertedBuf, convertedBufSize);
-                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                        pCameraEventListener->OnCameraPreviewed(dstCameraBuffer, pArg->GetResult());
                }
                else            //If the conversion is not needed.
                {
                        SysLog(NID_MEDIA, "Preview callback. Format is %d", mediaSrcFormat);
-                       pCameraEventListener->OnCameraPreviewed(*pBuffer, pArg->GetResult());
+                       pCameraEventListener->OnCameraPreviewed(*pBuffer.get(), pArg->GetResult());
                }
-
-CATCH:
-               delete pBuffer;
        }
        break;
 
index 96114db..68117b0 100755 (executable)
@@ -78,7 +78,7 @@ public:
         *      @exception      E_INVALID_STATE                 - This instance is in an invalid state for this method.
         *      @exception      E_INVALID_ARG                                - The argument passed to a method contains an invalid value.
         */
-       result SendEvent(_CameraEventType event, CameraErrorReason err, result res, const Tizen::Base::ByteBuffer* pByteBuffer);
+       result SendEvent(_CameraEventType event, CameraErrorReason err, result res, Tizen::Base::ByteBuffer* pByteBuffer);
 
 protected:
        /**
index fea6833..d1bf1a2 100755 (executable)
@@ -39,10 +39,6 @@ _CameraEventArg::_CameraEventArg(void)
 
 _CameraEventArg::~_CameraEventArg(void)
 {
-       if (__pCameraData != null)
-       {
-               delete __pCameraData;
-       }
 }
 
 void
@@ -58,20 +54,18 @@ _CameraEventArg::GetEventType(void) const
 }
 
 void
-_CameraEventArg::SetData(const Tizen::Base::ByteBuffer* pData)
+_CameraEventArg::SetData(Tizen::Base::ByteBuffer* pData)
 {
        if (pData != null)
        {
-               __pCameraData = new (std::nothrow) ByteBuffer();
-               SysTryReturn(NID_MEDIA, __pCameraData !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
-               __pCameraData->Construct(*pData); //shallow copy
+               __pCameraData.reset(pData);
        }
 }
 
 Tizen::Base::ByteBuffer*
 _CameraEventArg::GetData(void) const
 {
-       return __pCameraData;
+       return __pCameraData.get();
 }
 
 result
index 5b3d6db..53e5894 100755 (executable)
@@ -25,6 +25,7 @@
 #ifndef _FMEDIA_INTERNAL_CAMERA_EVENTARG_H_
 #define _FMEDIA_INTERNAL_CAMERA_EVENTARG_H_
 
+#include <unique_ptr.h>
 #include <FBaseByteBuffer.h>
 #include <FBaseRtIEventArg.h>
 #include <FMediaCameraTypes.h>
@@ -91,7 +92,7 @@ public:
        /**
        *       Set the data provided by the Camera
        */
-       void SetData(const Tizen::Base::ByteBuffer* data);
+       void SetData(Tizen::Base::ByteBuffer* data);
 
        /**
         *      Get the result.
@@ -124,7 +125,7 @@ private:
 
        _CameraEventType __cameraEventType;
 
-       Tizen::Base::ByteBuffer* __pCameraData;
+       std::unique_ptr <Tizen::Base::ByteBuffer> __pCameraData;
        result __result;
        CameraErrorReason __error;
 };
index cb44190..5ceb625 100755 (executable)
@@ -2158,25 +2158,25 @@ result
 _CameraImpl::EnqueueData(_CameraBuffer& cameraBuffer)
 {
        result r = E_SUCCESS;
-       _CameraBuffer* pCameraBuffer = null;
        _CameraBufferType bufferType = cameraBuffer.GetBufferType();
+       SysTryReturn(NID_MEDIA, cameraBuffer.GetLimit() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
 
-       SysTryCatch(NID_MEDIA, cameraBuffer.GetLimit() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
-
-       pCameraBuffer = new (std::nothrow) _CameraBuffer();
-       SysTryCatch(NID_MEDIA, pCameraBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       std::unique_ptr <_CameraBuffer> pCameraBuffer (new (std::nothrow) _CameraBuffer());
+       SysTryReturn(NID_MEDIA, pCameraBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        r = pCameraBuffer->Construct(cameraBuffer);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
 
        switch (bufferType)
        {
        case _CAMERA_BUFFER_CAPTURE:
-               r = __pCaptureBufferQueue->Enqueue(*pCameraBuffer);
+               r = __pCaptureBufferQueue->Enqueue(*pCameraBuffer.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
                break;
 
        case _CAMERA_BUFFER_PREVIEW:
-               r = __pPreviewBufferQueue->Enqueue(*pCameraBuffer);
+               r = __pPreviewBufferQueue->Enqueue(*pCameraBuffer.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
                break;
 
        default:
@@ -2184,16 +2184,8 @@ _CameraImpl::EnqueueData(_CameraBuffer& cameraBuffer)
                SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(bufferType) is used. bufferType=%d.", bufferType);
                break;
        }
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
-
-       return r;
-
-CATCH:
-       if (pCameraBuffer != null)
-       {
-               delete pCameraBuffer;
-       }
 
+       pCameraBuffer.release();
        return r;
 }
 
@@ -2761,7 +2753,6 @@ result
 _CameraImpl::LoadDefaultConfiguration(int reload)
 {
        result r = E_SUCCESS;
-       Object* pObj = null;
        SysLog(NID_MEDIA, "Enter.");
 
        // Preview resolution
@@ -2772,14 +2763,11 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
                Dimension* pDim = null;
 
                operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_RESOLUTION : _COP_SECONDARY_PREVIEW_RESOLUTION);
-               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
-               SysTryCatch(NID_MEDIA, itemType == _RESULT_DIMENSION, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
-               pDim = dynamic_cast<Dimension*>(pObj);
-               SysTryCatch(NID_MEDIA, pDim != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. preview resolution.");
+               std::unique_ptr <Object> pObj (_CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType));
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_DIMENSION, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pDim = dynamic_cast<Dimension*>(pObj.get());
+               SysTryReturn(NID_MEDIA, pDim != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The preview resolution is wrong.");
                __deviceDefaultPreviewResolution = *pDim;
-               delete pObj;
-               pObj = null;
-
                __previewResolution = __deviceDefaultPreviewResolution;
        }
 
@@ -2791,14 +2779,11 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
                Dimension* pDim = null;
 
                operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_RESOLUTION : _COP_SECONDARY_CAPTURE_RESOLUTION);
-               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
-               SysTryCatch(NID_MEDIA, itemType == _RESULT_DIMENSION, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
-               pDim = dynamic_cast<Dimension*>(pObj);
-               SysTryCatch(NID_MEDIA, pDim != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. capture resolution.");
+               std::unique_ptr <Object> pObj (_CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType));
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_DIMENSION, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pDim = dynamic_cast<Dimension*>(pObj.get());
+               SysTryReturn(NID_MEDIA, pDim != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The capture resolution is wrong.");
                __deviceDefaultCaptureResolution = *pDim;
-               delete pObj;
-               pObj = null;
-
                __captureResolution = __deviceDefaultCaptureResolution;
        }
 
@@ -2810,14 +2795,11 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
                Integer *pInteger = null;
 
                operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_PREVIEW_FORMAT : _COP_SECONDARY_PREVIEW_FORMAT);
-               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
-               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
-               pInteger = dynamic_cast<Integer*>(pObj);
-               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. preview format.");
+               std::unique_ptr <Object> pObj (_CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType));
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_INTEGER, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj.get());
+               SysTryReturn(NID_MEDIA, pInteger != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The preview format is wrong.");
                __deviceDefaultPreviewFormat = (Tizen::Graphics::PixelFormat)pInteger->ToInt();
-               delete pObj;
-               pObj = null;
-
                __previewFormat = __deviceDefaultPreviewFormat;
        }
 
@@ -2829,14 +2811,11 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
                Integer *pInteger = null;
 
                operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_CAPTURE_FORMAT : _COP_SECONDARY_CAPTURE_FORMAT);
-               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
-               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
-               pInteger = dynamic_cast<Integer*>(pObj);
-               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The item is wrong. capture format.");
+               std::unique_ptr <Object> pObj (_CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType));
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_INTEGER, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj.get());
+               SysTryReturn(NID_MEDIA, pInteger != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The capture format is wrong.");
                __deviceDefaultCaptureFormat = (Tizen::Graphics::PixelFormat)pInteger->ToInt();
-               delete pObj;
-               pObj = null;
-
                __captureFormat = __deviceDefaultCaptureFormat;
        }
 
@@ -2867,13 +2846,11 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
                Integer *pInteger = null;
 
                operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_ZERO_SHUTTER_LAG: _COP_SECONDARY_ZERO_SHUTTER_LAG);
-               pObj = _CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType);
-               SysTryCatch(NID_MEDIA, itemType == _RESULT_INTEGER, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The type is wrong. itemType:%d", itemType);
-               pInteger = dynamic_cast<Integer*>(pObj);
-               SysTryCatch(NID_MEDIA, pInteger != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The item is wrong. Zero shutter lag.");
+               std::unique_ptr <Object> pObj (_CameraCapability::GetValueN(operation, _QUERY_DEFAULT_VALUE, itemType));
+               SysTryReturn(NID_MEDIA, itemType == _RESULT_INTEGER, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The type is wrong. itemType:%d", itemType);
+               pInteger = dynamic_cast<Integer*>(pObj.get());
+               SysTryReturn(NID_MEDIA, pInteger != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The zero shutter lag value is wrong.");
                __zeroShutterLag = (bool)pInteger->ToInt();
-               delete pObj;
-               pObj = null;
        }
 
        //Metering mode
@@ -2896,13 +2873,6 @@ _CameraImpl::LoadDefaultConfiguration(int reload)
        }
 
        return r;
-
-CATCH:
-       if (pObj != null)
-       {
-               delete pObj;
-       }
-       return r;
 }
 
 result
@@ -3054,8 +3024,8 @@ void
 _CameraImpl::StateChangedCb(camera_state_e previous, camera_state_e current, bool byPolicy, void *pUserData)
 {
        _CameraImpl* pImpl = static_cast<_CameraImpl*>( pUserData);
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[%s] _CameraImpl instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[%s] _CameraImpl instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
        SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
 }
 
@@ -3066,9 +3036,9 @@ _CameraImpl::CaptureCb(camera_image_data_s* pImage, camera_image_data_s *pPostvi
        _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
        MediaPixelFormat format = MEDIA_PIXEL_FORMAT_NONE;
        double ratio = 0.0;
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl is null.");
-       SysTryReturn(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, , E_INVALID_STATE, "[E_INVALID_STATE] The camera is already capturing");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, E_INVALID_STATE, "[E_INVALID_STATE] The camera is already capturing");
        SysTryCatch(NID_MEDIA, pImage != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] image is null.");
        SysLog(NID_MEDIA, "Enter. image size:%d, format:%d", pImage->size, pImage->format);
 
@@ -3114,46 +3084,36 @@ void
 _CameraImpl::CaptureCompletedCb(void *pUserData)
 {
        result r = E_SUCCESS;
-       ByteBuffer* pBuffer = null;
        _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
        SysLog(NID_MEDIA, "CaptureCompletedCb");
 
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
-//     SysTryReturn(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, , E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. The camera is already power-offed");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
 
-       pBuffer = pImpl->DequeueDataN(_CAMERA_BUFFER_CAPTURE);
-       if (pBuffer != null)
+       std::unique_ptr <ByteBuffer> pBuffer (pImpl->DequeueDataN(_CAMERA_BUFFER_CAPTURE));
+       if (pBuffer.get() != null)
        {
                SysLog(NID_MEDIA, "Captured data sending. size is %d", pBuffer->GetLimit());
                if (pBuffer->GetLimit() > 0)
                {
-                       r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_NONE, E_SUCCESS, pBuffer);
-                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_NONE, E_SUCCESS, pBuffer.release());
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else
                {
                        SysLogException(NID_MEDIA, E_INVALID_DATA, "[E_INVALID_DATA] The captured data is invalid.");
-                       r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_DEVICE_FAILED, E_INVALID_DATA, pBuffer);
-                       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_DEVICE_FAILED, E_INVALID_DATA, pBuffer.release());
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
-               delete pBuffer;
-               pBuffer = null;
        }
        else
        {
                SysLogException(NID_MEDIA, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Out of memory for capturing anymore.");
                r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_CAPTURED, CAMERA_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, null);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        return;
-CATCH:
-       if (pBuffer != null)
-       {
-               delete pBuffer;
-       }
-       return;
 }
 
 void
@@ -3163,9 +3123,9 @@ _CameraImpl::PreviewCb(camera_preview_data_s *pFrame, void *pUserData)
        int queueCount = 0;
        _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
 
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
-       SysTryReturn(NID_MEDIA, pFrame != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] camera_preview_data_s instance is not available.");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturnVoidResult(NID_MEDIA, pFrame != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] camera_preview_data_s instance is not available.");
        SysLog(NID_MEDIA, "Enter. preview format:%d, width:%d, height:%d, num_of_planes:%d", pFrame->format, pFrame->width, pFrame->height, pFrame->num_of_planes);
 
        queueCount = pImpl->__pPreviewBufferQueue->GetCount();
@@ -3289,12 +3249,8 @@ CATCH:
        SysLogException(NID_MEDIA, E_INVALID_DATA, "[E_INVALID_DATA] Invalid data is streamed..");
        if (queueCount < pImpl->__pPreviewBufferQueue->GetCount())        // if the queue is increased.
        {
-               ByteBuffer* pBuffer = null;
-               pBuffer = pImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW);
-               if (pBuffer)
-               {
-                       delete pBuffer;
-               }
+               std::unique_ptr <ByteBuffer> pBuffer (pImpl->DequeueDataN(_CAMERA_BUFFER_PREVIEW));
+               pBuffer.reset(null);
        }
        return;
 }
@@ -3305,9 +3261,9 @@ _CameraImpl::InterruptedCb(camera_policy_e policy, camera_state_e previous, came
        result r = E_SUCCESS;
        _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
        SysLog(NID_MEDIA, "InterruptedCb called, policy is %d, previous state is %d, current state is %d, pUserData address is %x  ", policy, previous, current, pUserData );
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
-       SysTryReturn(NID_MEDIA, pImpl->IsPoweredOn() == true, , E_INVALID_OPERATION  ,"The camera is already power-offed");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl->IsPoweredOn() == true, E_INVALID_OPERATION  ,"The camera is already power-offed");
        r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_ERROR, CAMERA_ERROR_DEVICE_INTERRUPTED, E_DEVICE_FAILED, null);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Sending camera interrupted failed [%s] .", GetErrorMessage(r));
 CATCH:
@@ -3320,8 +3276,8 @@ _CameraImpl::ErrorCb(camera_error_e error, camera_state_e current, void *pUserDa
        result r = E_SUCCESS;
        _CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
        SysLog(NID_MEDIA, "ErrorCb called, error is 0x%x, current state is %d, pUserData address is %x  ", error, current, pUserData );
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
        switch (error)
        {
        case ::CAMERA_ERROR_OUT_OF_MEMORY:
@@ -3351,8 +3307,8 @@ _CameraImpl::FocusStateChangedCb(camera_focus_state_e state, void *pUserData)
        CameraErrorReason cameraErrorReason = CAMERA_ERROR_NONE;
        result cameraResult = E_SUCCESS;
        SysLog(NID_MEDIA, "Enter. state is %d.", state);
-       SysTryReturn(NID_MEDIA, _CameraImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+       SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
 
        CameraFocusMode focusMode = pImpl->GetFocusMode();
 
index e9fd070..d3be88a 100755 (executable)
  *
  */
 
+#include <unique_ptr.h>
 #include <pthread.h>
 #include <camera.h>
 #include <FBaseSysLog.h>
 #include "FMedia_CameraManager.h"
+#include "FMedia_CameraManager.h"
+#include "FMedia_CamPtrUtil.h"
 
 #define MM_SUCCESS 0
 
@@ -48,12 +51,11 @@ _CameraManagerSafeHashMapT::~_CameraManagerSafeHashMapT(void)
 void
 _CameraManagerSafeHashMapT::RemoveItems(void)
 {
-       IListT <_CameraDeviceType>* pList = null;
        _CameraManager* pManager = null;
        result r = E_SUCCESS;
 
-       pList = GetKeysN();
-       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+       std::unique_ptr <IListT<_CameraDeviceType>, _ListPtrUtil::Remover > pList (GetKeysN(), _ListPtrUtil::remover);
+       SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
 
        for (int i = 0; i < GetCount(); i++)
        {
@@ -71,8 +73,6 @@ _CameraManagerSafeHashMapT::RemoveItems(void)
                }
                delete pManager;
        }
-       pList->RemoveAll();
-       delete pList;
        RemoveAll();
 }
 
@@ -131,49 +131,41 @@ _CameraManager::AddInstance(_CameraDeviceType cameraDevice)
 {
        result r = E_SUCCESS;
        bool out = false;
-
        _CameraManager* pManager = null;
-
        SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
                                null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(cameraDevice) is used. camderDevice:%d is wrong.", cameraDevice);
 
        static pthread_once_t once_block = PTHREAD_ONCE_INIT;
-
        if (!__pMap)
        {
                pthread_once(&once_block, InitSafeHashMapInst);
                r = GetLastResult();
-               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        r = __pMap->ContainsKey(cameraDevice, out);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (out)
        {
                r = __pMap->GetValue(cameraDevice, pManager);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pManager != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS && pManager != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        else
        {
-               pManager = new (std::nothrow) _CameraManager();
-               SysTryCatch(NID_MEDIA, pManager !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+               std::unique_ptr <_CameraManager> pMan (new (std::nothrow) _CameraManager());
+               SysTryReturn(NID_MEDIA, pMan.get() !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+
+               r = pMan->Construct(cameraDevice);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = pManager->Construct(cameraDevice);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = __pMap->Add(cameraDevice, pMan.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = __pMap->Add(cameraDevice, pManager);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               pManager = pMan.release();
        }
 
        return pManager;
-
-CATCH:
-       if (pManager != null)
-       {
-               delete pManager;
-       }
-       return null;
 }
 
 void
@@ -185,13 +177,13 @@ _CameraManager::Release(_CameraDeviceType cameraDevice)
        {
                _CameraManager* pManager = null;
                r = __pMap->GetValue(cameraDevice, pManager);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                if (pManager->ReleaseRefCount() == 0)
                {
                        delete pManager;
                        r = __pMap->Remove(cameraDevice);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
 }
index f33f7da..4a7ee23 100755 (executable)
@@ -43,6 +43,15 @@ class _CameraManager
 {
 public:
        /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_CameraManager(void);
+
+       /**
        * Get the instance of _CameraManager.
        *
        * @return               The _CameraManager instance
@@ -80,15 +89,6 @@ private:
        _CameraManager(void);
 
        /**
-        * This is the destructor for this class. @n
-        * All allocated resources are deallocated by this method. This method should be called in the same thread
-        * where the Construct() method is called.
-        *
-        * @see                 Construct()
-        */
-       virtual ~_CameraManager(void);
-
-       /**
        * Initializes this instance of _CameraManager.
        *
        * @return               An error code
index 26715b7..f9227e2 100755 (executable)
@@ -107,11 +107,6 @@ _CapabilityImpl::_CapabilityImpl(void)
 
 _CapabilityImpl::~_CapabilityImpl(void)
 {
-       if (__pMap != null)
-       {
-               __pMap->RemoveAll(true);
-               delete __pMap;
-       }
 }
 
 result
@@ -120,72 +115,62 @@ _CapabilityImpl::Construct(void)
        result r = E_SUCCESS;
        long long length = 0;
        int readLen = 0;
-       std::unique_ptr<char[]> pXmlBuffer;
        FileAttributes attributes;
        File fileObj;
        const String mediaCapabilityFilePath(L"/usr/etc/media-capability.xml");
        SysLog(NID_MEDIA, "Enter ");
 
-       __pMap = new (std::nothrow) HashMap();
-       SysTryCatch(NID_MEDIA, null != __pMap, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
+       std::unique_ptr <HashMap> pMap (new (std::nothrow) HashMap(SingleObjectDeleter));
+
+       pMap.reset(new (std::nothrow) HashMap(SingleObjectDeleter));
+       SysTryReturn(NID_MEDIA, null != pMap.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
+
+       r = pMap->Construct();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = __pMap->Construct();
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       __pMap.reset(pMap.release());
 
        SysLog(NID_MEDIA, "Capability XML path:%ls", mediaCapabilityFilePath.GetPointer());
 
        r = File::GetAttributes( mediaCapabilityFilePath, attributes);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. File path is %ls", GetErrorMessage(r), mediaCapabilityFilePath.GetPointer());
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. File path is %ls", GetErrorMessage(r), mediaCapabilityFilePath.GetPointer());
 
        length = attributes.GetFileSize();
-       SysTryCatch(NID_MEDIA, length > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
+       SysTryReturn(NID_MEDIA, length > 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
 
-       pXmlBuffer.reset(new (std::nothrow) char[length]);
-       SysTryCatch(NID_MEDIA, null != pXmlBuffer.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
+       std::unique_ptr<char[]> pXmlBuffer (new (std::nothrow) char[length]);
+       SysTryReturn(NID_MEDIA, null != pXmlBuffer.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. ");
 
        r = fileObj.Construct(mediaCapabilityFilePath, L"r");
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
 //     read the capability xml file content as parse the capability
        readLen = fileObj.Read(pXmlBuffer.get(), length);
-       SysTryCatch(NID_MEDIA, readLen == length, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating. length:%d, readLen:%d", length,
+       SysTryReturn(NID_MEDIA, readLen == length, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating. length:%d, readLen:%d", length,
                           readLen);
 
 //     parse the capability file buffer all the parse key value pair shall be added in __pMap object
        r = ParseCapability(pXmlBuffer.get(), readLen);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        //      Get the camera count
-       {
-               int cameraCount = 0;
-               bool flag = false;
-
-               r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.back", flag);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-               if (flag)
-               {
-                       cameraCount++;
-               }
+       int cameraCount = 0;
+       bool flag = false;
 
-               r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.front", flag);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-               if (flag)
-               {
-                       cameraCount++;
-               }
-               __cameraCount = cameraCount;
+       r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.back", flag);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       if (flag)
+       {
+               cameraCount++;
        }
-       return E_SUCCESS;
-
-CATCH:
-       SysLog(NID_MEDIA, "[%s]", GetErrorMessage(r));
 
-       if (__pMap != null)
+       r = _SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/camera.front", flag);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       if (flag)
        {
-               __pMap->RemoveAll(true);
-               delete __pMap;
-               __pMap = 0;
+               cameraCount++;
        }
+       __cameraCount = cameraCount;
        return r;
 }
 
@@ -1025,10 +1010,10 @@ _CapabilityImpl::ParseSection(xmlNode* pRoot, const String& section)
                                                {
                                                        String* pKey = null;
                                                        pKey = new (std::nothrow) Tizen::Base::String(key);
-                                                       SysTryReturn(NID_MEDIA, pKey !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
+                                                       SysTryReturnVoidResult(NID_MEDIA, pKey !=null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The key is not created.");
 
                                                        r = __pMap->Add(*pKey, *pRet);
-                                                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                                                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                                                }
                                                break;
                                        }
index 514888e..8fa3603 100755 (executable)
@@ -36,11 +36,6 @@ _RecorderEventArg::_RecorderEventArg(void)
 
 _RecorderEventArg::~_RecorderEventArg(void)
 {
-       if (__pRecordedData != null)
-       {
-               delete (Tizen::Base::ByteBuffer*) __pRecordedData;
-               __pRecordedData = null;
-       }
 }
 
 void
@@ -58,13 +53,13 @@ _RecorderEventArg::GetEventType(void) const
 void
 _RecorderEventArg::SetData(Tizen::Base::ByteBuffer* data)
 {
-       __pRecordedData = data;
+       __pRecordedData.reset(data);
 }
 
 Tizen::Base::ByteBuffer*
 _RecorderEventArg::GetData(void) const
 {
-       return __pRecordedData;
+       return __pRecordedData.get();
 }
 
 result
index e3d2081..f6524a0 100755 (executable)
@@ -23,7 +23,7 @@
 #ifndef _FMEDIA_INTERNAL_EVENTARG_H_
 #define _FMEDIA_INTERNAL_EVENTARG_H_
 
-
+#include <unique_ptr.h>
 #include <FBaseObject.h>
 #include <FBaseRtIEventArg.h>
 #include <FBaseByteBuffer.h>
@@ -106,7 +106,7 @@ private:
        _RecorderEventArg& operator =(const _RecorderEventArg& value);
 
        _RecorderEventType __recorderEventType;
-       Tizen::Base::ByteBuffer* __pRecordedData;
+       std::unique_ptr <Tizen::Base::ByteBuffer> __pRecordedData;
        result __result;
        RecorderErrorReason __error;
 };
index dfe67fd..3048f21 100755 (executable)
@@ -21,6 +21,7 @@
  *
  */
 
+#include <unique_ptr.h>
 #include <pthread.h>
 #include <recorder.h>
 #include <FBaseSysLog.h>
@@ -54,7 +55,7 @@ _RecorderManagerSafeHashMapT::RemoveItems(void)
        result r = E_SUCCESS;
 
        pList = GetKeysN();
-       SysTryReturn(NID_MEDIA, pList != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
+       SysTryReturnVoidResult(NID_MEDIA, pList != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] There is no instance.");
 
        for (int i = 0; i < GetCount(); i++)
        {
@@ -163,16 +164,16 @@ _RecorderManager::AddInstance(_RecorderDeviceType recorderDevice)
        {
                pthread_once(&once_block, InitSafeHashMapInst);
                r = GetLastResult();
-               SysTryCatch(NID_MEDIA, __pMap != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
        r = __pMap->ContainsKey(recorderDevice, out);
-       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (out)
        {
                r = __pMap->GetValue(recorderDevice, pManager);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS && pManager != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS && pManager != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
        }
        else
        {
@@ -189,25 +190,20 @@ _RecorderManager::AddInstance(_RecorderDeviceType recorderDevice)
                        break;
                }
 
-               pManager = new (std::nothrow) _RecorderManager();
-               SysTryCatch(NID_MEDIA, pManager !=null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The object is not created.");
+               std::unique_ptr <_RecorderManager> pMan (new (std::nothrow) _RecorderManager());
+               SysTryReturn(NID_MEDIA, pMan.get() !=null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The object is not created.");
 
-               r = pManager->Construct(cameraDevice, recorderDevice);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = pMan->Construct(cameraDevice, recorderDevice);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
-               r = __pMap->Add(recorderDevice, pManager);
-               SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               r = __pMap->Add(recorderDevice, pMan.get());
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+               pManager = pMan.release();
        }
 
        pManager->AddRefCount();
        return pManager;
-
-CATCH:
-       if (pManager != null)
-       {
-               delete pManager;
-       }
-       return null;
 }
 
 void
@@ -219,13 +215,13 @@ _RecorderManager::Release(_RecorderDeviceType recorderDevice)
        {
                _RecorderManager* pManager = null;
                r = __pMap->GetValue(recorderDevice, pManager);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
 
                if (pManager->ReleaseRefCount() == 0)
                {
                        delete pManager;
                        r = __pMap->Remove(recorderDevice);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
 }
index c7432bc..f4cf148 100755 (executable)
@@ -43,6 +43,15 @@ class _RecorderManager
 {
 public:
        /**
+        * This is the destructor for this class. @n
+        * All allocated resources are deallocated by this method. This method should be called in the same thread
+        * where the Construct() method is called.
+        *
+        * @see                 Construct()
+        */
+       virtual ~_RecorderManager(void);
+
+       /**
        * Get the instance of _RecorderManager.
        *
        * @return               The _RecorderManager instance
@@ -80,15 +89,6 @@ private:
        _RecorderManager(void);
 
        /**
-        * This is the destructor for this class. @n
-        * All allocated resources are deallocated by this method. This method should be called in the same thread
-        * where the Construct() method is called.
-        *
-        * @see                 Construct()
-        */
-       virtual ~_RecorderManager(void);
-
-       /**
        * Initializes this instance of _RecorderManager.
        *
        * @return               An error code
index ae5de1b..ade40c1 100755 (executable)
@@ -60,7 +60,7 @@ _VideoFrameImpl::Initialize(MediaPixelFormat format, int width, int height, int
        {
                { VIDEO_PLANE_TYPE_Y, MEDIA_PIXEL_FORMAT_YUV420P, 1 },
                { VIDEO_PLANE_TYPE_Y, MEDIA_PIXEL_FORMAT_NV12, 1 },
-               { VIDEO_PLANE_TYPE_Y, MEDIA_PIXEL_FORMAT_NV21, 1 },     
+               { VIDEO_PLANE_TYPE_Y, MEDIA_PIXEL_FORMAT_NV21, 1 },
                { VIDEO_PLANE_TYPE_Y, MEDIA_PIXEL_FORMAT_YUV444P, 1 },
 
                { VIDEO_PLANE_TYPE_U, MEDIA_PIXEL_FORMAT_YUV420P, 0.5 },
index 928aa24..718dfba 100755 (executable)
@@ -72,11 +72,11 @@ void
 _VideoRecorderEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
 {
        IVideoRecorderEventListener* pVideoRecorderEventListener = dynamic_cast <IVideoRecorderEventListener*>(&listener);
-       SysTryReturn(NID_MEDIA, pVideoRecorderEventListener != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pVideoRecorderEventListener != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Listener is null.");
 
        Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <Tizen::Base::Runtime::IEventArg*>(&arg);
        _RecorderEventArg* pArg = dynamic_cast <_RecorderEventArg*>(pTempArg);
-       SysTryReturn(NID_MEDIA, pArg != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pArg != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  EventArg is null.");
 
        switch (pArg->GetEventType())
        {
index 2a2b52a..dd51612 100755 (executable)
@@ -176,16 +176,6 @@ _VideoRecorderImpl::~_VideoRecorderImpl(void)
                _CameraCoordinator::Release(__deviceType);
        }
 
-       if (__pVideoSourceAdapter != null)
-       {
-               delete __pVideoSourceAdapter;
-       }
-
-       if (__pVideoRecorderEvent != null)
-       {
-               delete __pVideoRecorderEvent;
-       }
-
        if ( __isConstructed )
        {
                __isUsed = false;
@@ -213,12 +203,12 @@ _VideoRecorderImpl::Construct(IVideoRecorderEventListener& listener, const Camer
        pCamImpl = _CameraImpl::GetInstance(pCamera);
 
        // Source Adapter
-       __pVideoSourceAdapter = new (std::nothrow) _VideoSourceAdapter(*pCamImpl);
-       SysTryCatch(NID_MEDIA, __pVideoSourceAdapter != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       __pVideoSourceAdapter.reset(new (std::nothrow) _VideoSourceAdapter(*pCamImpl));
+       SysTryCatch(NID_MEDIA, __pVideoSourceAdapter.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        // Create Event
-       __pVideoRecorderEvent = new (std::nothrow) _VideoRecorderEvent();
-       SysTryCatch(NID_MEDIA, __pVideoRecorderEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
+       __pVideoRecorderEvent.reset(new (std::nothrow) _VideoRecorderEvent());
+       SysTryCatch(NID_MEDIA, __pVideoRecorderEvent.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.  The object is not created.");
 
        r = __pVideoRecorderEvent->Construct(*this);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
@@ -312,24 +302,6 @@ CATCH:
                __pCoordinator->RemoveCameraCoordinatorListener(*this);
        }
 
-       if (__pVideoSourceAdapter != null)
-       {
-               delete __pVideoSourceAdapter;
-               __pVideoSourceAdapter = null;
-       }
-
-       if (__pVideoRecorderEventListener != null)
-       {
-               __pVideoRecorderEvent->RemoveListener(*__pVideoRecorderEventListener);
-               __pVideoRecorderEventListener = null;
-       }
-
-       if (__pVideoRecorderEvent != null)
-       {
-               delete __pVideoRecorderEvent;
-               __pVideoRecorderEvent = null;
-       }
-
        return r;
 }
 
@@ -1063,7 +1035,7 @@ _VideoRecorderImpl::GetRecordingResolution(void) const
 Tizen::Base::Collection::IList*
 _VideoRecorderImpl::GetSupportedRecordingResolutionListN(void) const
 {
-       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter.get() != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
 
        return __pVideoSourceAdapter->GetSupportedRecordingResolutionListN();
 }
@@ -1074,7 +1046,7 @@ _VideoRecorderImpl::GetSupportedMaxFrameRate(const Tizen::Graphics::Dimension& d
        result r = E_SUCCESS;
        int maxFrameRate = 0;
 
-       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter != null, 0, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
+       SysTryReturn(NID_MEDIA, __pVideoSourceAdapter.get() != null, 0, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  The source is deleted.");
 
        std::unique_ptr<IListT<int>, _ListPtrUtil::Remover> pListT (__pVideoSourceAdapter->GetSupportedFrameRateListN(dim), _ListPtrUtil::remover);
        SysTryCatch(NID_MEDIA, pListT.get() != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred.  Supported list was wrong.");
@@ -1328,8 +1300,8 @@ _VideoRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e c
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>( pUserData);
        int tableTotalCount = 0;
        int i = 0;
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
        SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
 
        tableTotalCount = sizeof(_VIDEO_CALLBACK_EVENT) / sizeof(_VIDEO_CALLBACK_EVENT[0]);
@@ -1340,7 +1312,7 @@ _VideoRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e c
                {
                        r = pImpl->GetEvent()->SendEvent(_VIDEO_CALLBACK_EVENT[i].event, _VIDEO_CALLBACK_EVENT[i].error, E_SUCCESS);
                        SysLog(NID_MEDIA, "VIDEO_CALLBACK_EVENT(%d) is sent by StateChangedCb", _VIDEO_CALLBACK_EVENT[i].event);
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
+                       SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
                        break;
                }
        }
@@ -1350,8 +1322,8 @@ void
 _VideoRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
 {
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
 
        SysLog(NID_MEDIA, "FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
 
@@ -1364,9 +1336,9 @@ _VideoRecorderImpl::AudioStreamCb(void* pStream, int size, audio_sample_type_e f
 {
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
        int samplingRate =0;
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. Impl is null.");
-       SysTryReturn(NID_MEDIA, pStream != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] void instance is not available. pStream is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. Impl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, pStream != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] void instance is not available. pStream is null.");
 
        if (pImpl->__audioStreamCallback == true)
        {
@@ -1380,8 +1352,8 @@ _VideoRecorderImpl::LimitReachedCb(recorder_recording_limit_type_e type, void *p
 {
        result r = E_SUCCESS;
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
 
        SysLog(NID_MEDIA, "Type:%d", type);
 
@@ -1415,8 +1387,8 @@ _VideoRecorderImpl::ErrorCb(recorder_error_e error, recorder_state_e state, void
 {
        result r = E_SUCCESS;
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
        SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
 
        _CameraCoordinator* __pCoordinator = null;
@@ -1440,8 +1412,8 @@ void
 _VideoRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
 {
        _VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
-       SysTryReturn(NID_MEDIA, _VideoRecorderImpl::IsAlive(), , E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
-       SysTryReturn(NID_MEDIA, pImpl != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+       SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+       SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
 
        SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
 }
@@ -1449,7 +1421,7 @@ _VideoRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e pre
 _VideoRecorderEvent*
 _VideoRecorderImpl::GetEvent(void) const
 {
-       return __pVideoRecorderEvent;
+       return __pVideoRecorderEvent.get();
 }
 
 void
index 073ae5c..2c6270d 100755 (executable)
@@ -56,7 +56,7 @@ public:
        /**
         * This is the default constructor for this class.
         *
-        * @remarks     The object is not fully constructed after this constructor is called. For full construction, 
+        * @remarks     The object is not fully constructed after this constructor is called. For full construction,
         * the Construct() method must be called right after calling this constructor.
         * @see  Construct()
         */
@@ -843,9 +843,9 @@ private:
        _VideoRecorderImpl& operator =(const _VideoRecorderImpl& _VideoRecorderImpl);
 
        _CameraCoordinator* __pCoordinator;
-       _VideoRecorderEvent* __pVideoRecorderEvent;
+       std::unique_ptr <_VideoRecorderEvent> __pVideoRecorderEvent;
        IVideoRecorderEventListener* __pVideoRecorderEventListener;
-       _VideoSourceAdapter* __pVideoSourceAdapter;
+       std::unique_ptr <_VideoSourceAdapter> __pVideoSourceAdapter;
        bool __isConstructed;
        RecorderState __state;
        long __recTime;
index 029ca0f..23ceba6 100755 (executable)
@@ -25,6 +25,7 @@
 #ifndef _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
 #define _FMEDIA_INTERNAL_CAPABILITY_IMPL_H_
 
+#include <unique_ptr.h>
 #include <libxml/tree.h>
 #include <FBaseColIList.h>
 #include <FBaseColHashMap.h>
@@ -354,7 +355,7 @@ private:
 
        static void InitCapabilityImpl(void);
 
-       Tizen::Base::Collection::HashMap* __pMap;
+       std::unique_ptr <Tizen::Base::Collection::HashMap> __pMap;
        int __cameraCount;
        bool __primaryCameraDone;
        bool __secondaryCameraDone;