|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "AudSong.h" |
|
23 #include "AudProcessor.h" |
|
24 #include "AudPanic.h" |
|
25 |
|
26 // Debug print macro |
|
27 #if defined _DEBUG |
|
28 #include <e32svr.h> |
|
29 #define PRINT(x) RDebug::Print x; |
|
30 #else |
|
31 #define PRINT(x) |
|
32 #endif |
|
33 |
|
34 |
|
35 CAudProcessor* CAudProcessor::NewL() |
|
36 { |
|
37 CAudProcessor* self = NewLC(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 CAudProcessor* CAudProcessor::NewLC() |
|
44 { |
|
45 CAudProcessor* self = new (ELeave) CAudProcessor; |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 CAudProcessor::CAudProcessor() : iProcessing(EFalse) |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 |
|
58 void CAudProcessor::ConstructL() |
|
59 { |
|
60 iClipInfoAO = CProcClipInfoAO::NewL(); |
|
61 iProcessingObject = CProcProcess::NewL(); |
|
62 iVisualizationAO = CProcVisualizationAO::NewL(); |
|
63 iTimeEstimateAO = CProcTimeEstimateAO::NewL(); |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 } |
|
69 |
|
70 |
|
71 CAudProcessor::~CAudProcessor() |
|
72 { |
|
73 PRINT((_L("CAudProcessor::~CAudProcessor() in") )); |
|
74 |
|
75 |
|
76 |
|
77 if (iVisualizationAO != 0) |
|
78 { |
|
79 delete iVisualizationAO; |
|
80 iVisualizationAO = 0; |
|
81 } |
|
82 PRINT((_L("CAudProcessor::~CAudProcessor() deleted iVisualizationAO") )); |
|
83 |
|
84 if (iProcessingObject != 0) |
|
85 { |
|
86 delete iProcessingObject; |
|
87 iProcessingObject = 0; |
|
88 } |
|
89 |
|
90 PRINT((_L("CAudProcessor::~CAudProcessor() deleted iProcessingObject") )); |
|
91 if (iClipInfoAO != 0) |
|
92 { |
|
93 delete iClipInfoAO; |
|
94 iClipInfoAO = 0; |
|
95 } |
|
96 |
|
97 PRINT((_L("CAudProcessor::~CAudProcessor() deleted iClipInfoAO") )); |
|
98 if (iTimeEstimateAO != 0) |
|
99 { |
|
100 delete iTimeEstimateAO; |
|
101 iTimeEstimateAO = 0; |
|
102 } |
|
103 |
|
104 |
|
105 PRINT((_L("CAudProcessor::~CAudProcessor() out") )); |
|
106 |
|
107 } |
|
108 |
|
109 |
|
110 |
|
111 TBool CAudProcessor::StartSyncProcessingL(const CAudSong* aSong) |
|
112 { |
|
113 |
|
114 if (iProcessing) |
|
115 { |
|
116 TAudPanic::Panic(TAudPanic::ESongProcessingOperationAlreadyRunning); |
|
117 } |
|
118 |
|
119 |
|
120 return iProcessingObject->StartSyncProcessingL(aSong); |
|
121 |
|
122 } |
|
123 |
|
124 TBool CAudProcessor::ProcessSyncPieceL(HBufC8*& aFrame, TInt& aProgress, |
|
125 TTimeIntervalMicroSeconds& aDuration) |
|
126 { |
|
127 TBool ret = iProcessingObject->ProcessSyncPieceL(aFrame, aProgress, aDuration); |
|
128 |
|
129 if (!ret) return EFalse; |
|
130 else |
|
131 { |
|
132 delete iProcessingObject; |
|
133 iProcessingObject = 0; |
|
134 return ETrue; |
|
135 } |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 /** |
|
141 * Cancel song processing. |
|
142 */ |
|
143 void CAudProcessor::CancelProcessing(MProcProcessObserver& aObserver) |
|
144 { |
|
145 |
|
146 iProcessing = EFalse; |
|
147 aObserver.NotifyAudioProcessingCompleted(KErrCancel); |
|
148 } |
|
149 |
|
150 |
|
151 void CAudProcessor::GetAudFilePropertiesL(const TDesC& aFileName, |
|
152 RFile* aFileHandle, |
|
153 TAudFileProperties* aProperties, |
|
154 MProcClipInfoObserver& aObserver, |
|
155 TInt aPriority) |
|
156 { |
|
157 |
|
158 iClipInfoAO->StartL(aFileName, aFileHandle, aObserver, aProperties, aPriority); |
|
159 } |
|
160 |
|
161 |
|
162 |
|
163 void CAudProcessor::StartGetClipVisualizationL(const CAudClipInfo* aClipInfo, TInt aSize, |
|
164 MAudVisualizationObserver& aObserver, |
|
165 TInt aPriority) |
|
166 { |
|
167 |
|
168 |
|
169 iVisualizationAO->StartClipVisualizationL(aClipInfo, aSize, aObserver, aPriority); |
|
170 |
|
171 |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 void CAudProcessor::CancelClipVisualization() |
|
177 { |
|
178 |
|
179 if (iVisualizationAO) |
|
180 { |
|
181 iVisualizationAO->CancelVisualization(); |
|
182 } |
|
183 |
|
184 } |
|
185 |
|
186 |
|
187 TBool CAudProcessor::StartTimeEstimateL(const CAudSong* aSong, MAudTimeEstimateObserver& aTEObserver) |
|
188 { |
|
189 |
|
190 if (iTimeEstimateAO) |
|
191 { |
|
192 return iTimeEstimateAO->StartL(aSong, aTEObserver); |
|
193 } |
|
194 else |
|
195 { |
|
196 return EFalse; |
|
197 } |
|
198 |
|
199 } |
|
200 |
|
201 void CAudProcessor::CancelTimeEstimate() |
|
202 { |
|
203 |
|
204 if (iTimeEstimateAO) |
|
205 { |
|
206 iTimeEstimateAO->CancelTimeEstimate(); |
|
207 } |
|
208 |
|
209 } |
|
210 |
|
211 |
|
212 |