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