diff -r 2c5162224003 -r fdb31ab341af mpengine/src/mpequalizerframeworkwrapper_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpengine/src/mpequalizerframeworkwrapper_p.cpp Fri May 14 18:54:37 2010 -0500 @@ -0,0 +1,258 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrapper for equalizer framework - private implementation. +* +*/ + +// System includes +#include +#include +#include +#include +#include +#include + +// User includes +#include "mpequalizerframeworkwrapper.h" +#include "mpequalizerframeworkwrapper_p.h" +#include "mptrace.h" + +// CONSTANTS +_LIT( KMPXNullSoundPath, "\\nullsound.mp3" ); + +/*! + \class MpEqualizerFrameworkWrapperPrivate + \ingroup musicplayer + \brief Wrapper for equalizer framework - private implementation. + + This is a private implementation of the audio eqalizer wrapper + utilties interface. + +*/ + +/*! + Constructs a new MpEqualizerFrameworkWrapper with \a parent and initializes its + private imaplementation. +*/ +MpEqualizerFrameworkWrapperPrivate::MpEqualizerFrameworkWrapperPrivate( MpEqualizerFrameworkWrapper *wrapper ): + q_ptr( wrapper ), + mEqualizerUtility (NULL) +{ + TX_LOG +} + +/*! + Destructs the class. + */ +MpEqualizerFrameworkWrapperPrivate::~MpEqualizerFrameworkWrapperPrivate() +{ + TX_ENTRY + + delete mEqualizerUtility; + + if ( mMdaPlayUtility ) { + mMdaPlayUtility->Close(); + } + delete mMdaPlayUtility; + + TX_EXIT +} + +/*! + Calls the DoInit to initialize Symbian based components. + + \sa DoInitL() + */ +void MpEqualizerFrameworkWrapperPrivate::init() +{ + TX_ENTRY + + TRAPD(err, DoInitL()); + if ( err != KErrNone ) { + TX_LOG_ARGS("MpEqualizerFrameworkWrapperPrivate::init err = " << err); + } + + TX_EXIT +} + +/*! + Get the preset name key by giving preset index. + + */ +int MpEqualizerFrameworkWrapperPrivate::getPresetNameKey( int presetIndex ) +{ + TX_ENTRY_ARGS( "preset index=" << presetIndex ); + + int presetKey( KEqualizerPresetNone ); + if ( mEqualizerUtility ) { + TRAPD( err, presetKey = DoGetPresetNameKeyL( presetIndex ) ); + if ( err != KErrNone ) { + TX_LOG_ARGS("DoGetPresetNameKeyL Error = " << err); + presetKey = KEqualizerPresetNone; + } + TX_LOG_ARGS( "Preset key in engine =" << presetKey ); + } + else { + TX_LOG_ARGS( "Equalizer not ready." ); + } + + TX_EXIT_ARGS( "Preset Name Key = " << presetKey ); + + return presetKey; +} + +/*! + Get the preset index by giving preset name key. + + */ +int MpEqualizerFrameworkWrapperPrivate::getPresetIndex( int presetNameKey ) +{ + TX_ENTRY_ARGS( "Preset Name Key = " << presetNameKey); + + int presetIndex = KEqualizerPresetNone; + if ( mEqualizerUtility && presetNameKey != KEqualizerPresetNone ) { + TArray presetArray = mEqualizerUtility->Presets(); + for ( TInt i = 0; i < presetArray.Count(); i++ ) { + TX_LOG_ARGS("presetArray[" << i << "].iPresetNameKey (" + << presetArray[i].iPresetNameKey << ") vs presetId (" <( presetNameKey ) ) { + presetIndex = i; + break; + } + } + } + + TX_EXIT_ARGS( "Preset Index = " << presetIndex ); + + return presetIndex; +} + + +/*! + Returning the list of availale preset names. + + \sa CAudioEqualizerUtility + */ +QStringList MpEqualizerFrameworkWrapperPrivate::presetNames() +{ + TX_ENTRY + + QStringList presetList; + + if ( mEqualizerUtility == NULL ) { + TX_LOG_ARGS( "Equalizer not ready." ); + return presetList; + } + + TArray presetArray = mEqualizerUtility->Presets(); + for (TInt i=0; iOpenFileL( nullSoundPath ); + + TX_EXIT +} + +/*! + \internal + */ +TInt MpEqualizerFrameworkWrapperPrivate::DoGetPresetNameKeyL( const TInt presetIndex ) const +{ + TX_ENTRY_ARGS( "preset index=" << presetIndex ); + + TInt presetNameKey = KErrNotFound; + TPresetName presetName = mEqualizerUtility->GetPresetL( presetIndex ); + + TArray presets = mEqualizerUtility->Presets(); + for ( TInt index = 0; index < presets.Count(); index++ ) { + TPresetName selectedItem = presets[index].iPresetName; + TX_LOG_ARGS(" Comparing..." << presets[index].iPresetNameKey ); + if ( selectedItem == presetName ) { + presetNameKey = presets[index].iPresetNameKey; + TX_LOG_ARGS(" Comparing mached presetNameKey = " << presetNameKey ); + break; + } + } + + TX_EXIT + + return presetNameKey; +} + +/*! + \internal + */ +void MpEqualizerFrameworkWrapperPrivate::MapcInitComplete( + TInt aError, + const TTimeIntervalMicroSeconds& /* aDuration */ ) +{ + TX_ENTRY_ARGS( "aError=" << aError ); + + if ( !aError ) { + TRAPD(err, mEqualizerUtility = CAudioEqualizerUtility::NewL( *mMdaPlayUtility ) ); + if ( err == KErrNone ) { + emit q_ptr->equalizerReady(); + } + else { + TX_ENTRY_ARGS( "CAudioEquqlizerUtility error=" << err ); + } + } + else { + TX_ENTRY_ARGS( "MapcInitComplete error=" << aError ); + } + + TX_EXIT +} + +/*! + \internal + */ +void MpEqualizerFrameworkWrapperPrivate::MapcPlayComplete( + TInt /* aError */ ) +{ + TX_LOG + // Do nothing +} + +//End of File