|
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 |
|
19 //#include <mixer.h> |
|
20 #include "xaadaptationmmf.h" |
|
21 #include "xanokialinearvolumeitfadaptationmmf.h" |
|
22 #include "xamediaplayeradaptctxmmf.h" |
|
23 #include "cmmfbackendengine.h" |
|
24 /* |
|
25 * XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(void *ctx, AdaptationContextIDS ctx->baseObj.ctxId, |
|
26 * XAuint32 percentage) |
|
27 * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID |
|
28 * XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL |
|
29 * @return XAresult ret - Success value |
|
30 */ |
|
31 XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx, XAuint32 percentage) |
|
32 { |
|
33 XAresult res = XA_RESULT_SUCCESS; |
|
34 XAuint32 maxvol; |
|
35 XAuint32 vol; |
|
36 DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage); |
|
37 if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation && |
|
38 ctx->baseObj.ctxId != XAMediaRecorderAdaptation && |
|
39 ctx->baseObj.ctxId != XARadioAdaptation) ) |
|
40 { |
|
41 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
42 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
43 /* invalid parameter */ |
|
44 return XA_RESULT_PARAMETER_INVALID; |
|
45 } |
|
46 |
|
47 if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
48 { |
|
49 mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
|
50 &maxvol); |
|
51 |
|
52 vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME; |
|
53 |
|
54 mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
|
55 vol); |
|
56 } |
|
57 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
58 return res; |
|
59 } |
|
60 |
|
61 XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx, |
|
62 XAuint32* stepcount) |
|
63 { |
|
64 XAresult res = XA_RESULT_SUCCESS; |
|
65 DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", |
|
66 percentage); |
|
67 if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation && |
|
68 ctx->baseObj.ctxId != XAMediaRecorderAdaptation && |
|
69 ctx->baseObj.ctxId != XARadioAdaptation) ) |
|
70 { |
|
71 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
72 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
73 /* invalid parameter */ |
|
74 return XA_RESULT_PARAMETER_INVALID; |
|
75 } |
|
76 |
|
77 if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation) |
|
78 { |
|
79 mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext, |
|
80 stepcount); |
|
81 } |
|
82 |
|
83 DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel"); |
|
84 return res; |
|
85 } |
|
86 |
|
87 void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx, TInt aVolume) |
|
88 { |
|
89 XAAdaptEvent event = {XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED,1,0}; |
|
90 if (ctx) |
|
91 { |
|
92 event.data = &aVolume; |
|
93 XAAdaptationBase_SendAdaptEvents(ctx, &event ); |
|
94 } |
|
95 } |
|
96 |