mmfenh/enhancedmediaclient/Client/src/Components/BalanceEffect/BalanceEffectImpl.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 "BalanceEffectImpl.h"
       
    20 // For KUidInterfaceMMFAudioPlayDevice
       
    21 #include <mmf/common/mmfstandardcustomcommands.h>
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #include <mmf/common/mmfstandardcustomcommandsenums.h>
       
    24 #endif
       
    25 // For TMMFAudioConfig
       
    26 #include <mmf/common/mmfaudio.h>
       
    27 // For TMMFMessageDestinationPckg
       
    28 #include <mmf/common/mmfcontrollerframework.h>
       
    29 
       
    30 using namespace multimedia;
       
    31 
       
    32 CBalanceEffect::CBalanceEffect()
       
    33 : iBalance(KMMFBalanceCenter)
       
    34 	{
       
    35     // No Impl	
       
    36 	}
       
    37 
       
    38 CBalanceEffect::~CBalanceEffect()
       
    39 	{
       
    40     // No Impl	
       
    41 	}
       
    42 
       
    43 TInt CBalanceEffect::PostConstructor()
       
    44     {
       
    45     TRAPD( status, CEffectControlBase::ConstructL( KUidInterfaceMMFAudioPlayDevice ) );
       
    46     return status;
       
    47     }
       
    48 
       
    49 // From MControl begins
       
    50 TInt CBalanceEffect::AddObserver( MControlObserver& /*aObserver*/ )
       
    51     {
       
    52     return KErrNotSupported;
       
    53     }
       
    54 
       
    55 TInt CBalanceEffect::RemoveObserver( MControlObserver& /*aObserver*/ )
       
    56     {
       
    57     return KErrNotSupported;
       
    58     }
       
    59 
       
    60 TUid CBalanceEffect::Type()
       
    61     {
       
    62     return KBalanceEffectControl;
       
    63     }
       
    64 
       
    65 TControlType CBalanceEffect::ControlType()
       
    66     {
       
    67 	return EEffectControl;
       
    68     }
       
    69 // From MControl ends
       
    70 
       
    71 // From MEffectControl begins
       
    72 TInt CBalanceEffect::Apply()
       
    73     {
       
    74         iEnabled = true;
       
    75         return DoApply();
       
    76     }
       
    77 
       
    78 // From MEffectControl ends
       
    79 
       
    80 // From MBalanceEffect begins
       
    81 
       
    82 TInt CBalanceEffect::DoApply()
       
    83     {
       
    84     TInt error(KErrNone);    
       
    85     TMMFMessageDestination msgDest( KUidInterfaceMMFAudioPlayDevice );
       
    86     TMMFMessageDestinationPckg msgDestPckg( msgDest );
       
    87 	TPckgBuf<TMMFAudioConfig> configPackage;
       
    88 	configPackage().iBalance = iBalance;
       
    89 	error =  CEffectControlBase::CustomCommandSync( msgDestPckg,
       
    90 			                                      EMMFAudioPlayDeviceSetBalance,
       
    91                                                   configPackage,
       
    92                                                   KNullDesC8);
       
    93     return error;
       
    94     }
       
    95 
       
    96 // From MBalanceEffectt begins
       
    97 TInt CBalanceEffect::SetBalance( TInt& aBalance )
       
    98     {
       
    99     iBalance = aBalance;
       
   100     return KErrNone;
       
   101     }
       
   102 
       
   103 TInt CBalanceEffect::GetBalance( TInt& aBalance )
       
   104     {
       
   105     aBalance = iBalance;
       
   106     return KErrNone;
       
   107     }
       
   108 
       
   109 // From CEffectControlerBase begins
       
   110 
       
   111 void CBalanceEffect::Event ( TEffectControlEvent aEvent)
       
   112 	{
       
   113 	TMMFMessageDestination msgDest ( KUidInterfaceMMFAudioPlayDevice );
       
   114 	TMMFMessageDestinationPckg msgDestPckg ( msgDest );
       
   115 	TPckgBuf<TMMFAudioConfig> configPackage;
       
   116 	 // Controller loaded with ECIBuilderCreated
       
   117 	if ( aEvent == ECIBuilderCreated )
       
   118 		{
       
   119 		if ( iBalance == KMMFBalanceCenter)
       
   120 			{
       
   121 			TInt error = CEffectControlBase::CustomCommandSync(msgDestPckg,
       
   122 					                                          EMMFAudioPlayDeviceGetBalance,
       
   123 					                                          KNullDesC8,
       
   124 					                                          KNullDesC8,
       
   125 					                                          configPackage);
       
   126 			if ( !error )
       
   127 				{
       
   128 				iBalance = configPackage().iBalance;				
       
   129 				}
       
   130 			}		
       
   131 		}
       
   132 	if ( iEnabled && iBalance != KMMFBalanceCenter)
       
   133 		{		
       
   134 		DoApply();
       
   135 		}	
       
   136 	}
       
   137 
       
   138 // From CEffectControlBase ends
       
   139 
       
   140 // End of file