|
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 } |
|
42 else |
|
43 { |
|
44 pSelf->range = RADIO_DEFAULT_FREQ_RANGE; |
|
45 pSelf->frequency = RADIO_DEFAULT_FREQ; |
|
46 pSelf->rdsEmulationThread = 0; |
|
47 pSelf->emulationThread = 0; |
|
48 } |
|
49 } |
|
50 |
|
51 DEBUG_API("<-XARadioAdapt_Create"); |
|
52 return (XAAdaptationBaseCtx*)&pSelf->baseObj; |
|
53 } |
|
54 |
|
55 /* |
|
56 * XAresult XARadioAdapt_PostInit() |
|
57 * 2nd phase initialization of Radio Adaptation Context |
|
58 */ |
|
59 XAresult XARadioAdapt_PostInit(XAAdaptationBaseCtx* bCtx) |
|
60 { |
|
61 XAresult ret = XA_RESULT_SUCCESS; |
|
62 XARadioAdaptationCtx* ctx = NULL; |
|
63 DEBUG_API("->XARadioAdapt_PostInit"); |
|
64 if(bCtx == NULL || bCtx->ctxId != XARadioAdaptation ) |
|
65 { |
|
66 DEBUG_ERR("Invalid parameter!!"); |
|
67 DEBUG_API("<-XARadioAdapt_PostInit"); |
|
68 return XA_RESULT_PARAMETER_INVALID; |
|
69 } |
|
70 ctx = (XARadioAdaptationCtx*)bCtx; |
|
71 assert(ctx); |
|
72 |
|
73 ret = XAAdaptationBase_PostInit( &ctx->baseObj.baseObj ); |
|
74 if( ret!=XA_RESULT_SUCCESS ) |
|
75 { |
|
76 DEBUG_ERR("Base context postinit failed!!"); |
|
77 DEBUG_API("<-XARadioAdapt_PostInit"); |
|
78 return ret; |
|
79 } |
|
80 |
|
81 cmmfradiobackendengine_init(); |
|
82 |
|
83 DEBUG_API("<-XARadioAdapt_PostInit"); |
|
84 return ret; |
|
85 } |
|
86 |
|
87 /* |
|
88 * void XARadioAdapt_Destroy(XAAdaptationMMFCtx* bCtx) |
|
89 * Destroys Radio Adaptation Context |
|
90 * @param ctx - Radio Adaptation context to be destroyed |
|
91 */ |
|
92 void XARadioAdapt_Destroy(XAAdaptationBaseCtx* bCtx) |
|
93 { |
|
94 XARadioAdaptationCtx* ctx = NULL; |
|
95 DEBUG_API("->XARadioAdapt_Destroy"); |
|
96 |
|
97 cmmfradiobackendengine_delete(cmmfradiobackendengine_init()); |
|
98 |
|
99 if(bCtx == NULL || bCtx->ctxId != XARadioAdaptation ) |
|
100 { |
|
101 DEBUG_ERR("Invalid parameter!!"); |
|
102 DEBUG_API("<-XARadioAdapt_Destroy"); |
|
103 return; |
|
104 } |
|
105 ctx = (XARadioAdaptationCtx*)bCtx; |
|
106 XAAdaptationBase_Free(&(ctx->baseObj.baseObj)); |
|
107 |
|
108 free(ctx); |
|
109 |
|
110 DEBUG_API("<-XARadioAdapt_Destroy"); |
|
111 } |