--- a/khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c Thu May 27 13:20:50 2010 +0300
+++ b/khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c Wed Jun 23 18:47:10 2010 +0300
@@ -1,26 +1,26 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Nokia Linear Volume MMF impl
+ *
+ */
-
-//#include <mixer.h>
#include "xaadaptationmmf.h"
#include "xanokialinearvolumeitfadaptationmmf.h"
#include "xamediaplayeradaptctxmmf.h"
#include "cmmfbackendengine.h"
+#include "cmmfradiobackendengine.h"
+
/*
* XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(void *ctx, AdaptationContextIDS ctx->baseObj.ctxId,
* XAuint32 percentage)
@@ -28,69 +28,79 @@
* XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL
* @return XAresult ret - Success value
*/
-XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx, XAuint32 percentage)
-{
+XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx,
+ XAuint32 percentage)
+ {
XAresult res = XA_RESULT_SUCCESS;
XAuint32 maxvol;
XAuint32 vol;
DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage);
- if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
- ctx->baseObj.ctxId != XAMediaRecorderAdaptation &&
- ctx->baseObj.ctxId != XARadioAdaptation) )
- {
- DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
- DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
+ if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
+ && ctx->baseObj.ctxId != XAMediaRecorderAdaptation
+ && ctx->baseObj.ctxId != XARadioAdaptation))
+ {
+ DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
/* invalid parameter */
- return XA_RESULT_PARAMETER_INVALID;
- }
-
- if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+ res = XA_RESULT_PARAMETER_INVALID;
+ return res;
+ }
+
+ if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
{
- mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
- &maxvol);
-
- vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME;
-
- mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
- vol);
+ res = mmf_volumeitf_get_maxvolume(
+ ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, &maxvol);
+
+ if(res == XA_RESULT_SUCCESS)
+ {
+ vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME;
+ res = mmf_volumeitf_set_volume(
+ ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, vol);
+ }
+
}
- DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
+ else if (ctx->baseObj.ctxId == XARadioAdaptation)
+ {
+ mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);
+ res = set_volume(cmmfradiobackendengine_init(), percentage);
+ }DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
return res;
-}
+ }
XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx,
- XAuint32* stepcount)
+ XAuint32* stepcount)
{
XAresult res = XA_RESULT_SUCCESS;
- DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d",
- percentage);
- if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
- ctx->baseObj.ctxId != XAMediaRecorderAdaptation &&
- ctx->baseObj.ctxId != XARadioAdaptation) )
- {
- DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
- DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
+ DEBUG_API("->XANokiaLinearVolumeItfAdapt_GetStepCount ");
+ if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
+ && ctx->baseObj.ctxId != XAMediaRecorderAdaptation
+ && ctx->baseObj.ctxId != XARadioAdaptation))
+ {
+ DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
/* invalid parameter */
return XA_RESULT_PARAMETER_INVALID;
+ }
+
+ if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+ {
+ res = mmf_volumeitf_get_maxvolume(
+ ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, stepcount);
+ }
+
+ DEBUG_API("<-XANokiaLinearVolumeItfAdapt_GetStepCount");
+ return res;
}
- if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx,
+ TInt aVolume)
+ {
+ XAAdaptEvent event =
{
- mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
- stepcount);
+ XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED, 1, 0
+ };
+ if (ctx)
+ {
+ event.data = &aVolume;
+ XAAdaptationBase_SendAdaptEvents(ctx, &event);
}
-
- DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
- return res;
}
-void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx, TInt aVolume)
-{
- XAAdaptEvent event = {XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED,1,0};
- if (ctx)
- {
- event.data = &aVolume;
- XAAdaptationBase_SendAdaptEvents(ctx, &event );
- }
-}
-