khronosfws/openmax_al/src/mmf_adaptation/xanokiavolumeextitfadaptationmmf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 42 1fa3fb47b1e3
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: 
    14  * Description: Nokia Volume Ext Impl
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include "xanokiavolumeextitfadaptationmmf.h"
    18 #include "xanokiavolumeextitfadaptationmmf.h"
    19 #include "xamediaplayeradaptctxmmf.h"
    19 #include "xamediaplayeradaptctxmmf.h"
    20 #include "xamediarecorderadaptctxmmf.h"
    20 #include "xamediarecorderadaptctxmmf.h"
    21 #include "cmmfbackendengine.h"
    21 #include "cmmfbackendengine.h"
       
    22 #include "cmmfradiobackendengine.h"
    22 
    23 
    23 /*
    24 /*
    24  * XAresult XANokiaVolumeExtItfAdapt_SetMute(void *ctx, AdaptationContextIDS ctx->ctxId, XAboolean mute)
    25  * XAresult XANokiaVolumeExtItfAdapt_SetMute(void *ctx, AdaptationContextIDS ctx->ctxId, XAboolean mute)
    25  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter
    26  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter
    26  * @param AdaptationContextIDS ctx->ctxId - Type specifier for context, this will be used to cast ctx pointer to correct type.
    27  * @param AdaptationContextIDS ctx->ctxId - Type specifier for context, this will be used to cast ctx pointer to correct type.
    27  * @param XAboolean mute - status of mute value
    28  * @param XAboolean mute - status of mute value
    28  * @return XAresult ret - Success value
    29  * @return XAresult ret - Success value
    29  */
    30  */
    30 XAresult XANokiaVolumeExtItfAdapt_SetMute(XAAdaptationMMFCtx *ctx, XAboolean mute)
    31 XAresult XANokiaVolumeExtItfAdapt_SetMute(XAAdaptationMMFCtx *ctx,
    31 {    
    32         XAboolean mute)
       
    33     {
    32     XAuint32 volume;
    34     XAuint32 volume;
       
    35     XAresult res = XA_RESULT_SUCCESS;
       
    36 
    33     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetMute");
    37     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetMute");
    34     if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
    38     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
    35                  ctx->baseObj.ctxId != XAMediaRecorderAdaptation &&
    39             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation
    36                  ctx->baseObj.ctxId != XARadioAdaptation ) )  
    40             && ctx->baseObj.ctxId != XARadioAdaptation))
    37     {
    41         {
    38         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    42         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    39         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
    43         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
    40         /* invalid parameter */
    44         /* invalid parameter */
    41         return XA_RESULT_PARAMETER_INVALID;
    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;
    42     }
   101     }
    43 
       
    44     if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation )
       
    45     {
       
    46     if(mute)
       
    47         {
       
    48         
       
    49         mmf_volumeitf_get_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
       
    50                                     &volume);
       
    51         ((XAMediaPlayerAdaptationMMFCtx*)ctx)->premutevol = volume;
       
    52         mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
       
    53                                     0);
       
    54         }
       
    55     else
       
    56         {
       
    57         mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
       
    58                                     ((XAMediaPlayerAdaptationMMFCtx*)ctx)->premutevol);
       
    59         }
       
    60     }
       
    61     else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
       
    62     {
       
    63     if(mute)
       
    64         {
       
    65         
       
    66         mmf_volumeitf_get_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
       
    67                                     &volume);
       
    68         ((XAMediaRecorderAdaptationMMFCtx*)ctx)->premutevol = volume;
       
    69         mmf_volumeitf_set_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
       
    70                                     0);
       
    71         }
       
    72     else
       
    73         {
       
    74         mmf_volumeitf_set_volume(((XAMediaRecorderAdaptationMMFCtx*)ctx)->mmfContext,
       
    75                                     ((XAMediaRecorderAdaptationMMFCtx*)ctx)->premutevol);
       
    76         } 
       
    77     }
       
    78    	else if ( ctx->baseObj.ctxId == XARadioAdaptation )
       
    79     {
       
    80    			
       
    81     }
       
    82         
       
    83     DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetMute");
       
    84     return XA_RESULT_SUCCESS;
       
    85 }
       
    86 
   102 
    87 /*
   103 /*
    88  * XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
   104  * XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
    89  * @param XAAdaptationBaseCtx *ctx - Adaptation context
   105  * @param XAAdaptationBaseCtx *ctx - Adaptation context
    90  * @param XAboolean enable - Enable Stereo Position
   106  * @param XAboolean enable - Enable Stereo Position
    91  * @return XAresult - Success value
   107  * @return XAresult - Success value
    92  */
   108  */
    93 XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(XAAdaptationMMFCtx *ctx, XAboolean enable)
   109 XAresult XANokiaVolumeExtItfAdapt_EnableStereoPosition(
    94 {
   110         XAAdaptationMMFCtx *ctx, XAboolean enable)
       
   111     {
       
   112     XAresult res = XA_RESULT_SUCCESS;
    95     DEBUG_API("->XANokiaVolumeExtItfAdapt_EnableStereoPosition");
   113     DEBUG_API("->XANokiaVolumeExtItfAdapt_EnableStereoPosition");
    96 
   114 
    97     if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
   115     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
    98                  ctx->baseObj.ctxId != XAMediaRecorderAdaptation ) )
   116             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
    99     {
   117         {
   100         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   118         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
   101         DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
       
   102         /* invalid parameter */
   119         /* invalid parameter */
   103         return XA_RESULT_PARAMETER_INVALID;
   120         return XA_RESULT_PARAMETER_INVALID;
   104     }
   121         }
   105 
   122 
   106     if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation  )
   123     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
   107     {
   124         {
   108 
   125         res =  XA_RESULT_FEATURE_UNSUPPORTED;
   109     }
   126         }
   110     else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
   127     else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
   111     {
   128         {
   112  
   129         res =  XA_RESULT_FEATURE_UNSUPPORTED;
   113     }
   130         }
       
   131     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
   132         {
       
   133         res =  XA_RESULT_FEATURE_UNSUPPORTED;
       
   134         }
   114 
   135 
   115     DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
   136     DEBUG_API("<-XANokiaVolumeExtItfAdapt_EnableStereoPosition");
   116     return XA_RESULT_SUCCESS;
   137     return res;
   117 }
   138     }
   118 
   139 
   119 /*
   140 /*
   120  * XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx, XApermille stereoPosition)
   141  * XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx, XApermille stereoPosition)
   121  * @param XAAdaptationBaseCtx *ctx - Adaptation context
   142  * @param XAAdaptationBaseCtx *ctx - Adaptation context
   122  * @param XApermille stereoPosition - Stereo Position to be set
   143  * @param XApermille stereoPosition - Stereo Position to be set
   123  * @return XAresult - Success value
   144  * @return XAresult - Success value
   124  */
   145  */
   125 XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx,
   146 XAresult XANokiaVolumeExtItfAdapt_SetStereoPosition(XAAdaptationMMFCtx *ctx,
   126                                             XApermille stereoPosition)
   147         XApermille stereoPosition)
   127 {
   148     {
       
   149     XAresult res = XA_RESULT_SUCCESS;
   128     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetStereoPosition");
   150     DEBUG_API("->XANokiaVolumeExtItfAdapt_SetStereoPosition");
   129     
   151 
   130     if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
   152     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
   131                  ctx->baseObj.ctxId != XAMediaRecorderAdaptation ) )
   153             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation))
   132     {
   154         {
   133         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   155         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
   134         DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   135         return XA_RESULT_PARAMETER_INVALID;
   156         return XA_RESULT_PARAMETER_INVALID;
       
   157         }
       
   158 
       
   159     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
       
   160         {
       
   161         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   162         }
       
   163     else if (ctx->baseObj.ctxId == XAMediaRecorderAdaptation)
       
   164         {
       
   165         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   166         }
       
   167     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
   168         {
       
   169         res = XA_RESULT_FEATURE_UNSUPPORTED;
       
   170         }
       
   171 
       
   172     DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   173     return res;
   136     }
   174     }
   137 
   175 
   138     if ( ctx->baseObj.ctxId == XAMediaPlayerAdaptation  )
   176 void XANokiaVolumeExtItfAdapt_MuteChange(XAAdaptationBaseCtx* ctx,
       
   177         XAboolean aMute)
   139     {
   178     {
   140 
   179     XAAdaptEvent event =
   141     }
   180         {
   142     else if ( ctx->baseObj.ctxId == XAMediaRecorderAdaptation )
   181         XA_NOKIAEXTVOLITFEVENTS, XA_ADAPT_VOLUME_MUTE_CHANGED, 1, 0
   143     {
   182         };
   144 
   183     if (ctx)
       
   184         {
       
   185         event.data = &aMute;
       
   186         XAAdaptationBase_SendAdaptEvents(ctx, &event);
       
   187         }
   145     }
   188     }
   146 
   189 
   147     DEBUG_API("<-XANokiaVolumeExtItfAdapt_SetStereoPosition");
       
   148     return XA_RESULT_SUCCESS;
       
   149 }
       
   150 
       
   151 void XANokiaVolumeExtItfAdapt_MuteChange(XAAdaptationBaseCtx* ctx, XAboolean aMute)
       
   152 {
       
   153    	XAAdaptEvent event = {XA_NOKIAEXTVOLITFEVENTS, XA_ADAPT_VOLUME_MUTE_CHANGED,1,0};    	
       
   154     if (ctx)
       
   155  		{
       
   156  			event.data = &aMute;
       
   157  			XAAdaptationBase_SendAdaptEvents(ctx, &event );
       
   158    	}   
       
   159 }
       
   160