19
|
1 |
/*
|
25
|
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: Nokia Linear Volume MMF impl
|
|
15 |
*
|
|
16 |
*/
|
19
|
17 |
|
|
18 |
#include "xaadaptationmmf.h"
|
|
19 |
#include "xanokialinearvolumeitfadaptationmmf.h"
|
|
20 |
#include "xamediaplayeradaptctxmmf.h"
|
|
21 |
#include "cmmfbackendengine.h"
|
21
|
22 |
#include "cmmfradiobackendengine.h"
|
|
23 |
|
19
|
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 |
*/
|
25
|
31 |
XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx,
|
|
32 |
XAuint32 percentage)
|
|
33 |
{
|
19
|
34 |
XAresult res = XA_RESULT_SUCCESS;
|
|
35 |
XAuint32 maxvol;
|
|
36 |
XAuint32 vol;
|
|
37 |
DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage);
|
25
|
38 |
if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
|
|
39 |
&& ctx->baseObj.ctxId != XAMediaRecorderAdaptation
|
|
40 |
&& ctx->baseObj.ctxId != XARadioAdaptation))
|
|
41 |
{
|
|
42 |
DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
|
19
|
43 |
/* invalid parameter */
|
25
|
44 |
res = XA_RESULT_PARAMETER_INVALID;
|
|
45 |
return res;
|
|
46 |
}
|
|
47 |
|
|
48 |
if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
|
19
|
49 |
{
|
25
|
50 |
res = mmf_volumeitf_get_maxvolume(
|
|
51 |
((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, &maxvol);
|
|
52 |
|
|
53 |
if(res == XA_RESULT_SUCCESS)
|
|
54 |
{
|
|
55 |
vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME;
|
|
56 |
res = mmf_volumeitf_set_volume(
|
|
57 |
((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, vol);
|
|
58 |
}
|
|
59 |
|
19
|
60 |
}
|
21
|
61 |
else if (ctx->baseObj.ctxId == XARadioAdaptation)
|
25
|
62 |
{
|
|
63 |
mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);
|
|
64 |
res = set_volume(cmmfradiobackendengine_init(), percentage);
|
|
65 |
}DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
|
19
|
66 |
return res;
|
25
|
67 |
}
|
19
|
68 |
|
|
69 |
XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx,
|
25
|
70 |
XAuint32* stepcount)
|
19
|
71 |
{
|
|
72 |
XAresult res = XA_RESULT_SUCCESS;
|
21
|
73 |
DEBUG_API("->XANokiaLinearVolumeItfAdapt_GetStepCount ");
|
25
|
74 |
if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
|
|
75 |
&& ctx->baseObj.ctxId != XAMediaRecorderAdaptation
|
|
76 |
&& ctx->baseObj.ctxId != XARadioAdaptation))
|
|
77 |
{
|
|
78 |
DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
|
19
|
79 |
/* invalid parameter */
|
|
80 |
return XA_RESULT_PARAMETER_INVALID;
|
25
|
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;
|
19
|
91 |
}
|
|
92 |
|
25
|
93 |
void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx,
|
|
94 |
TInt aVolume)
|
|
95 |
{
|
|
96 |
XAAdaptEvent event =
|
19
|
97 |
{
|
25
|
98 |
XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED, 1, 0
|
|
99 |
};
|
|
100 |
if (ctx)
|
|
101 |
{
|
|
102 |
event.data = &aVolume;
|
|
103 |
XAAdaptationBase_SendAdaptEvents(ctx, &event);
|
19
|
104 |
}
|
|
105 |
}
|
|
106 |
|