khronosfws/openmax_al/src/mmf_adaptation/xanokiavolumeextitfadaptationmmf.c
branchRCL_3
changeset 20 0ac9a5310753
parent 19 095bea5f582e
child 21 999b2818a0eb
equal deleted inserted replaced
19:095bea5f582e 20:0ac9a5310753
     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: Nokia Volume Ext Impl
       
    15  *
       
    16  */
       
    17 
       
    18 #include "xanokiavolumeextitfadaptationmmf.h"
       
    19 #include "xamediaplayeradaptctxmmf.h"
       
    20 #include "xamediarecorderadaptctxmmf.h"
       
    21 #include "cmmfbackendengine.h"
       
    22 #include "cmmfradiobackendengine.h"
       
    23 
       
    24 /*
       
    25  * XAresult XANokiaVolumeExtItfAdapt_SetMute(void *ctx, AdaptationContextIDS ctx->ctxId, XAboolean mute)
       
    26  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter
       
    27  * @param AdaptationContextIDS ctx->ctxId - Type specifier for context, this will be used to cast ctx pointer to correct type.
       
    28  * @param XAboolean mute - status of mute value
       
    29  * @return XAresult ret - Success value
       
    30  */
       
    31 XAresult XANokiaVolumeExtItfAdapt_SetMute(XAAdaptationMMFCtx *ctx,
       
    32         XAboolean mute)
       
    33     {
       
    34     XAuint32 volume;
       
    35     XAresult res = XA_RESULT_SUCCESS;
       
    36 
       
    37     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetMute");
       
    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");
       
    43         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
       
    44         /* invalid parameter */
       
    45         res = XA_RESULT_PARAMETER_INVALID;
       
    46         return res;
       
    47         }
       
    48 
       
    49     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
       
    50         {
       
    51         if (mute)
       
    52             {
       
    53 
       
    54             res = mmf_volumeitf_get_volume(
       
    55                     ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext,
       
    56                     &volume);
       
    57             if(res == XA_RESULT_SUCCESS)
       
    58                 {
       
    59                 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->premutevol = volume;
       
    60                 res = mmf_volumeitf_set_volume(
       
    61                         ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, 0);
       
    62                 }
       
    63             }
       
    64         else
       
    65             {
       
    66             res = mmf_volumeitf_set_volume(
       
    67                     ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext,
       
    68                     ((XAMediaPlayerAdaptationMMFCtx*) ctx)->premutevol);
       
    69             }
       
    70         }
       
    71     else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
       
    72         {
       
    73         if (mute)
       
    74             {
       
    75 
       
    76             res = mmf_volumeitf_get_volume(
       
    77                     ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext,
       
    78                     &volume);
       
    79             if(res == XA_RESULT_SUCCESS)
       
    80                 {
       
    81                 ((XAMediaRecorderAdaptationMMFCtx*) ctx)->premutevol = volume;
       
    82                 res = mmf_volumeitf_set_volume(
       
    83                         ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext, 0);
       
    84                 }
       
    85             }
       
    86         else
       
    87             {
       
    88             res = mmf_volumeitf_set_volume(
       
    89                     ((XAMediaRecorderAdaptationMMFCtx*) ctx)->mmfContext,
       
    90                     ((XAMediaRecorderAdaptationMMFCtx*) ctx)->premutevol);
       
    91             }
       
    92         }
       
    93     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
    94         {
       
    95         mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);
       
    96         res = set_mute(cmmfradiobackendengine_init(), mute);
       
    97         }
       
    98 
       
    99     DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
       
   100     return res;
       
   101     }
       
   102 
       
   103 /*
       
   104  * XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
       
   105  * @param XAAdaptationBaseCtx *ctx - Adaptation context
       
   106  * @param XAboolean enable - Enable Stereo Position
       
   107  * @return XAresult - Success value
       
   108  */
       
   109 XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(
       
   110         XAAdaptationMMFCtx *ctx, XAboolean enable)
       
   111     {
       
   112     XAresult res = XA_RESULT_SUCCESS;
       
   113     DEBUG_API("->XANokiaVolumeExtItfAdapt_EnableStereoPosition");
       
   114 
       
   115     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
       
   116             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
       
   117         {
       
   118         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   119         DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
       
   120         /* invalid parameter */
       
   121         return XA_RESULT_PARAMETER_INVALID;
       
   122         }
       
   123 
       
   124     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
       
   125         {
       
   126         res =  XA_RESULT_FEATURE_UNSUPPORTED;
       
   127         }
       
   128     else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
       
   129         {
       
   130         res =  XA_RESULT_FEATURE_UNSUPPORTED;
       
   131         }
       
   132     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
   133         {
       
   134         res =  XA_RESULT_FEATURE_UNSUPPORTED;
       
   135         }
       
   136 
       
   137     DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
       
   138     return res;
       
   139     }
       
   140 
       
   141 /*
       
   142  * XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx, XApermille stereoPosition)
       
   143  * @param XAAdaptationBaseCtx *ctx - Adaptation context
       
   144  * @param XApermille stereoPosition - Stereo Position to be set
       
   145  * @return XAresult - Success value
       
   146  */
       
   147 XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx,
       
   148         XApermille stereoPosition)
       
   149     {
       
   150     XAresult res = XA_RESULT_SUCCESS;
       
   151     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   152 
       
   153     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
       
   154             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
       
   155         {
       
   156         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   157         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   158         return XA_RESULT_PARAMETER_INVALID;
       
   159         }
       
   160 
       
   161     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
       
   162         {
       
   163         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   164         }
       
   165     else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
       
   166         {
       
   167         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   168         }
       
   169     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
   170         {
       
   171         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   172         }
       
   173 
       
   174     DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   175     return res;
       
   176     }
       
   177 
       
   178 void XANokiaVolumeExtItfAdapt_MuteChange(XAAdaptationBaseCtx* ctx,
       
   179         XAboolean aMute)
       
   180     {
       
   181     XAAdaptEvent event =
       
   182         {
       
   183         XA_NOKIAEXTVOLITFEVENTS, XA_ADAPT_VOLUME_MUTE_CHANGED, 1, 0
       
   184         };
       
   185     if (ctx)
       
   186         {
       
   187         event.data = &aMute;
       
   188         XAAdaptationBase_SendAdaptEvents(ctx, &event);
       
   189         }
       
   190     }
       
   191