khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c
changeset 25 6f7ceef7b1d1
parent 21 2ed61feeead6
child 28 ebf79c79991a
--- a/khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c	Fri May 28 19:26:28 2010 -0500
+++ b/khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c	Fri Jun 11 19:59:23 2010 -0500
@@ -1,22 +1,20 @@
 /*
-* 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"
@@ -30,73 +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);
+            }
+
         }
     else if (ctx->baseObj.ctxId == XARadioAdaptation)
-    	{
-		    mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);	        	
-    		res = set_volume(cmmfradiobackendengine_init(), percentage);  		    		
-    	}	    
-    DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
+        {
+        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("->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");
+    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_GetStepCount");
-    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 );
-   	}   
-}
-