khronosfws/openmax_al/src/adaptation/xavibraadaptctx.c
changeset 33 5e8b14bae8c3
parent 28 ebf79c79991a
child 36 73253677b50a
equal deleted inserted replaced
28:ebf79c79991a 33:5e8b14bae8c3
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <gst.h>
       
    19 #include "XAVibraAdaptCtx.h"
       
    20 #include "XAAdaptation.h"
       
    21 
       
    22 /*
       
    23  * XAAdaptationBaseCtx* XAVibraAdapt_Create()
       
    24  * Allocates memory for Vibra Adaptation Context and makes 1st phase initialization
       
    25  * @returns XAVibraAdaptationCtx* - Pointer to created context
       
    26  */
       
    27 XAAdaptationBaseCtx* XAVibraAdapt_Create(XAuint32 deviceID)
       
    28 {
       
    29     XAVibraAdaptationCtx *pSelf = calloc(1, sizeof(XAVibraAdaptationCtx));
       
    30     DEBUG_API("->XAVibraAdapt_Create");
       
    31     if ( pSelf)
       
    32     {
       
    33         if( XAAdaptationBase_Init(&(pSelf->baseObj),XAVibraAdaptation)
       
    34                     != XA_RESULT_SUCCESS )
       
    35         {
       
    36         DEBUG_ERR("Failed to init base context!!!");
       
    37         free(pSelf);
       
    38         pSelf = NULL;
       
    39         }
       
    40     }
       
    41 
       
    42     DEBUG_API("<-XAVibraAdapt_Create");
       
    43     return (XAAdaptationBaseCtx*)pSelf;
       
    44 }
       
    45 
       
    46 /*
       
    47  * XAresult XAVibraAdapt_PostInit()
       
    48  * 2nd phase initialization of Vibra Adaptation Context
       
    49  */
       
    50 XAresult XAVibraAdapt_PostInit(XAAdaptationBaseCtx* bCtx)
       
    51 {
       
    52     XAresult ret = XA_RESULT_SUCCESS;
       
    53     XAVibraAdaptationCtx* ctx = NULL;
       
    54 
       
    55     DEBUG_API("->XAVibraAdapt_PostInit");
       
    56     if(bCtx == NULL || bCtx->ctxId != XAVibraAdaptation )
       
    57     {
       
    58         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    59         DEBUG_API("<-XAVibraAdapt_PostInit");
       
    60         return XA_RESULT_PARAMETER_INVALID;
       
    61     }
       
    62     ctx = (XAVibraAdaptationCtx*)bCtx;
       
    63 
       
    64     XAAdaptationBase_PostInit( &(ctx->baseObj) );
       
    65 
       
    66     DEBUG_API("<-XAVibraAdapt_PostInit");
       
    67     return ret;
       
    68 }
       
    69 
       
    70 /*
       
    71  * void XAVibraAdapt_Destroy(XAVibraAdaptationCtx* ctx)
       
    72  * Destroys Vibra Adaptation Context
       
    73  * @param ctx - Vibra Adaptation context to be destroyed
       
    74  */
       
    75 void XAVibraAdapt_Destroy(XAAdaptationBaseCtx* bCtx)
       
    76 {
       
    77     XAVibraAdaptationCtx* ctx = NULL;
       
    78     DEBUG_API("->XAVibraAdapt_Destroy");
       
    79 
       
    80     if(bCtx == NULL || bCtx->ctxId != XAVibraAdaptation )
       
    81     {
       
    82         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    83         DEBUG_API("<-XAVibraAdapt_Destroy");
       
    84         return;
       
    85     }
       
    86     ctx = (XAVibraAdaptationCtx*)bCtx;
       
    87     XAAdaptationBase_Free(&(ctx->baseObj));
       
    88 
       
    89     free(ctx);
       
    90     ctx = NULL;
       
    91 
       
    92     DEBUG_API("<-XAVibraAdapt_Destroy");
       
    93 }