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