_ImageImpl::_ImageImpl(void)
{
+ __pUrlReqIDList.reset(null);
}
_ImageImpl::~_ImageImpl(void)
{
+ _ImageUriDataFactory *pFactory = null;
+
+ pFactory = _ImageUriDataFactory::GetInstance();
+ SysTryReturn(NID_MEDIA, pFactory != null, , GetLastResult(), "[%s] Failed to get Factory instance.",
+ GetErrorMessage(GetLastResult()));
+
+ if (__pUrlReqIDList.get() != null)
+ {
+ int num = 0;
+ Object* pObj = null;
+
+ // free the memory
+ num = __pUrlReqIDList->GetCount();
+ for (int i = 0; i < num; i++)
+ {
+ pObj = __pUrlReqIDList->GetAt(i);
+ if (pObj != null)
+ {
+ Integer *pValue = dynamic_cast<Integer*>(pObj);
+ RequestId reqId = (RequestId)(pValue->ToInt());
+
+ pFactory->Remove(reqId);
+ }
+ }
+ __pUrlReqIDList->RemoveAll(true);
+ }
}
_ImageImpl*
r = pFactory->DecodeUrl(srcImageUrl, colorFormat, destWidth,destHeight, reqId, listener, timeout);
SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r,"[%s] Propagated.", GetErrorMessage(r));
+ if (__pUrlReqIDList.get() == null)
+ {
+ __pUrlReqIDList.reset(new (std::nothrow)Collection::LinkedList());
+ SysTryCatch(NID_MEDIA, __pUrlReqIDList.get() != null, r = E_OUT_OF_MEMORY, r,
+ "[E_OUT_OF_MEMORY] Propagated. Failed to allocate a LinkedList.", GetErrorMessage(r));
+ }
+ __pUrlReqIDList->Add(new (std::nothrow) Integer(reqId));
+
return r;
CATCH:
Watchout();
}
+void
+_ImageUriDataFactory::Remove(RequestId reqId)
+{
+ Object* pObj = null;
+ int num = 0;
+ bool deleted = false;
+ result r = E_SUCCESS;
+
+ // Remove ImageUriData for this request id from the working list.
+ num = __pImageUriDataWorkingList->GetCount();
+ for (int i = 0; i < num; i++)
+ {
+ pObj = __pImageUriDataWorkingList->GetAt(i);
+ if (pObj != null)
+ {
+ _ImageUriData* pImageUriData = dynamic_cast<_ImageUriData*>(pObj);
+ if (pImageUriData != null)
+ {
+ if (reqId == pImageUriData->GetRequestId())
+ {
+ pImageUriData->Cancel(reqId, r);
+ __pImageUriDataWorkingList->RemoveAt(i, true);
+ deleted = true;
+ break;
+ }
+ }
+ }
+ }
+
+ // If ImageUriData for this request id is not present in working list,
+ // remove it from the holder queue.
+ if (deleted != true)
+ {
+ num = __pImageUriDataHolderQueue->GetCount();
+ for (int i = 0; i < num; i++)
+ {
+ // Dequeue elements one by one to check for reqId.
+ pObj = __pImageUriDataHolderQueue->Dequeue();
+ if (pObj != null)
+ {
+ _ImageUriData* pImageUriData = dynamic_cast<_ImageUriData*>(pObj);
+ if (pImageUriData != null)
+ {
+ if (reqId == pImageUriData->GetRequestId())
+ {
+ pImageUriData->Cancel(reqId, r);
+ delete pImageUriData;
+ deleted = true;
+ break;
+ }
+ // if Dequeued data does not have the same reqId, Enqueue is again.
+ __pImageUriDataHolderQueue->Enqueue(*pObj);
+ }
+ }
+ }
+ }
+
+ if(deleted != true)
+ {
+ SysLog(NID_MEDIA, "Could not find ReqId %ld in both queues!!", reqId);
+ }
+}
+
int
_ImageUriDataFactory::GetHolderCount(void)
{
int GetHolderCount(void);
int GetWorkerCount(void);
+ void Remove(RequestId reqId);
void OnMediaSessionEnded(RequestId requestId);
// Tizen::Graphics::Dimension& destDim);
//
+ std::unique_ptr<Tizen::Base::Collection::LinkedList> __pUrlReqIDList;
_ImageImpl(const _ImageImpl& impl);
_ImageImpl& operator =(const _ImageImpl& impl);