mmfenh/enhancedmediaclient/Client/src/Components/VolumeEffect/VolumeEffectImpl.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Project file for EnhancedMediaClient Utility
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "VolumeEffectImpl.h"
       
    20 // For KUidInterfaceMMFAudioPlayDevice
       
    21 #include <mmf/common/mmfstandardcustomcommands.h>
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #include <mmf/common/mmfstandardcustomcommandsimpl.h>
       
    24 #include <mmf/common/mmfstandardcustomcommandsenums.h>
       
    25 #endif
       
    26 // For TMMFAudioConfig
       
    27 #include <mmf/common/mmfaudio.h>
       
    28 // For TMMFMessageDestinationPckg
       
    29 #include <mmf/common/mmfcontrollerframework.h>
       
    30 
       
    31 
       
    32 using namespace multimedia;
       
    33 
       
    34 CVolumeEffect::CVolumeEffect()
       
    35 : iVolume(KErrUnknown)
       
    36     ,iRampDuration(0)
       
    37     ,iEnabled(false)
       
    38     {
       
    39     // No Impl
       
    40     }
       
    41 
       
    42 CVolumeEffect::~CVolumeEffect()
       
    43     {
       
    44     // No Impl
       
    45     }
       
    46 
       
    47 TInt CVolumeEffect::PostConstructor()
       
    48     {
       
    49     TRAPD( status, CEffectControlBase::ConstructL( KUidInterfaceMMFAudioPlayDevice ) );
       
    50     return status;
       
    51     }
       
    52 
       
    53 // From MControl begins
       
    54 TInt CVolumeEffect::AddObserver( MControlObserver& /*aObserver*/ )
       
    55     {
       
    56     return KErrNotSupported;
       
    57     }
       
    58 
       
    59 TInt CVolumeEffect::RemoveObserver( MControlObserver& /*aObserver*/ )
       
    60     {
       
    61     return KErrNotSupported;
       
    62     }
       
    63 
       
    64 TUid CVolumeEffect::Type()
       
    65     {
       
    66     return KVolumeEffectControl;
       
    67     }
       
    68 
       
    69 TControlType CVolumeEffect::ControlType()
       
    70     {
       
    71 	return EEffectControl;
       
    72     }
       
    73 
       
    74 // From MControl ends
       
    75 
       
    76 // From MEffectControl begins
       
    77 TInt CVolumeEffect::Apply()
       
    78     {
       
    79         iEnabled = true;
       
    80         return DoApply();
       
    81     }
       
    82 
       
    83 // From MEffectControl ends
       
    84 
       
    85 TInt CVolumeEffect::DoApply()
       
    86     {
       
    87     TInt error(KErrNone);    
       
    88     TMMFMessageDestination msgDest( KUidInterfaceMMFAudioPlayDevice );
       
    89     TMMFMessageDestinationPckg msgDestPckg( msgDest );
       
    90 	TPckgBuf<TMMFAudioConfig> configPackage;
       
    91 	configPackage().iVolume = iVolume;
       
    92 	error =  CEffectControlBase::CustomCommandSync( msgDestPckg,
       
    93                                                   EMMFAudioPlayDeviceSetVolume,
       
    94                                                   configPackage,
       
    95                                                   KNullDesC8);
       
    96     
       
    97     
       
    98     
       
    99     if(iRampDuration > 0)
       
   100         {
       
   101         configPackage().iRampDuration = iRampDuration;
       
   102     	error =  CEffectControlBase::CustomCommandSync( msgDestPckg, 
       
   103                										 EMMFAudioPlayDeviceSetVolumeRamp, 
       
   104               										 configPackage,
       
   105                										 KNullDesC8);  
       
   106     	}
       
   107     
       
   108     return error;    
       
   109     }
       
   110 
       
   111 
       
   112 
       
   113 // From MVolumeEffect begins
       
   114 TInt CVolumeEffect::SetVolume( TInt& aVolume )
       
   115     {
       
   116     iVolume = aVolume;
       
   117     return KErrNone;
       
   118     }
       
   119 
       
   120 TInt CVolumeEffect::GetVolume( TInt& aVolume )
       
   121     {    
       
   122     aVolume = iVolume;
       
   123     return KErrNone;
       
   124     }
       
   125 
       
   126 TInt CVolumeEffect::GetMaxVolume( TInt& aVolume )
       
   127     {
       
   128     TMMFMessageDestination msgDest( KUidInterfaceMMFAudioPlayDevice );
       
   129     TMMFMessageDestinationPckg msgDestPckg( msgDest );
       
   130 	TPckgBuf<TMMFAudioConfig> configPackage;
       
   131 	TInt error =  CEffectControlBase::CustomCommandSync( msgDestPckg, 
       
   132                                                          EMMFAudioPlayDeviceGetMaxVolume, 
       
   133                                                          KNullDesC8,
       
   134                                                          KNullDesC8,
       
   135                                                          configPackage );
       
   136 	if (!error)
       
   137 		aVolume = configPackage().iMaxVolume;
       
   138 	
       
   139 	return error;
       
   140     
       
   141     }
       
   142 
       
   143 TInt CVolumeEffect::GetMinVolume( TInt& aMinVolume )
       
   144     {
       
   145     aMinVolume = 0;
       
   146     return KErrNone;
       
   147     }
       
   148 
       
   149 TInt CVolumeEffect::GetDefaultVolume( TInt& aDefaultVolume )
       
   150     {
       
   151     TInt maxVol=0;    
       
   152     TInt err = GetMaxVolume(maxVol);
       
   153     if(err)
       
   154         return err;
       
   155         
       
   156     aDefaultVolume = (maxVol)/2;
       
   157     return KErrNone;
       
   158     }
       
   159 
       
   160 TInt CVolumeEffect::SetVolumeRamp(TInt /*aInitialVol*/,TInt aFinalVol,TUint64& aDuration,TVolumeRampMode /*aMode*/)
       
   161     {
       
   162     iVolume = aFinalVol;    
       
   163     iRampDuration = aDuration;
       
   164     return KErrNone;
       
   165     }
       
   166 
       
   167 // From CEffectControlBase begins
       
   168 void CVolumeEffect::Event( TEffectControlEvent aEvent )
       
   169     {
       
   170     TMMFMessageDestination msgDest( KUidInterfaceMMFAudioPlayDevice );
       
   171     TMMFMessageDestinationPckg msgDestPckg( msgDest );
       
   172 	TPckgBuf<TMMFAudioConfig> configPackage;
       
   173         // Controller Loaded with ECIBuilderCreated
       
   174     if ( aEvent == ECIBuilderCreated )
       
   175         {
       
   176 		if(iVolume == KErrUnknown)
       
   177 			{
       
   178 			TPckgBuf<TMMFAudioConfig> configPackage;
       
   179 			TInt error =  CEffectControlBase::CustomCommandSync(msgDestPckg, 
       
   180 														EMMFAudioPlayDeviceGetVolume, 
       
   181 														KNullDesC8,
       
   182 														KNullDesC8,
       
   183 														configPackage);
       
   184 	
       
   185 			if (!error)
       
   186 				{
       
   187 				iVolume = configPackage().iVolume;
       
   188 				}
       
   189 			}
       
   190 		}
       
   191 	        	
       
   192     if(iEnabled && iVolume != KErrUnknown)
       
   193         {
       
   194         DoApply();
       
   195         }
       
   196     }
       
   197 
       
   198 // From CEffectControlBase ends
       
   199 
       
   200 // End of file