/** ============================================================================
 *  @func   SWIRGB2YCBCR_DSP_delete
 *
 *  @desc   Delete phase of SWIRGB2YCBCR_DSP application. Deallocates all the
 *          resources that were allocated during create phase.
 *
 *  @modif  None.
 *  ============================================================================
 */
Int SWIRGB2YCBCR_DSP_delete (SWIRGB2YCBCR_DSP_TransferInfo * info)
{
    Int status = SYS_OK ;
    Int iomStatus ;

    if (info != NULL) {
        /* Delete SWI */
        if (info->swi != NULL) {
            SWI_delete (info->swi) ;
        }

        /* Delete GIO input channel */
        if (info->gioInputChan != NULL) {
            iomStatus = GIO_delete (info->gioInputChan) ;
            if (iomStatus != IOM_COMPLETED) {
                status = SYS_EBADIO ;
                SET_FAILURE_REASON (status) ;
            }
        }

        /* Delete GIO output channel */
        if (info->gioOutputChan != NULL) {
            iomStatus = GIO_delete (info->gioOutputChan) ;
            if (iomStatus != IOM_COMPLETED) {
                status = SYS_EBADIO ;
                SET_FAILURE_REASON (status) ;
            }
        }

        /* Deallocate inputBuffer */
        if (info->inputBuffer != NULL) {
            POOL_free (SAMPLE_POOL_ID, info->inputBuffer, info->bufferSize) ;
        }

        /* Deallocate outputBuffer */
        if (info->outputBuffer != NULL) {
            POOL_free (SAMPLE_POOL_ID, info->outputBuffer, info->bufferSize) ;
        }

        /* Deallocate info structure */
        if (!MEM_free (DSPLINK_SEGID, info, sizeof (SWIRGB2YCBCR_DSP_TransferInfo))) {
            status = SYS_EALLOC ;
            SET_FAILURE_REASON (status) ;
        }
    }
    else {
        status = SYS_EALLOC ;
    }

    return status ;
}
size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx)
{
    if (mtctx==NULL) return 0;   /* compatible with free on NULL */
    POOL_free(mtctx->factory);
    if (!mtctx->allJobsCompleted) ZSTDMT_releaseAllJobResources(mtctx); /* stop workers first */
    ZSTDMT_freeBufferPool(mtctx->buffPool);  /* release job resources into pools first */
    ZSTDMT_freeCCtxPool(mtctx->cctxPool);
    ZSTD_freeCDict(mtctx->cdict);
    ZSTD_freeCStream(mtctx->cstream);
    pthread_mutex_destroy(&mtctx->jobCompleted_mutex);
    pthread_cond_destroy(&mtctx->jobCompleted_cond);
    free(mtctx);
    return 0;
}
Beispiel #3
0
/** ============================================================================
 *  @func   pool_notify_Delete
 *
 *  @desc   This function releases resources allocated earlier by call to
 *          pool_notify_Create ().
 *          During cleanup, the allocated resources are being freed
 *          unconditionally. Actual applications may require stricter check
 *          against return values for robustness.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
Void
pool_notify_Delete (Uint8 processorId)
{
    DSP_STATUS status    = DSP_SOK ;
    DSP_STATUS tmpStatus = DSP_SOK ;

#ifdef DEBUG
    printf ("Entered pool_notify_Delete ()\n") ;
#endif

    /*
     *  Stop execution on DSP.
     */
    status = PROC_stop (processorId) ;
    if (DSP_FAILED (status)) {
        printf ("PROC_stop () failed. Status = [0x%x]\n", (int)status) ;
    }

    /*
     *  Unregister for notification of event registered earlier.
     */
    tmpStatus = NOTIFY_unregister (processorId,
                                   pool_notify_IPS_ID,
                                   pool_notify_IPS_EVENTNO,
                                   (FnNotifyCbck) pool_notify_Notify,
                                   0/* vladms pool_notify_SemPtr*/) ;
    if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
        status = tmpStatus ;
        printf ("NOTIFY_unregister () failed Status = [0x%x]\n",
                         (int)status) ;
    }

    /*
     *  Free the memory allocated for the data buffer.
     */
    tmpStatus = POOL_free (POOL_makePoolId(processorId, SAMPLE_POOL_ID),
                           (Void *) pool_notify_DataBuf,
                           pool_notify_BufferSize) ;
    if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
        status = tmpStatus ;
        printf ("POOL_free () DataBuf failed. Status = [0x%x]\n",
                         (int)status) ;
    }

    /*
     *  Close the pool
     */
    tmpStatus = POOL_close (POOL_makePoolId(processorId, SAMPLE_POOL_ID)) ;
    if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
        status = tmpStatus ;
        printf ("POOL_close () failed. Status = [0x%x]\n", (int)status) ;
    }

    /*
     *  Detach from the processor
     */
    tmpStatus = PROC_detach  (processorId) ;
    if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
        status = tmpStatus ;
        printf ("PROC_detach () failed. Status = [0x%x]\n", (int)status) ;
    }

    /*
     *  Destroy the PROC object.
     */
    tmpStatus = PROC_destroy () ;
    if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
        status = tmpStatus ;
        printf ("PROC_destroy () failed. Status = [0x%x]\n", (int)status) ;
    }

#ifdef DEBUG
    printf ("Leaving pool_notify_Delete ()\n") ;
#endif
}