khronosfws/openmax_al/src/mmf_adaptation/xanokiavolumeextitfadaptationmmf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 42 1fa3fb47b1e3
--- a/khronosfws/openmax_al/src/mmf_adaptation/xanokiavolumeextitfadaptationmmf.c	Thu May 27 13:20:50 2010 +0300
+++ b/khronosfws/openmax_al/src/mmf_adaptation/xanokiavolumeextitfadaptationmmf.c	Wed Jun 23 18:47:10 2010 +0300
@@ -1,24 +1,25 @@
 /*
-* 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 Volume Ext Impl
+ *
+ */
 
 #include "xanokiavolumeextitfadaptationmmf.h"
 #include "xamediaplayeradaptctxmmf.h"
 #include "xamediarecorderadaptctxmmf.h"
 #include "cmmfbackendengine.h"
+#include "cmmfradiobackendengine.h"
 
 /*
  * XAresult XANokiaVolumeExtItfAdapt_SetMute(void *ctx, AdaptationContextIDS ctx->ctxId, XAboolean mute)
@@ -27,62 +28,77 @@
  * @param XAboolean mute - status of mute value
  * @return XAresult ret - Success value
  */
-XAresult XANokiaVolumeExtItfAdapt_SetMute(XAAdaptationMMFCtx *ctx, XAboolean mute)
-{    
+XAresult XANokiaVolumeExtItfAdapt_SetMute(XAAdaptationMMFCtx *ctx,
+        XAboolean mute)
+    {
     XAuint32 volume;
+    XAresult res = XA_RESULT_SUCCESS;
+
     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetMute");
-    if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
-                 ctx->baseObj.ctxId != XAMediaRecorderAdaptation &&
-                 ctx->baseObj.ctxId != XARadioAdaptation ) )  
-    {
+    if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
+            && ctx->baseObj.ctxId != XAMediaRecorderAdaptation
+            && ctx->baseObj.ctxId != XARadioAdaptation))
+        {
         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
         /* invalid parameter */
-        return XA_RESULT_PARAMETER_INVALID;
-    }
+        res = XA_RESULT_PARAMETER_INVALID;
+        return res;
+        }
+
+    if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+        {
+        if (mute)
+            {
 
-    if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation )
-    {
-    if(mute)
+            res = mmf_volumeitf_get_volume(
+                    ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext,
+                    &volume);
+            if(res == XA_RESULT_SUCCESS)
+                {
+                ((XAMediaPlayerAdaptationMMFCtx*) ctx)->premutevol = volume;
+                res = mmf_volumeitf_set_volume(
+                        ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, 0);
+                }
+            }
+        else
+            {
+            res = mmf_volumeitf_set_volume(
+                    ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext,
+                    ((XAMediaPlayerAdaptationMMFCtx*) ctx)->premutevol);
+            }
+        }
+    else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
         {
-        
-        mmf_volumeitf_get_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
-                                    &volume);
-        ((XAMediaPlayerAdaptationMMFCtx*)ctx)->premutevol = volume;
-        mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
-                                    0);
+        if (mute)
+            {
+
+            res = mmf_volumeitf_get_volume(
+                    ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext,
+                    &volume);
+            if(res == XA_RESULT_SUCCESS)
+                {
+                ((XAMediaRecorderAdaptationMMFCtx*) ctx)->premutevol = volume;
+                res = mmf_volumeitf_set_volume(
+                        ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext, 0);
+                }
+            }
+        else
+            {
+            res = mmf_volumeitf_set_volume(
+                    ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext,
+                    ((XAMediaRecorderAdaptationMMFCtx*) ctx)->premutevol);
+            }
         }
-    else
+    else if (ctx->baseObj.ctxId == XARadioAdaptation)
         {
-        mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
-                                    ((XAMediaPlayerAdaptationMMFCtx*)ctx)->premutevol);
+        mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);
+        res = set_mute(cmmfradiobackendengine_init(), mute);
         }
+
+    DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
+    return res;
     }
-    else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
-    {
-    if(mute)
-        {
-        
-        mmf_volumeitf_get_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
-                                    &volume);
-        ((XAMediaRecorderAdaptationMMFCtx*)ctx)->premutevol = volume;
-        mmf_volumeitf_set_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
-                                    0);
-        }
-    else
-        {
-        mmf_volumeitf_set_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
-                                    ((XAMediaRecorderAdaptationMMFCtx*)ctx)->premutevol);
-        } 
-    }
-   	else if ( ctx->baseObj.ctxId == XARadioAdaptation )
-    {
-   			
-    }
-        
-    DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
-    return XA_RESULT_SUCCESS;
-}
 
 /*
  * XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
@@ -90,31 +106,36 @@
  * @param XAboolean enable - Enable Stereo Position
  * @return XAresult - Success value
  */
-XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationMMFCtx *ctx, XAboolean enable)
-{
+XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(
+        XAAdaptationMMFCtx *ctx, XAboolean enable)
+    {
+    XAresult res = XA_RESULT_SUCCESS;
     DEBUG_API("->XANokiaVolumeExtItfAdapt_EnableStereoPosition");
 
-    if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
-                 ctx->baseObj.ctxId != XAMediaRecorderAdaptation ) )
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
+    if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
+            && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
         /* invalid parameter */
         return XA_RESULT_PARAMETER_INVALID;
-    }
-
-    if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation  )
-    {
+        }
 
-    }
-    else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
-    {
- 
-    }
+    if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+        {
+        res =  XA_RESULT_FEATURE_UNSUPPORTED;
+        }
+    else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
+        {
+        res =  XA_RESULT_FEATURE_UNSUPPORTED;
+        }
+    else if (ctx->baseObj.ctxId == XARadioAdaptation)
+        {
+        res =  XA_RESULT_FEATURE_UNSUPPORTED;
+        }
 
     DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
-    return XA_RESULT_SUCCESS;
-}
+    return res;
+    }
 
 /*
  * XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx, XApermille stereoPosition)
@@ -123,38 +144,46 @@
  * @return XAresult - Success value
  */
 XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx,
-                                            XApermille stereoPosition)
-{
+        XApermille stereoPosition)
+    {
+    XAresult res = XA_RESULT_SUCCESS;
     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetStereoPosition");
-    
-    if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
-                 ctx->baseObj.ctxId != XAMediaRecorderAdaptation ) )
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
+
+    if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
+            && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
         return XA_RESULT_PARAMETER_INVALID;
+        }
+
+    if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
+        {
+        res = XA_RESULT_FEATURE_UNSUPPORTED;
+        }
+    else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
+        {
+        res = XA_RESULT_FEATURE_UNSUPPORTED;
+        }
+    else if (ctx->baseObj.ctxId == XARadioAdaptation)
+        {
+        res = XA_RESULT_FEATURE_UNSUPPORTED;
+        }
+
+    DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
+    return res;
     }
 
-    if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation  )
+void XANokiaVolumeExtItfAdapt_MuteChange(XAAdaptationBaseCtx* ctx,
+        XAboolean aMute)
     {
-
-    }
-    else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
-    {
-
+    XAAdaptEvent event =
+        {
+        XA_NOKIAEXTVOLITFEVENTS, XA_ADAPT_VOLUME_MUTE_CHANGED, 1, 0
+        };
+    if (ctx)
+        {
+        event.data = &aMute;
+        XAAdaptationBase_SendAdaptEvents(ctx, &event);
+        }
     }
 
-    DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
-    return XA_RESULT_SUCCESS;
-}
-
-void XANokiaVolumeExtItfAdapt_MuteChange(XAAdaptationBaseCtx* ctx, XAboolean aMute)
-{
-   	XAAdaptEvent event = {XA_NOKIAEXTVOLITFEVENTS, XA_ADAPT_VOLUME_MUTE_CHANGED,1,0};    	
-    if (ctx)
- 		{
- 			event.data = &aMute;
- 			XAAdaptationBase_SendAdaptEvents(ctx, &event );
-   	}   
-}
-