26 |
26 |
27 #include "thumbagaudioobserver.h" |
27 #include "thumbagaudioobserver.h" |
28 #include "thumbnaillog.h" |
28 #include "thumbnaillog.h" |
29 #include "thumbnailmanagerconstants.h" |
29 #include "thumbnailmanagerconstants.h" |
30 #include "thumbnailmanagerprivatecrkeys.h" |
30 #include "thumbnailmanagerprivatecrkeys.h" |
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "thumbagaudioobserverTraces.h" |
|
34 #endif |
|
35 |
31 |
36 |
32 |
37 // --------------------------------------------------------------------------- |
33 // --------------------------------------------------------------------------- |
38 // NewLC |
34 // NewLC |
39 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
40 // |
36 // |
41 CThumbAGAudioObserver* CThumbAGAudioObserver::NewLC(CThumbAGProcessor* aProcessor) |
37 CThumbAGAudioObserver* CThumbAGAudioObserver::NewLC(CThumbAGProcessor* aProcessor) |
42 { |
38 { |
43 TN_DEBUG1( "CThumbAGAudioObserver::NewLC() - begin" ); |
39 TN_DEBUG1( "CThumbAGAudioObserver::NewLC() - begin" ); |
44 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_NEWLC, "CThumbAGAudioObserver::NewLC" ); |
|
45 |
40 |
46 CThumbAGAudioObserver* self = new (ELeave) CThumbAGAudioObserver(aProcessor); |
41 CThumbAGAudioObserver* self = new (ELeave) CThumbAGAudioObserver(aProcessor); |
47 CleanupStack::PushL( self ); |
42 CleanupStack::PushL( self ); |
48 self->ConstructL(); |
43 self->ConstructL(); |
49 return self; |
44 return self; |
77 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
78 // |
73 // |
79 void CThumbAGAudioObserver::ConstructL() |
74 void CThumbAGAudioObserver::ConstructL() |
80 { |
75 { |
81 TN_DEBUG1( "CThumbAGAudioObserver::ConstructL() - begin" ); |
76 TN_DEBUG1( "CThumbAGAudioObserver::ConstructL() - begin" ); |
82 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_CONSTRUCTL, "CThumbAGAudioObserver::ConstructL - begin" ); |
|
83 |
77 |
84 #ifdef _DEBUG |
78 #ifdef _DEBUG |
85 iAddCounter = 0; |
79 iAddCounter = 0; |
86 iModCounter = 0; |
80 iModCounter = 0; |
87 #endif |
81 #endif |
88 |
82 |
89 InitializeL(); |
83 InitializeL(); |
90 |
84 |
91 TN_DEBUG1( "CThumbAGAudioObserver::ConstructL() - end" ); |
85 TN_DEBUG1( "CThumbAGAudioObserver::ConstructL() - end" ); |
92 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_CONSTRUCTL, "CThumbAGAudioObserver::ConstructL - end" ); |
|
93 } |
86 } |
94 |
87 |
95 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
96 // ~CThumbAGAudioObserver |
89 // ~CThumbAGAudioObserver |
97 // --------------------------------------------------------------------------- |
90 // --------------------------------------------------------------------------- |
98 // |
91 // |
99 void CThumbAGAudioObserver::InitializeL() |
92 void CThumbAGAudioObserver::InitializeL() |
100 { |
93 { |
101 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - begin" ); |
94 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - begin" ); |
102 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_INITIALIZEL, "CThumbAGAudioObserver::InitializeL - begin" ); |
95 |
103 |
96 |
104 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - create observers" ); |
97 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - create observers" ); |
105 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_INITIALIZEL, "CThumbAGAudioObserver::InitializeL - create observers" ); |
|
106 |
98 |
107 // create shutdown observer |
99 // create shutdown observer |
108 if(iMDSShutdownObserver) |
100 if(iMDSShutdownObserver) |
109 { |
101 { |
110 delete iMDSShutdownObserver; |
102 delete iMDSShutdownObserver; |
141 |
132 |
142 iMdESession = CMdESession::NewL( *this ); |
133 iMdESession = CMdESession::NewL( *this ); |
143 iSessionError = EFalse; |
134 iSessionError = EFalse; |
144 |
135 |
145 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - end" ); |
136 TN_DEBUG1( "CThumbAGAudioObserver::InitializeL() - end" ); |
146 OstTrace0( TRACE_FATAL, DUP3_CTHUMBAGAUDIOOBSERVER_INITIALIZEL, "CThumbAGAudioObserver::InitializeL - end" ); |
|
147 } |
137 } |
148 |
138 |
149 // --------------------------------------------------------------------------- |
139 // --------------------------------------------------------------------------- |
150 // ~CThumbAGAudioObserver |
140 // ~CThumbAGAudioObserver |
151 // --------------------------------------------------------------------------- |
141 // --------------------------------------------------------------------------- |
152 // |
142 // |
153 CThumbAGAudioObserver::~CThumbAGAudioObserver() |
143 CThumbAGAudioObserver::~CThumbAGAudioObserver() |
154 { |
144 { |
155 TN_DEBUG1( "CThumbAGAudioObserver::~CThumbAGAudioObserver() - begin" ); |
145 TN_DEBUG1( "CThumbAGAudioObserver::~CThumbAGAudioObserver() - begin" ); |
156 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_CTHUMBAGAUDIOOBSERVER, "CThumbAGAudioObserver::~CThumbAGAudioObserver - begin" ); |
|
157 |
146 |
158 iShutdown = ETrue; |
147 iShutdown = ETrue; |
159 |
148 |
160 Shutdown(); |
149 Shutdown(); |
161 |
150 |
162 TN_DEBUG1( "CThumbAGAudioObserver::~CThumbAGAudioObserver() - end" ); |
151 TN_DEBUG1( "CThumbAGAudioObserver::~CThumbAGAudioObserver() - end" ); |
163 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_CTHUMBAGAUDIOOBSERVER, "CThumbAGAudioObserver::~CThumbAGAudioObserver - end" ); |
|
164 } |
152 } |
165 |
153 |
166 void CThumbAGAudioObserver::Shutdown() |
154 void CThumbAGAudioObserver::Shutdown() |
167 { |
155 { |
168 TN_DEBUG1( "CThumbAGAudioObserver::Shutdown()" ); |
156 TN_DEBUG1( "CThumbAGAudioObserver::Shutdown()" ); |
169 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_SHUTDOWN, "CThumbAGAudioObserver::Shutdown" ); |
|
170 |
157 |
171 delete iMDSShutdownObserver; |
158 delete iMDSShutdownObserver; |
172 iMDSShutdownObserver = NULL; |
159 iMDSShutdownObserver = NULL; |
173 delete iShutdownObserver; |
160 delete iShutdownObserver; |
174 iShutdownObserver = NULL; |
161 iShutdownObserver = NULL; |
196 // ----------------------------------------------------------------------------- |
183 // ----------------------------------------------------------------------------- |
197 // |
184 // |
198 void CThumbAGAudioObserver::HandleSessionOpened( CMdESession& /* aSession */, TInt aError ) |
185 void CThumbAGAudioObserver::HandleSessionOpened( CMdESession& /* aSession */, TInt aError ) |
199 { |
186 { |
200 TN_DEBUG1( "CThumbAGAudioObserver::HandleSessionOpened"); |
187 TN_DEBUG1( "CThumbAGAudioObserver::HandleSessionOpened"); |
201 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_HANDLESESSIONOPENED, "CThumbAGAudioObserver::HandleSessionOpened" ); |
|
202 |
188 |
203 if (aError == KErrNone) |
189 if (aError == KErrNone) |
204 { |
190 { |
205 TRAPD( err, AddObserversL() ); |
191 TRAPD( err, AddObserversL() ); |
206 if (err != KErrNone) |
192 if (err != KErrNone) |
207 { |
193 { |
208 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionOpened, AddObserversL error == %d", err ); |
194 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionOpened, AddObserversL error == %d", err ); |
209 OstTrace1( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_HANDLESESSIONOPENED, "CThumbAGAudioObserver::HandleSessionOpened;err=%d", err ); |
|
210 } |
195 } |
211 } |
196 } |
212 else |
197 else |
213 { |
198 { |
214 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionOpened error == %d", aError ); |
199 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionOpened error == %d", aError ); |
215 OstTrace1( TRACE_FATAL, DUP2_CTHUMBAGAUDIOOBSERVER_HANDLESESSIONOPENED, "CThumbAGAudioObserver::HandleSessionOpened;aError=%d", aError ); |
|
216 } |
200 } |
217 } |
201 } |
218 |
202 |
219 // ----------------------------------------------------------------------------- |
203 // ----------------------------------------------------------------------------- |
220 // CThumbAGAudioObserver::HandleSessionError |
204 // CThumbAGAudioObserver::HandleSessionError |
221 // ----------------------------------------------------------------------------- |
205 // ----------------------------------------------------------------------------- |
222 // |
206 // |
223 void CThumbAGAudioObserver::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
207 void CThumbAGAudioObserver::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
224 { |
208 { |
225 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionError == %d", aError ); |
209 TN_DEBUG2( "CThumbAGAudioObserver::HandleSessionError == %d", aError ); |
226 OstTrace1( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_HANDLESESSIONERROR, "CThumbAGAudioObserver::HandleSessionError;aError=%d", aError ); |
|
227 if (aError != KErrNone && !iSessionError) |
210 if (aError != KErrNone && !iSessionError) |
228 { |
211 { |
229 iSessionError = ETrue; |
212 iSessionError = ETrue; |
230 |
213 |
231 if (!iShutdown) |
214 if (!iShutdown) |
250 void CThumbAGAudioObserver::HandleObjectNotification( CMdESession& /*aSession*/, |
232 void CThumbAGAudioObserver::HandleObjectNotification( CMdESession& /*aSession*/, |
251 TObserverNotificationType aType, |
233 TObserverNotificationType aType, |
252 const RArray<TItemId>& aObjectIdArray ) |
234 const RArray<TItemId>& aObjectIdArray ) |
253 { |
235 { |
254 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - begin" ); |
236 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - begin" ); |
255 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - begin" ); |
|
256 |
237 |
257 // no processor or shutting down |
238 // no processor or shutting down |
258 if ( iShutdown || !iProcessor) |
239 if ( iShutdown || !iProcessor) |
259 { |
240 { |
260 return; |
241 return; |
262 |
243 |
263 #ifdef _DEBUG |
244 #ifdef _DEBUG |
264 if (aType == ENotifyAdd) |
245 if (aType == ENotifyAdd) |
265 { |
246 { |
266 TN_DEBUG2( "CThumbAGAudioObserver::HandleObjectNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
247 TN_DEBUG2( "CThumbAGAudioObserver::HandleObjectNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
267 OstTrace1( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - ENotifyAdd;aObjectIdArray.Count()=%d", aObjectIdArray.Count() ); |
|
268 iAddCounter = aObjectIdArray.Count(); |
248 iAddCounter = aObjectIdArray.Count(); |
269 } |
249 } |
270 else if (aType == ENotifyModify) |
250 else if (aType == ENotifyModify) |
271 { |
251 { |
272 TN_DEBUG2( "CThumbAGAudioObserver::HandleObjectNotification() - ENotifyModify %d", aObjectIdArray.Count() ); |
252 TN_DEBUG2( "CThumbAGAudioObserver::HandleObjectNotification() - ENotifyModify %d", aObjectIdArray.Count() ); |
273 OstTrace1( TRACE_FATAL, DUP2_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - ENotifyModify;aObjectIdArray.Count()=%d", aObjectIdArray.Count() ); |
|
274 iModCounter = aObjectIdArray.Count(); |
253 iModCounter = aObjectIdArray.Count(); |
275 } |
254 } |
276 #endif |
255 #endif |
277 |
256 |
278 if ( (aType == ENotifyAdd || aType == ENotifyModify ) && (aObjectIdArray.Count() > 0) ) |
257 if ( (aType == ENotifyAdd || aType == ENotifyModify ) && (aObjectIdArray.Count() > 0) ) |
279 { |
258 { |
280 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - AddToQueueL" ); |
259 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - AddToQueueL" ); |
281 OstTrace0( TRACE_FATAL, DUP3_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - AddToQueueL" ); |
|
282 |
260 |
283 // Add event to processing queue by type and enable force run |
261 // Add event to processing queue by type and enable force run |
284 RPointerArray<HBufC> dummyArray; |
262 RPointerArray<HBufC> dummyArray; |
285 TRAPD(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAudio, aObjectIdArray, dummyArray, EFalse)); |
263 TRAPD(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAudio, aObjectIdArray, dummyArray, EFalse)); |
286 if (err != KErrNone) |
264 if (err != KErrNone) |
287 { |
265 { |
288 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - error adding to queue" ); |
266 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - error adding to queue" ); |
289 OstTrace0( TRACE_FATAL, DUP4_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - error adding to queue" ); |
|
290 } |
267 } |
291 } |
268 } |
292 else |
269 else |
293 { |
270 { |
294 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - bad notification" ); |
271 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - bad notification" ); |
295 OstTrace0( TRACE_FATAL, DUP5_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - bad notification" ); |
|
296 } |
272 } |
297 |
273 |
298 #ifdef _DEBUG |
274 #ifdef _DEBUG |
299 TN_DEBUG3( "CThumbAGAudioObserver::IN-COUNTERS---------- Add = %d Modify = %d", iAddCounter, iModCounter ); |
275 TN_DEBUG3( "CThumbAGAudioObserver::IN-COUNTERS---------- Add = %d Modify = %d", iAddCounter, iModCounter ); |
300 OstTraceExt2( TRACE_FATAL, DUP6_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification;iAddCounter=%u;iModCounter=%u", iAddCounter, iModCounter ); |
|
301 iModCounter = 0; |
276 iModCounter = 0; |
302 iAddCounter = 0; |
277 iAddCounter = 0; |
303 #endif |
278 #endif |
304 |
279 |
305 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - end" ); |
280 TN_DEBUG1( "CThumbAGAudioObserver::HandleObjectNotification() - end" ); |
306 OstTrace0( TRACE_FATAL, DUP7_CTHUMBAGAUDIOOBSERVER_HANDLEOBJECTNOTIFICATION, "CThumbAGAudioObserver::HandleObjectNotification - end" ); |
|
307 } |
281 } |
308 |
282 |
309 // ----------------------------------------------------------------------------- |
283 // ----------------------------------------------------------------------------- |
310 // CThumbAGAudioObserver::ShutdownNotification |
284 // CThumbAGAudioObserver::ShutdownNotification |
311 // ----------------------------------------------------------------------------- |
285 // ----------------------------------------------------------------------------- |
312 // |
286 // |
313 void CThumbAGAudioObserver::ShutdownNotification() |
287 void CThumbAGAudioObserver::ShutdownNotification() |
314 { |
288 { |
315 TN_DEBUG1( "CThumbAGAudioObserver::ShutdownNotification()" ); |
289 TN_DEBUG1( "CThumbAGAudioObserver::ShutdownNotification()" ); |
316 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_SHUTDOWNNOTIFICATION, "CThumbAGAudioObserver::ShutdownNotification" ); |
|
317 |
290 |
318 if (!iShutdown) |
291 if (!iShutdown) |
319 { |
292 { |
320 TN_DEBUG1( "CThumbAGAudioObserver::ShutdownNotification() shutdown" ); |
293 TN_DEBUG1( "CThumbAGAudioObserver::ShutdownNotification() shutdown" ); |
321 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_SHUTDOWNNOTIFICATION, "CThumbAGAudioObserver::ShutdownNotification - shutdown" ); |
|
322 iShutdown = ETrue; |
294 iShutdown = ETrue; |
323 } |
295 } |
324 } |
296 } |
325 |
297 |
326 // --------------------------------------------------------------------------- |
298 // --------------------------------------------------------------------------- |
351 iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify ); |
322 iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify ); |
352 |
323 |
353 CleanupStack::Pop( 4, addCondition ); |
324 CleanupStack::Pop( 4, addCondition ); |
354 |
325 |
355 TN_DEBUG1( "CThumbAGAudioObserver::AddObserversL() - end" ); |
326 TN_DEBUG1( "CThumbAGAudioObserver::AddObserversL() - end" ); |
356 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_ADDOBSERVERSL, "CThumbAGAudioObserver::AddObserversL - end" ); |
|
357 } |
327 } |
358 |
328 |
359 // --------------------------------------------------------------------------- |
329 // --------------------------------------------------------------------------- |
360 // CThumbAGAudioObserver::ReconnectCallBack() |
330 // CThumbAGAudioObserver::ReconnectCallBack() |
361 // --------------------------------------------------------------------------- |
331 // --------------------------------------------------------------------------- |
362 // |
332 // |
363 TInt CThumbAGAudioObserver::ReconnectCallBack(TAny* aAny) |
333 TInt CThumbAGAudioObserver::ReconnectCallBack(TAny* aAny) |
364 { |
334 { |
365 TN_DEBUG1( "CThumbAGAudioObserver::ReconnectCallBack() - reinitialize"); |
335 TN_DEBUG1( "CThumbAGAudioObserver::ReconnectCallBack() - reinitialize"); |
366 OstTrace0( TRACE_FATAL, CTHUMBAGAUDIOOBSERVER_RECONNECTCALLBACK, "CThumbAGAudioObserver::ReconnectCallBack - reinitialize" ); |
|
367 |
336 |
368 CThumbAGAudioObserver* self = static_cast<CThumbAGAudioObserver*>( aAny ); |
337 CThumbAGAudioObserver* self = static_cast<CThumbAGAudioObserver*>( aAny ); |
369 |
338 |
370 self->iReconnect->Cancel(); |
339 self->iReconnect->Cancel(); |
371 |
340 |
372 // reconnect to MDS |
341 // reconnect to MDS |
373 TRAP_IGNORE( self->InitializeL() ); |
342 TRAP_IGNORE( self->InitializeL() ); |
374 |
343 |
375 TN_DEBUG1( "CThumbAGAudioObserver::ReconnectCallBack() - done"); |
344 TN_DEBUG1( "CThumbAGAudioObserver::ReconnectCallBack() - done"); |
376 OstTrace0( TRACE_FATAL, DUP1_CTHUMBAGAUDIOOBSERVER_RECONNECTCALLBACK, "CThumbAGAudioObserver::ReconnectCallBack - done" ); |
|
377 |
345 |
378 return KErrNone; |
346 return KErrNone; |
379 } |
347 } |
380 |
348 |
381 |
349 |