khronosfws/openmax_al/src/mmf_adaptation/xanokialinearvolumeitfadaptationmmf.c
changeset 31 8dfd592727cb
parent 16 43d09473c595
child 32 94fc26b6e006
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 Linear Volume MMF impl
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 
       
    19 //#include <mixer.h>
       
    20 #include "xaadaptationmmf.h"
    18 #include "xaadaptationmmf.h"
    21 #include "xanokialinearvolumeitfadaptationmmf.h"
    19 #include "xanokialinearvolumeitfadaptationmmf.h"
    22 #include "xamediaplayeradaptctxmmf.h"
    20 #include "xamediaplayeradaptctxmmf.h"
    23 #include "cmmfbackendengine.h"
    21 #include "cmmfbackendengine.h"
       
    22 #include "cmmfradiobackendengine.h"
       
    23 
    24 /*
    24 /*
    25  * XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(void *ctx, AdaptationContextIDS ctx->baseObj.ctxId,
    25  * XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(void *ctx, AdaptationContextIDS ctx->baseObj.ctxId,
    26  *                                          XAuint32 percentage)
    26  *                                          XAuint32 percentage)
    27  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID
    27  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID
    28  * XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL
    28  * XAuint32 percentage - Requested volume level, in between MIN_VOLUME_LEVEL and MAX_VOLUME_LEVEL
    29  * @return XAresult ret - Success value
    29  * @return XAresult ret - Success value
    30  */
    30  */
    31 XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx, XAuint32 percentage)
    31 XAresult XANokiaLinearVolumeItfAdapt_SetVolumeLevel(XAAdaptationMMFCtx *ctx,
    32 {
    32         XAuint32 percentage)
       
    33     {
    33     XAresult res = XA_RESULT_SUCCESS;
    34     XAresult res = XA_RESULT_SUCCESS;
    34     XAuint32 maxvol;
    35     XAuint32 maxvol;
    35     XAuint32 vol;
    36     XAuint32 vol;
    36     DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage);
    37     DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d", percentage);
    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))
       
    41         {
       
    42         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
       
    43         /* invalid parameter */
       
    44         res = XA_RESULT_PARAMETER_INVALID;
       
    45         return res;
       
    46         }
       
    47 
       
    48     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
       
    49         {
       
    50         res = mmf_volumeitf_get_maxvolume(
       
    51                 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, &maxvol);
       
    52 
       
    53         if(res == XA_RESULT_SUCCESS)
       
    54             {
       
    55             vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME;
       
    56             res = mmf_volumeitf_set_volume(
       
    57                     ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, vol);
       
    58             }
       
    59 
       
    60         }
       
    61     else if (ctx->baseObj.ctxId == XARadioAdaptation)
       
    62         {
       
    63         mmf_set_player_adapt_context(cmmfradiobackendengine_init(), ctx);
       
    64         res = set_volume(cmmfradiobackendengine_init(), percentage);
       
    65         }DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
       
    66     return res;
       
    67     }
       
    68 
       
    69 XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx,
       
    70         XAuint32* stepcount)
    40     {
    71     {
    41         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    72     XAresult res = XA_RESULT_SUCCESS;
    42         DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
    73     DEBUG_API("->XANokiaLinearVolumeItfAdapt_GetStepCount ");
       
    74     if (!ctx || (ctx->baseObj.ctxId != XAMediaPlayerAdaptation
       
    75             && ctx->baseObj.ctxId != XAMediaRecorderAdaptation
       
    76             && ctx->baseObj.ctxId != XARadioAdaptation))
       
    77         {
       
    78         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
    43         /* invalid parameter */
    79         /* invalid parameter */
    44         return XA_RESULT_PARAMETER_INVALID;
    80         return XA_RESULT_PARAMETER_INVALID;
    45     }
    81         }
    46     
    82 
    47     if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
    83     if (ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
    48         {
    84         {
    49         mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
    85         res = mmf_volumeitf_get_maxvolume(
    50                                         &maxvol); 
    86                 ((XAMediaPlayerAdaptationMMFCtx*) ctx)->mmfContext, stepcount);
    51         
       
    52         vol = (percentage * maxvol) / MAX_PERCENTAGE_VOLUME;
       
    53         
       
    54         mmf_volumeitf_set_volume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
       
    55                                     vol);
       
    56         }
    87         }
    57     DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
    88 
       
    89     DEBUG_API("<-XANokiaLinearVolumeItfAdapt_GetStepCount");
    58     return res;
    90     return res;
    59 }
       
    60 
       
    61 XAresult XANokiaLinearVolumeItfAdapt_GetStepCount(XAAdaptationMMFCtx *ctx,
       
    62                                                     XAuint32* stepcount)
       
    63     {
       
    64     XAresult res = XA_RESULT_SUCCESS;
       
    65     DEBUG_API_A1("->XANokiaLinearVolumeItfAdapt_SetVolumeLevel to: %d",
       
    66                                                             percentage);
       
    67     if(!ctx || ( ctx->baseObj.ctxId != XAMediaPlayerAdaptation &&
       
    68                  ctx->baseObj.ctxId != XAMediaRecorderAdaptation &&
       
    69                  ctx->baseObj.ctxId != XARadioAdaptation) )
       
    70     {
       
    71         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    72         DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
       
    73         /* invalid parameter */
       
    74         return XA_RESULT_PARAMETER_INVALID;
       
    75     }
    91     }
    76 
    92 
    77     if(ctx->baseObj.ctxId == XAMediaPlayerAdaptation)
    93 void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx,
       
    94         TInt aVolume)
       
    95     {
       
    96     XAAdaptEvent event =
    78         {
    97         {
    79         mmf_volumeitf_get_maxvolume(((XAMediaPlayerAdaptationMMFCtx*)ctx)->mmfContext,
    98         XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED, 1, 0
    80                                         stepcount);
    99         };
       
   100     if (ctx)
       
   101         {
       
   102         event.data = &aVolume;
       
   103         XAAdaptationBase_SendAdaptEvents(ctx, &event);
    81         }
   104         }
    82     
       
    83     DEBUG_API("<-XANokiaLinearVolumeItfAdapt_SetVolumeLevel");
       
    84     return res;    
       
    85     }
   105     }
    86 
   106 
    87 void XANokiaLinearVolumeItfAdapt_VolumeChange(XAAdaptationBaseCtx *ctx, TInt aVolume)
       
    88 {
       
    89    	XAAdaptEvent event = {XA_NOKIALINEARVOLITFEVENTS, XA_ADAPT_VOLUME_VOLUME_CHANGED,1,0};    	
       
    90     if (ctx)
       
    91  		{
       
    92  			event.data = &aVolume;    
       
    93  			XAAdaptationBase_SendAdaptEvents(ctx, &event );
       
    94    	}   
       
    95 }
       
    96