コード例 #1
0
srv_ies_result srv_ies_job_cancel(srv_ies_job_handle hJob)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool cancelled;

    IES_LOG_SETUP();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    IES_LOG_BEGIN(SRV_IES_JOB_CANCEL, 1, hJob);    

    kal_trace(MOD_IES, TRACE_GROUP_2, "srv_ies_job_cancel on job %x", hJob);

    cancelled = KAL_FALSE;

    kal_take_mutex(g_srv_ies_hdl_mutex);
    if (hJob != g_srv_ies_curr_job[hJob->jobID])
    {
        g_srv_ies_meta_test[hJob->jobID] = KAL_FALSE;
        cancelled = KAL_TRUE;
    }
    else
    {
        hJob->seqNum = 0;
        g_srv_ies_curr_job[hJob->jobID] = NULL;
    }
    kal_give_mutex(g_srv_ies_hdl_mutex);

    // Send abort request and wait for event
    if (KAL_FALSE == cancelled)
    {
        kal_take_mutex(g_srv_ies_job_mutex);
        hJob->state = SRV_IES_JOB_STATE_CANCELLED;
        kal_give_mutex(g_srv_ies_job_mutex);

        _srv_ies_job_cancel_request(hJob);
        WAIT_IES_TASK_EVENT();

        hJob->state = SRV_IES_JOB_STATE_INVALID;

        kal_take_mutex(g_srv_ies_hdl_mutex);
        TYPED_FREE(hJob, srv_ies_job);
        kal_give_mutex(g_srv_ies_hdl_mutex);
    }

    // We don't care any further results.
    IES_LOG_END(SRV_IES_OK);
    return SRV_IES_OK;
}
コード例 #2
0
srv_ies_result srv_ies_job_query_progress(srv_ies_job_handle    hJob,
                                          U32                   *pProg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job     *pJob;
    CRESULT         result;
    CTuint32        count;
    CTuint32        total;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if((NULL == pProg) || (NULL == hJob))
    {
        return SRV_IES_E_INVALID_ARGS;
    }

    kal_take_mutex(g_srv_ies_hdl_mutex);
    pJob = g_srv_ies_curr_job[hJob->jobID];
    kal_give_mutex(g_srv_ies_hdl_mutex);

    total = 0;

    kal_take_mutex(g_srv_ies_job_mutex);
    if ((pJob != hJob) || (NULL == pJob->pItr))
    {
        *pProg = SRV_IES_JOB_PROGRESS_MAX;
    }
    else
    {
        result = caps_getCurIterationCount(pJob->pItr, &count);
        ASSERT(CERR_OK == result);

        result = caps_estimateIterationCount(pJob->pItr, &total);
        ASSERT(CERR_OK == result);
    }
    kal_give_mutex(g_srv_ies_job_mutex);

    if (0 != total)
    {
       *pProg = (count * SRV_IES_JOB_PROGRESS_MAX) / total;
    }
    else
    {
       *pProg = SRV_IES_JOB_PROGRESS_MAX;
    }

    return SRV_IES_OK;
}
コード例 #3
0
srv_ies_result srv_ies_job_destroy(srv_ies_job_handle hJob)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job_id jobID;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ASSERT(hJob != NULL);

    jobID = hJob->jobID;

    hJob->seqNum = 0;

    ASSERT(KAL_FALSE == g_srv_ies_meta_test[hJob->jobID]);

    hJob->state = SRV_IES_JOB_STATE_INVALID;

    kal_take_mutex(g_srv_ies_hdl_mutex);
    if (hJob == g_srv_ies_curr_job[jobID])
    {
        g_srv_ies_curr_job[jobID] = NULL;
        TYPED_FREE(hJob, srv_ies_job);
    }
    kal_give_mutex(g_srv_ies_hdl_mutex);

    return SRV_IES_OK;
}
コード例 #4
0
srv_ies_job_handle srv_ies_job_create(srv_ies_app_session_handle        hApp,
                                      module_type                       modID,
                                      SRV_IES_JOB_TYPE_ENUM             jobType,
                                      void                              *pOwner,
                                      void                              *pInput,
                                      CTIterator                        *pItr,
                                      void                              *pOutput,
                                      kal_uint32                        maxStep,
                                      srv_ies_async_callback_func_ptr   callback,
                                      void                              *pData)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job *pJob;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_mutex(g_srv_ies_hdl_mutex);
    TYPED_ALLOC(pJob, srv_ies_job);
    g_srv_ies_curr_job[pJob->jobID] = pJob;
    kal_give_mutex(g_srv_ies_hdl_mutex);

    ASSERT(NULL != pJob);

    switch(jobType)
    {
        case SRV_IES_JOB_TYPE_RENDER_PREVIEW:
        case SRV_IES_JOB_TYPE_RENDER_BUFFER:
        case SRV_IES_JOB_TYPE_CREATE_META:
            pJob->pOutput = pOutput;
            break;
        case SRV_IES_JOB_TYPE_RENDER_FILE:
            ASSERT(NULL != pInput);
            mmi_wcsncpy(pJob->filePath, pOutput, SRV_FMGR_PATH_MAX_LEN);
            break;
        default:
            ASSERT(0);
            return NULL;
    }

    LIST_INIT((srv_ies_list_head_struct*)pJob);

    ((srv_ies_job_control*)pOwner)->pCurrJob = pJob;

    pJob->pParent   = hApp;
    pJob->state     = SRV_IES_JOB_STATE_CREATED;
    pJob->modID     = kal_get_active_module_id();
    pJob->jobType   = jobType;
    pJob->seqNum    = srv_ies_job_request_seq_num();
    pJob->pOwner    = pOwner;
    pJob->pItr      = pItr;
    pJob->pInput    = pInput;
    pJob->maxStep   = maxStep;
    pJob->callback  = callback;
    pJob->pData     = pData;

    return pJob;
}
コード例 #5
0
void nvram_util_take_mutex(kal_mutexid ext_mutex_id_ptr)
{
    if (!INT_QueryExceptionStatus() && !kal_query_systemInit() && ext_mutex_id_ptr)
    {
        kal_take_mutex(ext_mutex_id_ptr);
    }
}
コード例 #6
0
static U8 _srv_ies_job_response_handler(void *pMsg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_ilm_job_response        *pResp;
    srv_ies_job                     *pJob;
    SRV_IES_JOB_STATE_ENUM          state;
    srv_ies_result                  result;
    srv_ies_async_callback_func_ptr callback;
    void*                           pData;

    IES_LOG_SETUP();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    IES_LOG_BEGIN(SRV_IES_JOB_HANDLE_RESPONSE, 1, pMsg);

    pResp = (srv_ies_ilm_job_response*)pMsg;
    ASSERT(NULL != pResp);

    pJob  = pResp->pJob;
    ASSERT(NULL != pJob);

    // MAUI_02734511: The race condition for cancelling the jobs.
    // The sequence number is to identify if the job is cancelled.
    // That's because there may be some latency between IES and MMI.
    if (!_srv_ies_job_compare_seq_num(pResp->seqNum, pJob->seqNum))
    {
        IES_LOG_END(0);
        return 0;
    }

    result      = pResp->result;
    callback    = pJob->callback;
    pData       = pJob->pData;

    kal_take_mutex(g_srv_ies_job_mutex);
    state       = pJob->state;
    kal_give_mutex(g_srv_ies_job_mutex);

    if (SRV_IES_JOB_STATE_FINISHED == state)
    {  
       if (callback)
       {
          callback(result, pData);
       }
    }

    if (MMI_TRUE == _srv_ies_job_compare_seq_num(pResp->seqNum, pJob->seqNum))
    {
       srv_ies_job_destroy(pJob);
    }

    IES_LOG_END(0);
    return 0;
}
コード例 #7
0
/*************************************************************************
    Local Functions
 *************************************************************************/
static mmi_ret mmi_widget_view_event_handler_proc(mmi_event_struct *evt)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch(evt->evt_id)
    {
        case EVT_ID_GROUP_DEINIT:
        {
            mmi_frm_set_protocol_event_handler(MSG_ID_WIDGET_NOTIFY_CONTENT_UPDATE_IND, NULL, KAL_FALSE);
            mmi_frm_set_protocol_event_handler(MSG_ID_WIDGET_CLOSE_VIEW_IND, NULL, KAL_FALSE);
            mmi_frm_set_protocol_event_handler(MSG_ID_WIDGET_TERMINATE_WGT_IND, NULL, KAL_FALSE);
            mmi_frm_set_protocol_event_handler(MSG_ID_WIDGET_TERMINATE_ALL_WGT_IND, NULL, KAL_FALSE);

            gadget_adp_avplugin_notify_close();

            kal_take_mutex(g_widget_view_lock);

            if (!g_widget_view_cntx->closed_by_engine)
            {
                widget_close_view(g_widget_view_cntx->widget_id, g_widget_view_cntx->view_handle, g_widget_view_cntx->view_type, g_widget_view_cntx->view_response);
            }

            if (g_widget_view_cntx->gdi_buffer1)
            {
                  med_free_asm_mem(GRP_ID_WIDGET_VIEW, (void **) &g_widget_view_cntx->gdi_buffer1);
            }

            if (g_widget_view_cntx->gdi_buffer2)
            {
                  med_free_asm_mem(GRP_ID_WIDGET_VIEW, (void **) &g_widget_view_cntx->gdi_buffer2);
            }

            if (g_widget_view_cntx->render_layer)
            {
                gdi_layer_free(g_widget_view_cntx->render_layer);
            }
            OslMfree(g_widget_view_cntx);
            g_widget_view_cntx = NULL;

            kal_give_mutex(g_widget_view_lock);
            
            widget_disable_view_cache();

            break;
        }
        default:
            break;
    }

    return MMI_RET_OK;

}
コード例 #8
0
/*****************************************************************************
 * FUNCTION
 *  med_free_aud_mem_ext
 * DESCRIPTION
 *  
 * PARAMETERS
 *  pointer     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void med_free_aud_mem_ext(void **pointer,char* file_p, long line_p)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_mutex(med_mem_mutex);
    med_aud_sfree((address_t) * pointer);
    kal_give_mutex(med_mem_mutex);
    *pointer = NULL;
}
コード例 #9
0
ファイル: aud_vr_main.c プロジェクト: WayWingsDev/testmywatch
/*****************************************************************************
 * FUNCTION
 *  aud_vr_mutex_lock
 * DESCRIPTION
 *  mutex lock operation
 * PARAMETERS
 *  M       [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_vr_mutex_lock(aud_vr_mutex_struct *M)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (kal_get_active_module_id() != M->tid)
    {
        kal_take_mutex(M->mutex);
        M->tid = kal_get_active_module_id();
    }
    ++(M->cnt);
}
コード例 #10
0
/*****************************************************************************
 * FUNCTION
 *  med_alloc_ext_mem
 * DESCRIPTION
 *  
 * PARAMETERS
 *  size        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void *med_alloc_ext_mem_ext(kal_int32 size, kal_uint8 location, char* file_p, long line_p)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    void *p = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_mutex(med_mem_mutex);
    p = (void*)med_ext_smalloc_ext((size_type) size, location, file_p, line_p);
    kal_give_mutex(med_mem_mutex);

    return p;
}
コード例 #11
0
static _ies_task_job_handle_queue()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job             *pJob;
    SRV_IES_JOB_STATE_ENUM  state;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    pJob = NULL;

    if (LIST_EMPTY(&(g_ies_task_context.normal)))
    {
        if (!LIST_EMPTY(&(g_ies_task_context.lowest)))
        {
            pJob = (srv_ies_job*)(g_ies_task_context.lowest.pNext);
            LIST_DEL((srv_ies_list_head_struct*)pJob);
        }
    }
    else
    {
        pJob = (srv_ies_job*)(g_ies_task_context.normal.pNext);
        LIST_DEL(((srv_ies_list_head_struct*)pJob));
    }

    if (pJob)
    {
        kal_take_mutex(g_srv_ies_job_mutex);
        state = pJob->state;
        kal_give_mutex(g_srv_ies_job_mutex);

        ASSERT(SRV_IES_JOB_STATE_FINISHED != pJob->state);

        if (SRV_IES_JOB_STATE_CANCELLED != state)
        {
            g_ies_task_context.pJob = pJob;
            if (_ies_task_job_handle_start(g_ies_task_context.pJob))
            {
                g_ies_task_context.pJob = NULL;
            }
		}
    }
}
コード例 #12
0
srv_ies_result srv_ies_job_init(srv_ies_app_session_handle hApp)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 taskID;
    kal_int32  index;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (0 == g_srv_ies_hdl_mutex)
    {
        g_srv_ies_hdl_mutex = kal_create_mutex("IESHDLMX");
        ASSERT(0 != g_srv_ies_hdl_mutex);
    }

    kal_take_mutex(g_srv_ies_hdl_mutex);
    if (0 == g_srv_ies_job_user)
    {
        kal_get_my_task_index(&taskID);
        if(INDX_MMI == taskID)
        {
            mmi_frm_set_protocol_event_handler(MSG_ID_IES_JOB_RSP,
                                               &_srv_ies_job_response_handler,
                                               MMI_FALSE);
        }

        memset(g_srv_ies_curr_job, 0x0, sizeof(srv_ies_job*) * SRV_IES_JOB_MAX_JOB_COUNT);
   
        for (index = 0; index < SRV_IES_JOB_MAX_JOB_COUNT; index++)
        {
            g_srv_ies_job_pool[index].jobID = index;
        }
    }

    hApp->appState |= SRV_IES_APP_STATE_JOB_INITED;

    g_srv_ies_job_user++;
    kal_give_mutex(g_srv_ies_hdl_mutex);

    g_srv_ies_job_deinit = KAL_FALSE;

    return SRV_IES_OK;
}
コード例 #13
0
/*****************************************************************************
 * FUNCTION
 *  jpush_timer_mutex_lock
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jpush_timer_mutex_lock(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* GDI_LOCK; */
    if (kal_get_active_module_id() != jpush_timer_mutex_tid)
    {
        kal_take_mutex(g_jpush_record_mutex);
        jpush_timer_mutex_tid = kal_get_active_module_id();
    }
    ++jpush_timer_mutex_cnt;

}
コード例 #14
0
/******************************************************************************
* En-queue (rather than push) a command in the command queue of *prCommState.
* Store the command and its associated parameter in *peCmd and *pu4Param
* respectively.
*
* Note: The term "Push" in the function name is a misnomer.
*
* Side effect: the command queue, *peCmd, *pu4Param, and *pfgEmpty
*
* Return value:
*       KAL_TRUE if a command can be retrieved from the command queue.
*       KAL_FALSE if the command queue is full.
******************************************************************************/
kal_bool VideoCommPushCommand(VIDEO_COMM_STATE_T *prCommState,
        VIDEO_COMMAND_TYPE_T eCmd, kal_uint32 u4Param)
{
    kal_uint32 u4ReadIdx, u4WriteIdx, u4TotalNum;
    kal_uint32 u4SavedMask;

    u4SavedMask = SaveAndSetIRQMask();
    prCommState->u4EntryCount++;
    RestoreIRQMask(u4SavedMask);

    kal_take_mutex(prCommState->eMutex);

    u4ReadIdx = prCommState->rCmdQ.u4ReadIdx;
    u4WriteIdx = prCommState->rCmdQ.u4WriteIdx;
    u4TotalNum = prCommState->rCmdQ.u4TotalNum;

    if (u4TotalNum == 0)
    {
        ASSERT(0);
        return KAL_FALSE;
    }

    if (((u4WriteIdx + 1) % u4TotalNum) == u4ReadIdx)
    {
        kal_give_mutex(prCommState->eMutex);
        u4SavedMask = SaveAndSetIRQMask();
        prCommState->u4EntryCount--;
        RestoreIRQMask(u4SavedMask);
        return KAL_FALSE;
    }

    prCommState->rCmdQ.prCmdQ[u4WriteIdx].eCmd = eCmd;
    prCommState->rCmdQ.prCmdQ[u4WriteIdx].u4Param = u4Param;
    prCommState->rCmdQ.u4WriteIdx = (u4WriteIdx + 1) % u4TotalNum;

    kal_give_mutex(prCommState->eMutex);

    u4SavedMask = SaveAndSetIRQMask();
    prCommState->u4EntryCount--;
    RestoreIRQMask(u4SavedMask);

    return KAL_TRUE;
}
コード例 #15
0
void *mmi_widget_view_lock_canvas(int instance_id, void *view_handle, void **ptr_buffer, int width, int height)
{
    canvas_lock_struct *lock = NULL;
    
    int buffer_size = width * height * 2;
        
#ifdef WIDGET_DETAILS_VIEW_ARGB8888_COLOR_FORMAT
    buffer_size = width * height * 4;
#endif

    ASSERT(ptr_buffer);
    if (mmi_frm_scrn_get_active_id() != SCR_ID_WIDGET_VIEW)
    {
        return NULL;
    }

    kal_take_mutex(g_widget_view_lock);

    if (!g_widget_view_cntx || g_widget_view_cntx->widget_id != instance_id || g_widget_view_cntx->view_handle != view_handle || !g_widget_view_cntx->render_layer ||
        g_widget_view_cntx->view_width != width || g_widget_view_cntx->view_height != height)
    {
        kal_give_mutex(g_widget_view_lock);
        return NULL;
    }

    lock = (canvas_lock_struct *)OslMalloc(sizeof(canvas_lock_struct));
    memset(lock, 0, sizeof(canvas_lock_struct));
    lock->mutex = g_widget_view_lock;
    lock->view_type = g_widget_view_cntx->view_type;
    lock->unlock_canvas = mmi_widget_view_unlock_canvas;
    gdi_layer_push_and_set_active(g_widget_view_cntx->render_layer);


    memset(gdi_act_layer->buf_ptr1, 0xff, buffer_size);
    //gdi_layer_get_buffer_ptr(&layer_buffer);
    *ptr_buffer = gdi_act_layer->buf_ptr1;

    gdi_layer_pop_and_restore_active();

    return lock;
}
コード例 #16
0
static MMI_BOOL _ies_task_job_handle_start(srv_ies_job *pJob)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    CRESULT                         result;
    srv_ies_app_session_handle      hApp;
    kal_uint32                      count;
    srv_ies_result                  error;
    srv_ies_job_control             *pOwner;
    CTImage                         *pImage;
    kal_bool                        postDel;
    WCHAR                           file[SRV_FMGR_PATH_MAX_LEN + 1];

#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif // 0

    IES_LOG_SETUP();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(MOD_IES, TRACE_GROUP_2, "_ies_task_job_handle_start job %x", pJob);

    IES_LOG_BEGIN(SRV_IES_JOB_HANDLE_START, 1, pJob);

    hApp = (srv_ies_app_session_handle)(pJob->pParent);
    ASSERT(NULL != hApp);

    // Reserve memory for foreground task (i.e. MMI task)
    if (hApp->feature == SRV_IES_FEATURE_VIEW)
    {
        count = oslmem_free_space();
    #ifdef __MMI_SRV_IES_META__
        if (SRV_IES_JOB_TYPE_CREATE_META == pJob->jobType)
        {
            if (count <= (7.5 * 1024 * 1024))
            {
                kal_sleep_task(1);

                IES_LOG_END(MMI_FALSE);
                return MMI_FALSE;
            }
        }
    #else
        if (count <= (4.5 * 1024 * 1024))
        {
            kal_sleep_task(1);

            IES_LOG_END(MMI_FALSE);
            return MMI_FALSE;
        }
    #endif  // __MMI_SRV_IES_META__
    }

    result  = CRES_TASK_COMPLETE;
    postDel = KAL_FALSE;

    kal_take_mutex(g_srv_ies_job_mutex);

    ASSERT(SRV_IES_JOB_STATE_FINISHED  != pJob->state);

    if (SRV_IES_JOB_STATE_CANCELLED == pJob->state)
    {
        if (!LIST_EMPTY(((srv_ies_list_head_struct*)pJob)))
        {
            LIST_DEL(((srv_ies_list_head_struct*)pJob));
        }
    }

    while(SRV_IES_JOB_STATE_CANCELLED != pJob->state)
    {       
        pJob->state = SRV_IES_JOB_STATE_RUNNING;

        CAPS_MEM_USAGE();
        
        kal_trace(MOD_IES, TRACE_GROUP_2, "caps_doNextIteration begin for pItr %x uid %d", pJob->pItr, pJob->jobID);
        count = 0;
        do
        {
            result = caps_doNextIteration(pJob->pItr);
            if (++count >= pJob->maxStep)
            {
                break;
            }
        } while(CERR_OK == result);
        kal_trace(MOD_IES, TRACE_GROUP_2, "caps_doNextIteration end for pItr %x uid %d", pJob->pItr, pJob->jobID);

        // CERR_OK means there are more iterations left
        if(CERR_OK == result)
        {
            break;
        }
        else
        { 
            CAPS_MEM_USAGE();
            
            // job finished, see if succeeded
            error = srv_ies_util_error_get_result(result); 

            kal_trace(MOD_IES, TRACE_GROUP_2, "_ies_task_job_handle_start done for job %x with result %x", pJob, error);

            pJob->state = SRV_IES_JOB_STATE_FINISHED;
            caps_destroyIterator(pJob->pItr);
            pJob->pItr = NULL;

            pOwner = (srv_ies_job_control*)pJob->pOwner;
            if (NULL != pOwner)
            {
               pOwner->pCurrJob = NULL;
            }

            switch(pJob->jobType)
            {
                case SRV_IES_JOB_TYPE_RENDER_PREVIEW:
                    if (SRV_IES_OK == error)
                    {
                        result = caps_getSourceRenderResult(((srv_ies_image*)pOwner)->session);
                        if (CFAILED(result))
                        {
                            error = srv_ies_util_error_get_result(result);
                        }
                    #if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
                    #endif // 0
                    }
                    break;
                case SRV_IES_JOB_TYPE_RENDER_BUFFER:
                    pImage = (CTImage*)(pJob->pOutput);

                    if (SRV_IES_OK == error)
                    {
                        result = caps_getSourceRenderResult(((srv_ies_image*)pOwner)->session);
                        if (CFAILED(result))
                        {
                            error  = srv_ies_util_error_get_result(result);
                        }
                    #if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
                     #endif // 0

                     #if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
                    #endif // 0
                    }

                    pImage->pixels = NULL;
                    caps_destroyImage(pImage);
                    pJob->pOutput = NULL;
                    break;
                case SRV_IES_JOB_TYPE_RENDER_FILE:
                    if (pJob->pInput)
                    {
                        ctstream_destroy((CTStream*)pJob->pInput);
                        pJob->pInput = NULL;
                    }

                    if (SRV_IES_OK != error)
                    {
                        memcpy(file, pJob->filePath, sizeof(WCHAR) * (SRV_FMGR_PATH_MAX_LEN + 1));
                        postDel = KAL_TRUE;
                    }
                    break;
                case SRV_IES_JOB_TYPE_CREATE_META:
                    if (SRV_IES_OK != error)
                    {
                        srv_ies_meta_destroy((srv_ies_meta_handle)(pJob->pOutput));
                        pJob->pOutput = NULL;
                    }
                    else
                    {
                        g_srv_ies_meta_test[pJob->jobID] = KAL_TRUE;
                    }
                    break;
                default:
                    ASSERT(0);
                    IES_LOG_END(MMI_TRUE);
                    return MMI_TRUE;
            }

            if(MOD_NIL != pJob->modID)
            {
                _ies_task_job_respond(pJob, pJob->seqNum, error);
            }
            result = CRES_TASK_COMPLETE;
            break;
        }
    }
    kal_give_mutex(g_srv_ies_job_mutex);

    if (KAL_TRUE == postDel)
    {
       if (srv_fmgr_fs_path_exist(file) >= 0)
       {
          srv_fmgr_fs_delete(file);
       }
    }

    IES_LOG_END(((result == CERR_OK)? MMI_FALSE: MMI_TRUE));
    return (result == CERR_OK)? MMI_FALSE: MMI_TRUE;

}
コード例 #17
0
void BitCopy(const kal_uint8 *src, kal_uint16 srcOffset, kal_uint8 *dest, kal_uint16 *destOffset, kal_uint16 length)
{
	
     kal_uint32	 Input32Temp, BC_it;
     kal_uint32  srcStartAddr, dstStartAddr;
     kal_uint16  destOffsetTemp = *destOffset; 
     
     srcStartAddr = (kal_uint32) (src + ( srcOffset / 8 ));
     srcOffset = srcOffset % 8;
     
     dstStartAddr = (kal_uint32) (dest + ( (*destOffset) / 8 ));
     (*destOffset) = (*destOffset) % 8;
     
     
     if (!BC_mutex){
         BC_mutex = kal_create_mutex("BC_mutex");}
      
     
     kal_take_mutex(BC_mutex);
        
     //reset all register   
	  DRV_WriteReg32(BC_REG_START,0);       
	   
	  //input source addr
	  DRV_WriteReg32(BC_REG_SRC, ((kal_uint32)(srcStartAddr)));    
	   
	  //output destination addr   
	  DRV_WriteReg32(BC_REG_DST, ((kal_uint32)(dstStartAddr)));      
	   
	   
	  //output destination last byte addr 
	  Input32Temp = ((length - (8 - (*destOffset))) > 0) ? (kal_uint32)(dstStartAddr + ((length - (8 - (*destOffset)) + 7) / 8)) : (kal_uint32)dstStartAddr;
	  DRV_WriteReg32(BC_REG_LDST, ((kal_uint32)Input32Temp));   
	   
	   
	  //input copy length 
	  Input32Temp = 0;
     Input32Temp = length & 0x0000FFFF;
	   DRV_WriteReg32(BC_REG_SIZE, ((kal_uint32)Input32Temp));                 
	   
	   
	  //set wo and ro(also reset all)
	  Input32Temp = 0;
     Input32Temp = (kal_uint32)(( ((kal_uint32)(*destOffset))<<4) | ((kal_uint32)srcOffset) | (0x00030000));
	  DRV_WriteReg32(BC_REG_CON, (kal_uint32)Input32Temp);               
	   
	   
	  //start the BC engine 
     DRV_WriteReg32(BC_REG_START, 0x00008000);       
	   	
	   	
	   //polling completed interrupt	
	   while(1){  
	     BC_it = DRV_Reg32(BC_REG_STA);
        if((BC_it&0x00000002)!=0)
	   		break;
	   }
	   
	   kal_give_mutex(BC_mutex);
	   
	   (*destOffset) = destOffsetTemp + length;
} 
コード例 #18
0
ファイル: mply_sec.c プロジェクト: WayWingsDev/testmywatch
/*****************************************************************************
 * FUNCTION
 *  media_player_do_recover
 * DESCRIPTION
 *  The function is to do recover
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
media_error_t media_player_do_recover(media_player_t* mp, media_time_t key_frame_time)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_player_cntx_struct* self = SELF(mp, media_player_cntx_struct, itf);
    VIDEO_DECODER_QUERY_I_FRM_T query;
    VIDEO_ERROR_TYPE_T error;
    kal_bool found;
    kal_uint64 decode_time, diff;
    media_data_t *node = NULL, *head = NULL, *found_node = NULL;
    VIDEO_COMPONENT_TYPE_T *dec_handle = self->decoder_handle;
    kal_uint32 event_group, format_index;
    media_codec_type_t codec_type;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, VID_TRC_MEDIA_PLAYER_JUMP_TO_I_FRAME, self->state, (kal_uint32)key_frame_time);

    if (self->state == MPLY_STATE_CLOSED ||
            self->state == MPLY_STATE_OPENED ||
            self->state == MPLY_STATE_PREPARED ||
            self->state == MPLY_STATE_SEEKING ||
            self->state == MPLY_STATE_SEEK_DONE)
    {
        return MED_E_WRONG_STATE;
    }

    ASSERT(self->vid_stream_index != MEDIA_PLAYER_INVALID_INDEX);
    kal_take_mutex(media_player_mutex);
    /**************************************************
     ** Jump to I frame in file
     **************************************************/
    if (key_frame_time > 0)
    {
        /* Flush frame */
        error = dec_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM, NULL);
        ASSERT(error == VIDEO_ERROR_NONE ||
               error == VIDEO_ERROR_NO_FRAME_TO_FLUSH);

        /* Wait until flush frame is done */
        if (error == VIDEO_ERROR_NONE)
        {
            /* release mutex for decoder to release frame */
            kal_give_mutex(media_player_mutex);
            MPLY_SET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_retrieve_eg_events(media_player_comp_eg, MEDIA_PLAYER_EG_DECODER_FLUSH_FRAME_DONE, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
            MPLY_UNSET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_take_mutex(media_player_mutex);
        }

        /* Flush frame in queue */
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO_WRITTEN);
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO);
        self->vid_life_cycle_id ++;
        self->vid_queue_num = 0;
        MPLY_UNSET_FLAG(MPLY_FLAG_VID_BUFF_FULL);

        /* Enable skip non-I frame */
        MPLY_SET_FLAG(MPLY_FLAG_SKIP_NON_I_FRAME);
        self->key_frame_time = key_frame_time;
        goto finish;
    }

    /**************************************************
     ** Jump to I frame in queue
     **************************************************/
    codec_type = self->vid_stream.dec_config.codec;
    format_index = mpl_get_vid_custom_format_index(codec_type);

    diff = mply_custom_get_cust(format_index, 2);
    ASSERT(diff > 0);
    error = self->decoder_handle->pfnGetParameter(VIDEO_PARAM_QUERY_DECODE_TIME, &decode_time);
    decode_time = MEDIA_PLAYER_COMPTIME_TO_TIME(decode_time);
    found = KAL_FALSE;

    /* Search I frame with max T from queue's head */
    if (self->video_queue)
    {
        node = head = self->video_queue->next;
        do
        {
            if ((node->flags & MEDIA_DATA_FLAG_KEY_FRAME) &&
                    (node->display_time <= decode_time + diff))
            {
                found = KAL_TRUE;
                found_node = node;
            }
            node = node->next;
        }
        while (node != head);
    }

    kal_trace(TRACE_FUNC, VID_TRC_MEDIA_PLAYER_JUMP_INFO,
              found, (kal_uint32)decode_time, (kal_uint32)diff);

    /* If I frame is found, drop P, B frame */
    if (found && found_node != NULL)
    {
        /* Flush all the frame in decoder */
        error = dec_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM, NULL);
        ASSERT(error == VIDEO_ERROR_NONE ||
               error == VIDEO_ERROR_NO_FRAME_TO_FLUSH);

        /* Wait until flush frame is done */
        if (error == VIDEO_ERROR_NONE)
        {
            kal_give_mutex(media_player_mutex);
            MPLY_SET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_retrieve_eg_events(media_player_comp_eg, MEDIA_PLAYER_EG_DECODER_FLUSH_FRAME_DONE, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
            MPLY_UNSET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_take_mutex(media_player_mutex);
        }

        /* Flush frame in queue */
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO_WRITTEN);
        self->vid_life_cycle_id ++;
        self->vid_queue_num = 0;
        MPLY_UNSET_FLAG(MPLY_FLAG_VID_BUFF_FULL);

        /* Flush P, B frame in queue */
        head = self->video_queue->next;
        while(head != found_node)
        {
            media_player_remove_from_queue(&self->video_queue, head);
            head->release(head);
            self->vid_queue_num --;

            head = self->video_queue->next;
        }
        goto finish;
    }

    /**************************************************
     ** Jump to I frame in decoder
     **************************************************/

    /* Check if decoder input queue has I frame */
    query.u8TimeDifference = MEDIA_PLAYER_TIME_TO_COMPTIME(diff);
    query.fgRet = KAL_FALSE;

    error = self->decoder_handle->pfnGetParameter(VIDEO_PARAM_IS_I_FRM_IN_QUEUE, &query);
    ASSERT(error == VIDEO_ERROR_NONE);

    if (query.fgRet)
    {
        error = self->decoder_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM_BEFORE_I, NULL);
        goto finish;
    }

finish:
    mpl_start_timer(
        MPL_PLAYER_RECOVER_TIMER, MPLY_RESET_RECOVER_ELAPSE,
        media_player_reset_recover, self);

    kal_give_mutex(media_player_mutex);
    return MED_S_OK;
}
コード例 #19
0
ファイル: aud_bt_a2dp.c プロジェクト: 12019/mtktest
void aud_bt_a2dp_lock_codec(void)
{
    kal_take_mutex(codec_mutex);
}
コード例 #20
0
static void _ies_task_job_handle_cancel(srv_ies_job *pJob)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job_control  *pOwner;
    CTImage              *pImage;
    kal_bool             postDel;
    WCHAR                file[SRV_FMGR_PATH_MAX_LEN + 1];

    IES_LOG_SETUP();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(MOD_IES, TRACE_GROUP_2, "_ies_task_job_handle_cancel job %x", pJob);

    IES_LOG_BEGIN(SRV_IES_JOB_HANDLE_CANCEL, 1, pJob);

    postDel = KAL_FALSE;

    kal_take_mutex(g_srv_ies_job_mutex);
    while(NULL != pJob->pItr)
    {
        // Abort the iterator
        caps_abortIterator(pJob->pItr);
        caps_destroyIterator(pJob->pItr);
        pJob->pItr = NULL;
    }

    switch(pJob->jobType)
    {
        case SRV_IES_JOB_TYPE_RENDER_PREVIEW:
            break;  
        case SRV_IES_JOB_TYPE_RENDER_BUFFER:
            if (NULL != pJob->pOutput)
            {
                pImage = (CTImage*)(pJob->pOutput);
                pImage->pixels = NULL;
                caps_destroyImage(pImage);
                pJob->pOutput = NULL;
            }
            break;
        case SRV_IES_JOB_TYPE_RENDER_FILE:
            if (pJob->pInput)
            {
                ctstream_destroy((CTStream*)pJob->pInput);
                pJob->pInput = NULL;
            }

            memcpy(file, pJob->filePath, sizeof(WCHAR) * (SRV_FMGR_PATH_MAX_LEN + 1));
            postDel = KAL_TRUE;
            break;
        case SRV_IES_JOB_TYPE_CREATE_META:
            if (NULL != pJob->pOutput)
            {
                srv_ies_meta_destroy((srv_ies_meta_handle)(pJob->pOutput));
                pJob->pOutput = NULL;
            }
            g_srv_ies_meta_test[pJob->jobID] = KAL_FALSE;
            break;
        default:
            ASSERT(0);
            break;
    }

    pOwner = (srv_ies_job_control*)pJob->pOwner;
    if (pOwner)
    {
       pOwner->pCurrJob = NULL;
    }
    kal_give_mutex(g_srv_ies_job_mutex);

    if (KAL_TRUE == postDel)
    {
       if (srv_fmgr_fs_path_exist(file) >= 0)
       {
          srv_fmgr_fs_delete(file);
       }
    }

    // set event to notify client. (this is a blocking action)
    kal_trace(MOD_IES, TRACE_GROUP_2, "_ies_task_job_handle_cancel set event");
    SET_IES_TASK_EVENT();

    IES_LOG_END(0);
}
コード例 #21
0
/* Query all LUN media. It contains the total error handling.
     If result is fail, the host function is turned off in this function */
static kal_bool USB_Host_Ms_Check_All_Media(kal_uint8 ms_index)
{
	kal_uint32 index;
	kal_uint32 index2;


	for(index = 0; index < g_UsbHostMs[ms_index].total_lun; index++)
	{
		/* Note that take and give the mutex in lun level. To reduce the latency in application read and write */
		kal_take_mutex(g_UsbHostMs[ms_index].mutex_id);

		/* check the dedicated LUN */
		USB_Host_MS_Check_Media(index);

		if(g_UsbHostMs[ms_index].dev_state != USB_HOST_MS_DEV_STATE_READY)
		{
			/* Reset all media state */
			for(index2 = 0; index2 < g_UsbHostMs[ms_index].total_lun; index2++)
			{
				/* If original state is READY, set state change as true */
				if(((g_UsbHostMs[ms_index].media_info[index2].state == USB_HOST_MS_MEDIA_STATE_WR_PROTECT)
					||(g_UsbHostMs[ms_index].media_info[index2].state == USB_HOST_MS_MEDIA_STATE_READY))
					&& (g_UsbHostMs[ms_index].media_info[index2].sec_size != 0))
				{
					g_UsbHostMs[ms_index].media_state_change |= (1<<index2);
				}

				/* Set all the media state to error */
				g_UsbHostMs[ms_index].media_info[index2].state = USB_HOST_MS_MEDIA_STATE_ERROR;
			}

			if(g_UsbHostMs[ms_index].dev_state == USB_HOST_MS_DEV_STATE_FATAL_ERROR)
			{
				/* It means reset is no use or error count exceed limit */
				g_UsbHostMs[ms_index].dev_error_count = 8;
				USB_Host_Ms_Error_Handler(ms_index);
				kal_give_mutex(g_UsbHostMs[ms_index].mutex_id);
				break;
			}
			else
			{
				g_UsbHostMs[ms_index].dev_error_count++;

				/* Should modify to dev error, reset device */
				if(USB_Host_Ms_Error_Check(ms_index) == KAL_TRUE)
				{
					/* It means reset is no use or error count exceed limit */
					USB_Host_Ms_Error_Handler(ms_index);
					kal_give_mutex(g_UsbHostMs[ms_index].mutex_id);
					break;
				}
				else
				{
					/* reset is complete, so check all media again */
					/* Error handling is in the recursive function */
					kal_give_mutex(g_UsbHostMs[ms_index].mutex_id);
					USB_Host_Ms_Check_All_Media(ms_index);
					break;
				}
			}
		}
		else
		{
			kal_give_mutex(g_UsbHostMs[ms_index].mutex_id);
		}
	}

	if((g_UsbHostMs[ms_index].dev_error_count >= 3) ||(g_UsbHostMs[ms_index].dev_attatch == KAL_FALSE) )
	{
		/* Error count exceed limit, host function has been turned off in error handler */
		return KAL_FALSE;
	}
	else
	{
		/* Reset error count. Avoid error count propagete */
		g_UsbHostMs[ms_index].dev_error_count = 0;
		return KAL_TRUE;
	}
}
コード例 #22
0
static void _ies_task_dispatch_message(ilm_struct *pIlm)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_ilm_job_request     *pReq;
    srv_ies_job                 *pJob;
    srv_ies_job                 *pLow;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch(pIlm->msg_id)
    {
    case MSG_ID_IES_JOB_REQ:
        pReq = (srv_ies_ilm_job_request*)pIlm->local_para_ptr;
        ASSERT(NULL != pReq);

        pJob = pReq->pJob;
        ASSERT(NULL != pJob);

        ASSERT(KAL_FALSE == g_srv_ies_job_deinit);

        if(!_srv_ies_job_compare_seq_num(pReq->seqNum, pJob->seqNum))
        {
            kal_trace(MOD_IES, TRACE_GROUP_2, "_ies_task_dispatch_message got inconsistent sequence number %d, %d", pReq->seqNum, pReq->pJob->seqNum);
            break;
        }

        if (SRV_IES_JOB_REQUEST_CANCEL == pReq->type)
        {          
            if (!LIST_EMPTY(((srv_ies_list_head_struct*)pJob)))
            {
                LIST_DEL(((srv_ies_list_head_struct*)pJob));
            }
            _ies_task_job_handle_cancel(pJob);

            if (pJob == g_ies_task_context.pJob)
            {
                g_ies_task_context.pJob = NULL;
            }
        }
        else
        {
            ASSERT(SRV_IES_JOB_REQUEST_START == pReq->type);

            ASSERT(SRV_IES_JOB_STATE_FINISHED != pJob->state);

            if (g_ies_task_context.pJob)
            {
                if (g_ies_task_context.pJob->jobType > pJob->jobType)
                {
                    pLow = g_ies_task_context.pJob;
                    g_ies_task_context.pJob = pJob;

                    ASSERT(SRV_IES_JOB_STATE_FINISHED != pLow->state);

                    switch(pLow->jobType)
                    {
                        case SRV_IES_JOB_TYPE_RENDER_PREVIEW:
                        case SRV_IES_JOB_TYPE_RENDER_BUFFER:
                        case SRV_IES_JOB_TYPE_RENDER_FILE:
                            LIST_ADD_HEAD(&(g_ies_task_context.normal), (srv_ies_list_head_struct*)pLow);
                            break;
                        case SRV_IES_JOB_TYPE_CREATE_META:
                            LIST_ADD_HEAD(&(g_ies_task_context.lowest), (srv_ies_list_head_struct*)pLow);
                            break;
                        default:
                            ASSERT(0);
                    }
                }
                else
                {
                    pLow = pJob;

                    switch(pLow->jobType)
                    {
                        case SRV_IES_JOB_TYPE_RENDER_PREVIEW:
                        case SRV_IES_JOB_TYPE_RENDER_BUFFER:
                        case SRV_IES_JOB_TYPE_RENDER_FILE:
                            LIST_ADD_TAIL(&(g_ies_task_context.normal), (srv_ies_list_head_struct*)pLow);
                            break;
                        case SRV_IES_JOB_TYPE_CREATE_META:
                            LIST_ADD_TAIL(&(g_ies_task_context.lowest), (srv_ies_list_head_struct*)pLow);
                            break;
                        default:
                            ASSERT(0);
                    }

                }

                kal_take_mutex(g_srv_ies_job_mutex);
                if (SRV_IES_JOB_STATE_CANCELLED != pLow->state)
                {
                    pLow->state = SRV_IES_JOB_STATE_PENDING;
                }
                kal_give_mutex(g_srv_ies_job_mutex);
            }
            else
            {
                ASSERT(SRV_IES_JOB_STATE_FINISHED != pJob->state);
                g_ies_task_context.pJob = pJob;
            }

            if (_ies_task_job_handle_start(g_ies_task_context.pJob))
            {
                g_ies_task_context.pJob = NULL;
            }
        }
        break;
    default:
        break;
    }
}
コード例 #23
0
srv_ies_result srv_ies_job_deinit(srv_ies_app_session_handle hApp)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ies_job             *pJob;
    kal_int32               index;
    SRV_IES_JOB_STATE_ENUM  state;
    kal_uint32              taskID;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    hApp->appState &= ~SRV_IES_APP_STATE_JOB_INITED;

    for (index = 0; index < SRV_IES_JOB_MAX_JOB_COUNT; index++)
    {
        kal_take_mutex(g_srv_ies_hdl_mutex);
        pJob = g_srv_ies_curr_job[index];
        kal_give_mutex(g_srv_ies_hdl_mutex);
        if (pJob)
        {
            kal_take_mutex(g_srv_ies_job_mutex);
            state = pJob->state;
            kal_give_mutex(g_srv_ies_job_mutex);

            if ((pJob->pParent == hApp) &&
                (SRV_IES_JOB_STATE_INVALID  != state) &&
                (SRV_IES_JOB_STATE_FINISHED != state))
            {
                srv_ies_job_cancel(pJob);
            }
            else if ((pJob->pParent == hApp) &&
                     (SRV_IES_JOB_STATE_FINISHED == state))
            {
               g_srv_ies_curr_job[index] = NULL;
               pJob->seqNum = 0;
               TYPED_FREE(pJob, srv_ies_job);
            }

            pJob->state = SRV_IES_JOB_STATE_INVALID;
        }
    }

    kal_take_mutex(g_srv_ies_hdl_mutex);

    g_srv_ies_job_user--;
    ASSERT(g_srv_ies_job_user >= 0);

    if (0 == g_srv_ies_job_user)
    {
        kal_get_my_task_index(&taskID);
        if(INDX_MMI == taskID)
        {
            mmi_frm_clear_protocol_event_handler(MSG_ID_IES_JOB_RSP,
                                                 &_srv_ies_job_response_handler);
        }

        g_srv_ies_job_deinit = KAL_TRUE;
    }
    kal_give_mutex(g_srv_ies_hdl_mutex);

    return SRV_IES_OK;
}