예제 #1
0
int32_t XdmServer_process (
    Rpe_ServerObj              *server,
    FArg                        inBufs,
    FArg                        outBufs,
    FArg                        inArgs,
    FArg                        outArgs)
{
    XdmServer_ServerConfig     *xdmServerCfg;
    XdmServer_ServerObj        *xdmServer;
    XDM_Fxns                   *xdmFxns;
    IALG_Fxns                  *ialgFxns;
    IALG_Handle                 alg;
    int32_t                     status;
    Rpe_FxnPtr                  algProcessFxn;

#ifdef DEBUG
    fprintf (stderr, "XdmServer_processServer: Enter\n");
#endif

    /* 
     * Retrieve ialgFxns and pointer to XDM process function from 
     * the server config record 
     */
    xdmServerCfg = (XdmServer_ServerConfig *) (server->serverConfig);
    xdmFxns = xdmServerCfg->xdmFxns;
    ialgFxns = &xdmFxns->ialgFxns;
    algProcessFxn = xdmFxns->algProcessFxn;

    /* Get alg handle from the server handle */
    xdmServer = (XdmServer_ServerObj *) server;
    alg = xdmServer->alg;

    /* 
     * It should have been already ensured that 
     * 1) ialgFxns is NOT NULL
     * 2) alg is NOT NULL
     */

    /* Call algActivate if NOT NULL */
    if (NULL != ialgFxns->algActivate)
        ialgFxns->algActivate (alg);

    /* Call XDM process */
    status = ((XdmServer_ProcessFxn) (algProcessFxn)) (alg, inBufs, outBufs, 
                                                       inArgs, outArgs);
    
    /* Call algDeactivate if NOT NULL */
    if (NULL != ialgFxns->algDeactivate)
        ialgFxns->algDeactivate (alg);

    return (status);
}
예제 #2
0
/*
*  ======== ALG_delete ========
*/
Void ALG_delete(ALG_Handle alg)
{
	IALG_MemRec memTab[ JPEGDEC_MEM_NUMBER ];
	Int n;
	IALG_Fxns *fxns;

	if (alg != NULL && alg->fxns != NULL) {
		fxns = alg->fxns;
		n = fxns->algNumAlloc != NULL ? fxns->algNumAlloc() : IALG_DEFMEMRECS;
		memset( memTab, 0, JPEGDEC_MEM_NUMBER * sizeof( IALG_MemRec ) );
		memTab[0].base = alg;
		n = fxns->algFree(alg, memTab);
		_ALG_freeMemory(memTab, n);
	}
}
예제 #3
0
int32_t XdmServer_delete (
    Rpe_ServerObj              *server)
{
    XdmServer_ServerObj        *xdmServer = (XdmServer_ServerObj *) server;
    IALG_Handle                 alg;
    IALG_MemRec                *memTab;
    Int                         numRecs;
    uint16_t                    memTabSize;
    IALG_Fxns                  *ialgFxns;
    int32_t                     status;

    if ((alg = xdmServer->alg) == NULL) {           /* Should not happen */
        status = RPE_E_XDM_NULL_ALG;
        goto Exit;
    }

    if (NULL == alg->fxns) {                        /* Should not happen */
        status = RPE_E_XDM_NULL_ALGFXNS;
        goto Exit;
    }

    ialgFxns = alg->fxns;
    numRecs = (NULL != ialgFxns->algNumAlloc) ? ialgFxns->algNumAlloc ()
                                              : IALG_DEFMEMRECS;

    /* Get the memTab memory that was allocated at create time */
    memTab = xdmServer->memTab;

    memTab[0].base = alg;
    numRecs = ialgFxns->algFree (alg, memTab);

    /* Free up algorithm memory */
    _XdmServer_freeXdaisAlgMemory((IALG_MemRec *) memTab, numRecs);

    /* Get the memTab memory size that was allocated */
    memTabSize = xdmServer->numRecs * sizeof (IALG_MemRec);
    /* Free memTab memory */
    Memory_free((IHeap_Handle) RPE_dspAlgHeapHandle, memTab, memTabSize);
    
    status = RPE_S_SUCCESS;

Exit:
    return (status);
}
예제 #4
0
/*
 *  ======== ALG_delete ========
 */
Void ALG_delete(ALG_Handle alg)
{
    IALG_MemRec *memTab;
    Int n;
    IALG_Fxns *fxns;

    if (alg != NULL && alg->fxns != NULL) {
        fxns = alg->fxns;
        n = fxns->algNumAlloc != NULL ? fxns->algNumAlloc() : IALG_DEFMEMRECS;

        if ((memTab = (IALG_MemRec *)malloc(n * sizeof (IALG_MemRec)))) {
            memTab[0].base = alg;
            n = fxns->algFree(alg, memTab);
            _ALG_freeMemory(memTab, n);

            free(memTab);
        }
    }
}
예제 #5
0
int32_t XdmServer_create (
    Rpe_ServerObj              *server,
    Rpe_Attributes             *instAttr,
    void                       *createParams)
{
    XdmServer_ServerObj        *xdmServer = (XdmServer_ServerObj *) server;
    XDM_Fxns                   *xdmFxns;
    IALG_Fxns                  *ialgFxns;
    IALG_MemRec                *memTab = NULL;
    Int                         numRecs;
    uint16_t                    memTabSize;
    IALG_Handle                 alg;
    IALG_Fxns                  *fxnsPtr;
    XdmServer_ServerConfig     *xdmServerCfg;
    uint8_t                     algAllocDone = FALSE;
    int32_t                     status, i;
    uint8_t                    *ptr;
    Error_Block                 eb;

#ifdef DEBUG
    fprintf (stderr, "XdmServer_createServer: Enter\n");
#endif
    xdmServer->alg = NULL;

    xdmServerCfg = (XdmServer_ServerConfig *) (server->serverConfig);

    /* Check that all fields in the config. structure are initialized */
    if ((xdmFxns = xdmServerCfg->xdmFxns) == NULL) {
        status = RPE_E_XDM_NULL_XDMFXNS;
        goto Error;
    }

    ialgFxns = &(xdmFxns->ialgFxns);

    if (NULL == ialgFxns->algAlloc) {
        status = RPE_E_XDM_NULL_ALGALLOC_FXN;
        goto Error;
    }
    if (NULL == ialgFxns->algFree) {
        status = RPE_E_XDM_NULL_ALGFREE_FXN;
        goto Error;
    }
    if (NULL == ialgFxns->algInit) {
        status = RPE_E_XDM_NULL_ALGINIT_FXN;
        goto Error;
    }
    if (NULL == xdmFxns->algControlFxn) {
        status = RPE_E_XDM_NULL_CONTROL;
        goto Error;
    }
    if (NULL == xdmFxns->algProcessFxn) {
        status = RPE_E_XDM_NULL_PROCESS;
        goto Error;
    }
    
    /* Get number of XDAIS alg memtab entries */
    xdmServer->numRecs = numRecs = (ialgFxns->algNumAlloc != NULL)
        ? ialgFxns->algNumAlloc () : IALG_DEFMEMRECS;

    /* Allocate memtab entries */
    memTabSize = numRecs * sizeof(IALG_MemRec);      
    
    if ((memTab = (IALG_MemRec *) Memory_alloc ((IHeap_Handle) RPE_dspAlgHeapHandle,
                                                memTabSize,
                                                RPE_MEM_ALLOC_ALIGNMENT,
                                                &eb)) == NULL) {
        status = RPE_E_SERVER_NO_MEMORY;
        goto Error;
    }
    
    /* Clear the memTab memory */
    ptr = (uint8_t *) memTab;
    for (i = 0; i < memTabSize; i++)
    {
      ptr[i] = 0;
    }
    
    /* Save memTab in the server record */
    xdmServer->memTab = memTab;

    /* Fill up memtab entries */
    if ((numRecs = ialgFxns->algAlloc (createParams, &fxnsPtr, memTab)) <= 0) {
        status = RPE_E_XDM_INVALID_CREAT_PARAMS;
        goto Error;
    }

    /* Allocated algorithm memory using memtab entries */
    if ((status = _XdmServer_allocXdaisAlgMemory (memTab, numRecs))
                                                            != RPE_S_SUCCESS) {
        goto Error;
    }
    algAllocDone = TRUE;

    /* Initialize alg handle */
    alg = (IALG_Handle) memTab[0].base;
    alg->fxns = ialgFxns;

    /* 
     * Call alg initialize function with the memory it requested.
     * If algInit successful return the alg object's handle 
     */
    if (ialgFxns->algInit (alg, memTab, NULL, createParams) != IALG_EOK) {
        status = RPE_E_XDM_ALGINIT;
        goto Error;
    }

    /* Put algHandle in the server handle */
    xdmServer->alg = alg;

    status = RPE_S_SUCCESS;
    goto Exit;

Error:
    /* Free all memory resources */

    /* Call algFree to free all instance memory, saved memTab recs. */
    if (TRUE == algAllocDone) {
        ialgFxns->algFree (alg, memTab);
        _XdmServer_freeXdaisAlgMemory (memTab, numRecs);
    }

    if (NULL != memTab)
        Memory_free ((IHeap_Handle) RPE_dspAlgHeapHandle, memTab, memTabSize);

Exit:
    return (status);
}