35
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Wrapper for equalizer framework - private implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <QDebug>
|
|
20 |
#include <QStringList>
|
|
21 |
#include <hbglobal.h>
|
|
22 |
#include <AudioEqualizerUtility.h>
|
|
23 |
#include <EqualizerConstants.h>
|
|
24 |
#include <mpxuser.h>
|
|
25 |
|
|
26 |
// User includes
|
|
27 |
#include "mpequalizerframeworkwrapper.h"
|
|
28 |
#include "mpequalizerframeworkwrapper_p.h"
|
|
29 |
#include "mptrace.h"
|
|
30 |
|
|
31 |
// CONSTANTS
|
36
|
32 |
_LIT( KMPXNullSoundPath, "\\system\\data\\nullsound.mp3" );
|
35
|
33 |
|
|
34 |
/*!
|
|
35 |
\class MpEqualizerFrameworkWrapperPrivate
|
|
36 |
\ingroup musicplayer
|
|
37 |
\brief Wrapper for equalizer framework - private implementation.
|
|
38 |
|
|
39 |
This is a private implementation of the audio eqalizer wrapper
|
|
40 |
utilties interface.
|
|
41 |
|
|
42 |
*/
|
|
43 |
|
|
44 |
/*!
|
|
45 |
Constructs a new MpEqualizerFrameworkWrapper with \a parent and initializes its
|
|
46 |
private imaplementation.
|
|
47 |
*/
|
|
48 |
MpEqualizerFrameworkWrapperPrivate::MpEqualizerFrameworkWrapperPrivate( MpEqualizerFrameworkWrapper *wrapper ):
|
|
49 |
q_ptr( wrapper ),
|
|
50 |
mEqualizerUtility (NULL)
|
|
51 |
{
|
|
52 |
TX_LOG
|
|
53 |
}
|
|
54 |
|
|
55 |
/*!
|
|
56 |
Destructs the class.
|
|
57 |
*/
|
|
58 |
MpEqualizerFrameworkWrapperPrivate::~MpEqualizerFrameworkWrapperPrivate()
|
|
59 |
{
|
|
60 |
TX_ENTRY
|
|
61 |
|
|
62 |
delete mEqualizerUtility;
|
|
63 |
|
|
64 |
if ( mMdaPlayUtility ) {
|
|
65 |
mMdaPlayUtility->Close();
|
|
66 |
}
|
|
67 |
delete mMdaPlayUtility;
|
|
68 |
|
|
69 |
TX_EXIT
|
|
70 |
}
|
|
71 |
|
|
72 |
/*!
|
|
73 |
Calls the DoInit to initialize Symbian based components.
|
|
74 |
|
|
75 |
\sa DoInitL()
|
|
76 |
*/
|
|
77 |
void MpEqualizerFrameworkWrapperPrivate::init()
|
|
78 |
{
|
|
79 |
TX_ENTRY
|
|
80 |
|
|
81 |
TRAPD(err, DoInitL());
|
|
82 |
if ( err != KErrNone ) {
|
|
83 |
TX_LOG_ARGS("MpEqualizerFrameworkWrapperPrivate::init err = " << err);
|
|
84 |
}
|
|
85 |
|
|
86 |
TX_EXIT
|
|
87 |
}
|
|
88 |
|
|
89 |
/*!
|
|
90 |
Get the preset name key by giving preset index.
|
|
91 |
|
|
92 |
*/
|
|
93 |
int MpEqualizerFrameworkWrapperPrivate::getPresetNameKey( int presetIndex )
|
|
94 |
{
|
|
95 |
TX_ENTRY_ARGS( "preset index=" << presetIndex );
|
|
96 |
|
|
97 |
int presetKey( KEqualizerPresetNone );
|
|
98 |
if ( mEqualizerUtility ) {
|
|
99 |
TRAPD( err, presetKey = DoGetPresetNameKeyL( presetIndex ) );
|
|
100 |
if ( err != KErrNone ) {
|
|
101 |
TX_LOG_ARGS("DoGetPresetNameKeyL Error = " << err);
|
|
102 |
presetKey = KEqualizerPresetNone;
|
|
103 |
}
|
|
104 |
TX_LOG_ARGS( "Preset key in engine =" << presetKey );
|
|
105 |
}
|
|
106 |
else {
|
|
107 |
TX_LOG_ARGS( "Equalizer not ready." );
|
|
108 |
}
|
|
109 |
|
|
110 |
TX_EXIT_ARGS( "Preset Name Key = " << presetKey );
|
|
111 |
|
|
112 |
return presetKey;
|
|
113 |
}
|
|
114 |
|
|
115 |
/*!
|
|
116 |
Get the preset index by giving preset name key.
|
|
117 |
|
|
118 |
*/
|
|
119 |
int MpEqualizerFrameworkWrapperPrivate::getPresetIndex( int presetNameKey )
|
|
120 |
{
|
|
121 |
TX_ENTRY_ARGS( "Preset Name Key = " << presetNameKey);
|
|
122 |
|
51
|
123 |
int presetIndex = 0;
|
35
|
124 |
if ( mEqualizerUtility && presetNameKey != KEqualizerPresetNone ) {
|
|
125 |
TArray<TEfAudioEqualizerUtilityPreset> presetArray = mEqualizerUtility->Presets();
|
|
126 |
for ( TInt i = 0; i < presetArray.Count(); i++ ) {
|
|
127 |
TX_LOG_ARGS("presetArray[" << i << "].iPresetNameKey ("
|
|
128 |
<< presetArray[i].iPresetNameKey << ") vs presetId (" <<presetNameKey << ")");
|
|
129 |
if ( presetArray[i].iPresetNameKey == static_cast<TUint32>( presetNameKey ) ) {
|
51
|
130 |
//Set the current preset index. 1 is added to index because index 0 represent "Off" at UI level.
|
|
131 |
presetIndex = i+1;
|
35
|
132 |
break;
|
|
133 |
}
|
|
134 |
}
|
|
135 |
}
|
|
136 |
|
|
137 |
TX_EXIT_ARGS( "Preset Index = " << presetIndex );
|
|
138 |
|
|
139 |
return presetIndex;
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
/*!
|
|
144 |
Returning the list of availale preset names.
|
|
145 |
|
|
146 |
\sa CAudioEqualizerUtility
|
|
147 |
*/
|
|
148 |
QStringList MpEqualizerFrameworkWrapperPrivate::presetNames()
|
|
149 |
{
|
|
150 |
TX_ENTRY
|
|
151 |
|
|
152 |
QStringList presetList;
|
|
153 |
|
|
154 |
if ( mEqualizerUtility == NULL ) {
|
|
155 |
TX_LOG_ARGS( "Equalizer not ready." );
|
|
156 |
return presetList;
|
|
157 |
}
|
|
158 |
|
|
159 |
TArray<TEfAudioEqualizerUtilityPreset> presetArray = mEqualizerUtility->Presets();
|
|
160 |
for (TInt i=0; i<presetArray.Count(); i++) {
|
|
161 |
TPresetName selectedItem = presetArray[i].iPresetName;
|
|
162 |
presetList << QString::fromUtf16( selectedItem.Ptr(), selectedItem.Length() );
|
|
163 |
}
|
|
164 |
|
|
165 |
TX_EXIT_ARGS( "PresetNames=" << presetList);
|
|
166 |
|
|
167 |
return presetList;
|
|
168 |
}
|
|
169 |
|
|
170 |
/*!
|
|
171 |
\internal
|
|
172 |
*/
|
|
173 |
void MpEqualizerFrameworkWrapperPrivate::DoInitL()
|
|
174 |
{
|
|
175 |
TX_ENTRY
|
|
176 |
|
|
177 |
if (mMdaPlayUtility) {
|
|
178 |
mMdaPlayUtility->Close();
|
|
179 |
delete mMdaPlayUtility;
|
|
180 |
mMdaPlayUtility = NULL;
|
|
181 |
}
|
|
182 |
|
|
183 |
mMdaPlayUtility = ( CMdaAudioPlayerUtility* )User::LeaveIfNull(
|
|
184 |
CMdaAudioPlayerUtility::NewL(
|
|
185 |
*this,
|
|
186 |
EMdaPriorityMin,
|
|
187 |
EMdaPriorityPreferenceNone ));
|
|
188 |
|
|
189 |
TX_LOG_ARGS("Loading null sound");
|
|
190 |
TFileName nullSoundPath( KMPXNullSoundPath );
|
|
191 |
User::LeaveIfError( MPXUser::CompleteWithDllPath( nullSoundPath ) );
|
|
192 |
TX_LOG_ARGS("Loading null sound done!");
|
|
193 |
mMdaPlayUtility->OpenFileL( nullSoundPath );
|
|
194 |
|
|
195 |
TX_EXIT
|
|
196 |
}
|
|
197 |
|
|
198 |
/*!
|
|
199 |
\internal
|
|
200 |
*/
|
|
201 |
TInt MpEqualizerFrameworkWrapperPrivate::DoGetPresetNameKeyL( const TInt presetIndex ) const
|
|
202 |
{
|
|
203 |
TX_ENTRY_ARGS( "preset index=" << presetIndex );
|
|
204 |
|
|
205 |
TInt presetNameKey = KErrNotFound;
|
|
206 |
TPresetName presetName = mEqualizerUtility->GetPresetL( presetIndex );
|
|
207 |
|
|
208 |
TArray<TEfAudioEqualizerUtilityPreset> presets = mEqualizerUtility->Presets();
|
|
209 |
for ( TInt index = 0; index < presets.Count(); index++ ) {
|
|
210 |
TPresetName selectedItem = presets[index].iPresetName;
|
|
211 |
TX_LOG_ARGS(" Comparing..." << presets[index].iPresetNameKey );
|
|
212 |
if ( selectedItem == presetName ) {
|
|
213 |
presetNameKey = presets[index].iPresetNameKey;
|
|
214 |
TX_LOG_ARGS(" Comparing mached presetNameKey = " << presetNameKey );
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
}
|
|
218 |
|
|
219 |
TX_EXIT
|
|
220 |
|
|
221 |
return presetNameKey;
|
|
222 |
}
|
|
223 |
|
|
224 |
/*!
|
|
225 |
\internal
|
|
226 |
*/
|
|
227 |
void MpEqualizerFrameworkWrapperPrivate::MapcInitComplete(
|
|
228 |
TInt aError,
|
|
229 |
const TTimeIntervalMicroSeconds& /* aDuration */ )
|
|
230 |
{
|
|
231 |
TX_ENTRY_ARGS( "aError=" << aError );
|
|
232 |
|
|
233 |
if ( !aError ) {
|
|
234 |
TRAPD(err, mEqualizerUtility = CAudioEqualizerUtility::NewL( *mMdaPlayUtility ) );
|
|
235 |
if ( err == KErrNone ) {
|
|
236 |
emit q_ptr->equalizerReady();
|
|
237 |
}
|
|
238 |
else {
|
|
239 |
TX_ENTRY_ARGS( "CAudioEquqlizerUtility error=" << err );
|
|
240 |
}
|
|
241 |
}
|
|
242 |
else {
|
|
243 |
TX_ENTRY_ARGS( "MapcInitComplete error=" << aError );
|
|
244 |
}
|
|
245 |
|
|
246 |
TX_EXIT
|
|
247 |
}
|
|
248 |
|
|
249 |
/*!
|
|
250 |
\internal
|
|
251 |
*/
|
|
252 |
void MpEqualizerFrameworkWrapperPrivate::MapcPlayComplete(
|
|
253 |
TInt /* aError */ )
|
|
254 |
{
|
|
255 |
TX_LOG
|
|
256 |
// Do nothing
|
|
257 |
}
|
|
258 |
|
|
259 |
//End of File
|