1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: Nokia Linear Volume MMF impl |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 //#include <mixer.h> |
|
20 #include "xaadaptationmmf.h" |
18 #include "xaadaptationmmf.h" |
21 #include "xanokialinearvolumeitfadaptationmmf.h" |
19 #include "xanokialinearvolumeitfadaptationmmf.h" |
22 #include "xamediaplayeradaptctxmmf.h" |
20 #include "xamediaplayeradaptctxmmf.h" |
23 #include "cmmfbackendengine.h" |
21 #include "cmmfbackendengine.h" |
24 #include "cmmfradiobackendengine.h" |
22 #include "cmmfradiobackendengine.h" |
28 * XAuint32 percentage) |
26 * XAuint32 percentage) |
29 * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID |
27 * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID |
30 * XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL |
28 * XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL |
31 * @return XAresult ret - Success value |
29 * @return XAresult ret - Success value |
32 */ |
30 */ |
33 XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx, XAuint32 percentage) |
31 XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx, |
34 { |
32 XAuint32 percentage) |
|
33 { |
35 XAresult res = XA_RESULT_SUCCESS; |
34 XAresult res = XA_RESULT_SUCCESS; |
36 XAuint32 maxvol; |
35 XAuint32 maxvol; |
37 XAuint32 vol; |
36 XAuint32 vol; |
38 DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage); |
37 DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage); |
39 if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation && |
38 if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation |
40 ctx->baseObj.ctxId != XAMediaRecorderAdaptation && |
39 && ctx->baseObj.ctxId != XAMediaRecorderAdaptation |
41 ctx->baseObj.ctxId != XARadioAdaptation) ) |
40 && ctx->baseObj.ctxId != XARadioAdaptation)) |
42 { |
41 { |
43 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
42 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
44 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
45 /* invalid parameter */ |
43 /* invalid parameter */ |
46 return XA_RESULT_PARAMETER_INVALID; |
44 res = XA_RESULT_PARAMETER_INVALID; |
47 } |
45 return res; |
48 |
46 } |
49 if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
47 |
|
48 if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
50 { |
49 { |
51 mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
50 res = mmf_volumeitf_get_maxvolume( |
52 &maxvol); |
51 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, &maxvol); |
53 |
52 |
54 vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME; |
53 if(res == XA_RESULT_SUCCESS) |
55 |
54 { |
56 mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
55 vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME; |
57 vol); |
56 res = mmf_volumeitf_set_volume( |
|
57 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, vol); |
|
58 } |
|
59 |
58 } |
60 } |
59 else if (ctx->baseObj.ctxId == XARadioAdaptation) |
61 else if (ctx->baseObj.ctxId == XARadioAdaptation) |
60 { |
62 { |
61 mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx); |
63 mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx); |
62 res = set_volume(cmmfradiobackendengine_init(), percentage); |
64 res = set_volume(cmmfradiobackendengine_init(), percentage); |
63 } |
65 }DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
64 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
65 return res; |
66 return res; |
66 } |
67 } |
67 |
68 |
68 XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx, |
69 XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx, |
69 XAuint32* stepcount) |
70 XAuint32* stepcount) |
70 { |
71 { |
71 XAresult res = XA_RESULT_SUCCESS; |
72 XAresult res = XA_RESULT_SUCCESS; |
72 DEBUG_API("->XANokiaLinearVolumeItfAdapt_GetStepCount "); |
73 DEBUG_API("->XANokiaLinearVolumeItfAdapt_GetStepCount "); |
73 if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation && |
74 if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation |
74 ctx->baseObj.ctxId != XAMediaRecorderAdaptation && |
75 && ctx->baseObj.ctxId != XAMediaRecorderAdaptation |
75 ctx->baseObj.ctxId != XARadioAdaptation) ) |
76 && ctx->baseObj.ctxId != XARadioAdaptation)) |
76 { |
77 { |
77 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
78 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
78 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
79 /* invalid parameter */ |
79 /* invalid parameter */ |
80 return XA_RESULT_PARAMETER_INVALID; |
80 return XA_RESULT_PARAMETER_INVALID; |
|
81 } |
|
82 |
|
83 if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
84 { |
|
85 res = mmf_volumeitf_get_maxvolume( |
|
86 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, stepcount); |
|
87 } |
|
88 |
|
89 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_GetStepCount"); |
|
90 return res; |
81 } |
91 } |
82 |
92 |
83 if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
93 void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx, |
|
94 TInt aVolume) |
|
95 { |
|
96 XAAdaptEvent event = |
84 { |
97 { |
85 mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
98 XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED, 1, 0 |
86 stepcount); |
99 }; |
|
100 if (ctx) |
|
101 { |
|
102 event.data = &aVolume; |
|
103 XAAdaptationBase_SendAdaptEvents(ctx, &event); |
87 } |
104 } |
88 |
|
89 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_GetStepCount"); |
|
90 return res; |
|
91 } |
105 } |
92 |
106 |
93 void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx, TInt aVolume) |
|
94 { |
|
95 XAAdaptEvent event = {XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED,1,0}; |
|
96 if (ctx) |
|
97 { |
|
98 event.data = &aVolume; |
|
99 XAAdaptationBase_SendAdaptEvents(ctx, &event ); |
|
100 } |
|
101 } |
|
102 |
|