khronosfws/openmax_al/src/mmf_adaptation/xaradioadaptctx.c
branchRCL_3
changeset 19 095bea5f582e
equal deleted inserted replaced
18:a36789189b53 19:095bea5f582e
       
     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 "xaradioadaptctx.h"
       
    19 #include "xaadaptationmmf.h"
       
    20 #include "cmmfradiobackendengine.h"
       
    21 #include "assert.h"
       
    22 
       
    23 /*
       
    24  * XAAdaptationMMFCtx* XARadioAdapt_Create()
       
    25  * Allocates memory for Radio Adaptation Context and makes 1st phase initialization
       
    26  * @returns XARadioAdaptationCtx* - Pointer to created context
       
    27  */
       
    28 XAAdaptationBaseCtx* XARadioAdapt_Create()
       
    29 {
       
    30     XARadioAdaptationCtx *pSelf = (XARadioAdaptationCtx*)calloc(1, sizeof(XARadioAdaptationCtx));
       
    31     DEBUG_API("->XARadioAdapt_Create");
       
    32 
       
    33     if ( pSelf)
       
    34     {
       
    35         if( XAAdaptationBase_Init(&(pSelf->baseObj.baseObj),XARadioAdaptation)
       
    36                     != XA_RESULT_SUCCESS )
       
    37       	{
       
    38         	DEBUG_ERR("Failed to init base context!!!");
       
    39          	free(pSelf);
       
    40         	pSelf = NULL;
       
    41         	return (XAAdaptationBaseCtx*)pSelf;
       
    42       	}
       
    43      		else
       
    44        	{
       
    45        		pSelf->range = RADIO_DEFAULT_FREQ_RANGE;
       
    46         	pSelf->frequency = RADIO_DEFAULT_FREQ;
       
    47         	pSelf->rdsEmulationThread = 0;
       
    48        		pSelf->emulationThread = 0;
       
    49        	}
       
    50     }
       
    51 
       
    52     DEBUG_API("<-XARadioAdapt_Create");
       
    53     return (XAAdaptationBaseCtx*)&pSelf->baseObj;
       
    54 }
       
    55 
       
    56 /*
       
    57  * XAresult XARadioAdapt_PostInit()
       
    58  * 2nd phase initialization of Radio Adaptation Context
       
    59  */
       
    60 XAresult XARadioAdapt_PostInit(XAAdaptationBaseCtx* bCtx)
       
    61 {
       
    62     XAresult ret = XA_RESULT_SUCCESS;
       
    63     XARadioAdaptationCtx* ctx = NULL;
       
    64     DEBUG_API("->XARadioAdapt_PostInit");
       
    65     if(bCtx == NULL || bCtx->ctxId != XARadioAdaptation )
       
    66     {
       
    67         DEBUG_ERR("Invalid parameter!!");
       
    68         DEBUG_API("<-XARadioAdapt_PostInit");
       
    69         return XA_RESULT_PARAMETER_INVALID;
       
    70     }
       
    71     ctx = (XARadioAdaptationCtx*)bCtx;
       
    72     assert(ctx);
       
    73 
       
    74     ret = XAAdaptationBase_PostInit( &ctx->baseObj.baseObj );
       
    75     if( ret!=XA_RESULT_SUCCESS )
       
    76     {
       
    77         DEBUG_ERR("Base context postinit failed!!");
       
    78         DEBUG_API("<-XARadioAdapt_PostInit");
       
    79         return ret;
       
    80     }
       
    81 
       
    82 		cmmfradiobackendengine_init(); 
       
    83 
       
    84     DEBUG_API("<-XARadioAdapt_PostInit");
       
    85     return ret;
       
    86 }
       
    87 
       
    88 /*
       
    89  * void XARadioAdapt_Destroy(XAAdaptationMMFCtx* bCtx)
       
    90  * Destroys Radio Adaptation Context
       
    91  * @param ctx - Radio Adaptation context to be destroyed
       
    92  */
       
    93 void XARadioAdapt_Destroy(XAAdaptationBaseCtx* bCtx)
       
    94 {
       
    95 		XARadioAdaptationCtx* ctx = NULL;
       
    96     DEBUG_API("->XARadioAdapt_Destroy");
       
    97     
       
    98 		cmmfradiobackendengine_delete(cmmfradiobackendengine_init());    
       
    99 
       
   100     if(bCtx == NULL || bCtx->ctxId != XARadioAdaptation )
       
   101     {
       
   102         DEBUG_ERR("Invalid parameter!!");
       
   103         DEBUG_API("<-XARadioAdapt_Destroy");
       
   104         return;
       
   105     }
       
   106     ctx = (XARadioAdaptationCtx*)bCtx;
       
   107     XAAdaptationBase_Free(&(ctx->baseObj.baseObj));
       
   108 
       
   109     free(ctx);
       
   110 
       
   111     DEBUG_API("<-XARadioAdapt_Destroy");
       
   112 }