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