|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Group for effect controls |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 #include "cammsemcequalizerenvironmentalpresetutility.h" |
|
22 |
|
23 const TInt KAMMSEMCPresetGranularity = 5; |
|
24 |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 // Constructors |
|
29 |
|
30 CAMMSEMCEqualizerEnvironmentalPresetUtility::CAMMSEMCEqualizerEnvironmentalPresetUtility() |
|
31 { |
|
32 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility:: CAMMSEMCEqualizerEnvironmentalPresetUtility()"); |
|
33 } |
|
34 |
|
35 // Destructor |
|
36 CAMMSEMCEqualizerEnvironmentalPresetUtility::~CAMMSEMCEqualizerEnvironmentalPresetUtility() |
|
37 { |
|
38 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::~ +"); |
|
39 delete iPresetNames; |
|
40 if (iEmptyEqualizerUtility) |
|
41 { |
|
42 TRAPD(err,iEmptyEqualizerUtility ->DisableEqualizerL()); |
|
43 if (err) |
|
44 { |
|
45 // The only even theoritically possible error code here would be |
|
46 // KErrAccessDenied which is a result from Effect API calling ApplyL |
|
47 // method without having update rights, but since the Utility |
|
48 // class is already created, that situation can be discarded here. |
|
49 } |
|
50 delete iEmptyEqualizerUtility; |
|
51 iEmptyEqualizerUtility = NULL; |
|
52 } |
|
53 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::~ -"); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetAtIndexL |
|
58 // Gets the current preset. |
|
59 // (other items were commented in a header). |
|
60 // ----------------------------------------------------------------------------- |
|
61 void CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetAtIndexL(TDes& aPreset ,TInt iIndex) |
|
62 { |
|
63 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetAtIndexL +"); |
|
64 // Return KNullDesC if no preset is set. |
|
65 if (iIndex >= 0) |
|
66 { |
|
67 |
|
68 TArray< TEfAudioEqualizerUtilityPreset > presetNames = |
|
69 iEmptyEqualizerUtility->Presets(); |
|
70 aPreset = presetNames[ iIndex ].iPresetName ; |
|
71 |
|
72 } |
|
73 else |
|
74 { |
|
75 aPreset = KNullDesC; |
|
76 } |
|
77 |
|
78 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetAtIndexL -"); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CAMMSEMCEqualizerEnvironmentalPresetUtility::PrepareEmptyEqualizerUtilitiesL |
|
83 // Creates utilities that can be used to obtain preset names and preset data. |
|
84 // (other items were commented in a header). |
|
85 // ----------------------------------------------------------------------------- |
|
86 void CAMMSEMCEqualizerEnvironmentalPresetUtility::PrepareEmptyEqualizerUtilitiesL() |
|
87 { |
|
88 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::PrepareEmptyEqualizerUtilitiesL +"); |
|
89 //Calling base class function to create and initialize the CMMFDevSound |
|
90 CreateAndInitializeDevSoundL(); |
|
91 if (!iEmptyEqualizerUtility) |
|
92 { |
|
93 iEmptyEqualizerUtility = |
|
94 CAudioEqualizerUtility::NewL(*iMMFDevSound); |
|
95 } |
|
96 |
|
97 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::PrepareEmptyEqualizerUtilitiesL -"); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CAMMSEMCEqualizerEnvironmentalPresetUtility::DeleteEmptyEqualizerUtilities |
|
102 // Deletes utilities that are used to obtain preset names and preset data. |
|
103 // (other items were commented in a header). |
|
104 // ----------------------------------------------------------------------------- |
|
105 void CAMMSEMCEqualizerEnvironmentalPresetUtility::DeleteEmptyEqualizerUtilities() |
|
106 { |
|
107 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::DeleteEmptyEqualizerUtilities +"); |
|
108 |
|
109 if (iEmptyEqualizerUtility) |
|
110 { |
|
111 TRAPD(err,iEmptyEqualizerUtility ->DisableEqualizerL()); |
|
112 if (err) |
|
113 { |
|
114 // The only even theoritically possible error code here would be |
|
115 // KErrAccessDenied which is a result from Effect API calling ApplyL |
|
116 // method without having update rights, but since the Utility |
|
117 // class is already created, that situation can be discarded here. |
|
118 } |
|
119 delete iEmptyEqualizerUtility; |
|
120 iEmptyEqualizerUtility = NULL; |
|
121 } |
|
122 |
|
123 //Calling base class function to delete CMMFDevSound object to free memory |
|
124 DeleteDevSound(); |
|
125 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::DeleteEmptyEqualizerUtilities -"); |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetNamesL |
|
131 // Gets list of preset names available. |
|
132 // (other items were commented in a header). |
|
133 // ----------------------------------------------------------------------------- |
|
134 void CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetNamesL( |
|
135 CDesCArray& aPresetNames) |
|
136 { |
|
137 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetNamesL +"); |
|
138 TArray< TEfAudioEqualizerUtilityPreset > presetNames = |
|
139 iEmptyEqualizerUtility->Presets(); |
|
140 TInt presetCount = presetNames.Count(); |
|
141 for (TInt i = 0; i < presetCount; i++) |
|
142 { |
|
143 aPresetNames.AppendL(presetNames[ i ].iPresetName); |
|
144 } |
|
145 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::GetPresetNamesL -"); |
|
146 } |
|
147 |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CAMMSEMCEqualizerEnvironmentalPresetUtility::GetEqualizerAtPresetIndexL |
|
151 // Gets list of preset names available. |
|
152 // (other items were commented in a header). |
|
153 // ----------------------------------------------------------------------------- |
|
154 CAudioEqualizer * CAMMSEMCEqualizerEnvironmentalPresetUtility::GetEqualizerAtPresetIndexL(TInt iIndex) |
|
155 { |
|
156 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::GetEqualizerAtPresetIndexL, index=%d", |
|
157 iIndex); |
|
158 |
|
159 __ASSERT_DEBUG(iIndex >= 0, User::Invariant()); |
|
160 |
|
161 // Set the preset to the empty Environmental Equalizer utility. |
|
162 iEmptyEqualizerUtility->GetPresetL(iIndex); |
|
163 return &(iEmptyEqualizerUtility->Equalizer()); |
|
164 |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CAMMSEMCEqualizerEnvironmentalPresetUtility::ConstructL |
|
170 // Symbian 2nd phase constructor can leave. |
|
171 // (other items were commented in a header). |
|
172 // ----------------------------------------------------------------------------- |
|
173 void CAMMSEMCEqualizerEnvironmentalPresetUtility::ConstructL() |
|
174 { |
|
175 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEMCEqualizerEnvironmentalPresetUtility::ConstructL"); |
|
176 iPresetNames = new(ELeave)CDesCArrayFlat(KAMMSEMCPresetGranularity); |
|
177 CAMMSEMCBaseMMFDevSound ::ConstructL(); |
|
178 } |
|
179 |
|
180 // End of File |