34 // EXTERNAL DATA STRUCTURES |
34 // EXTERNAL DATA STRUCTURES |
35 |
35 |
36 // EXTERNAL FUNCTION PROTOTYPES |
36 // EXTERNAL FUNCTION PROTOTYPES |
37 |
37 |
38 // CONSTANTS |
38 // CONSTANTS |
39 #if 0 // Old constants that may be used again in the future |
39 |
40 const TInt KCamInCallToneHz = 1760; |
|
41 const TInt KCamInCallToneLen= 450000; |
|
42 _LIT( KCamSelfTimerSoundFile , "z:\\system\\sounds\\simple\\cameraappSelfTimer.rng" ); |
|
43 #endif |
|
44 |
|
45 const TReal32 KCamInCallToneVol = 0.75f; |
|
46 |
40 |
47 _LIT( KCamAutoFocusComplete, "z:\\system\\sounds\\digital\\cameraappFocusSucc.wav" ); |
41 _LIT( KCamAutoFocusComplete, "z:\\system\\sounds\\digital\\cameraappFocusSucc.wav" ); |
48 //_LIT( KCamAutoFocusFailed, "c:\\system\\sounds\\digital\\focus2.wav" ); NOT DEFINED YET |
42 //_LIT( KCamAutoFocusFailed, "c:\\system\\sounds\\digital\\focus2.wav" ); NOT DEFINED YET |
49 |
43 |
50 |
44 |
70 // |
64 // |
71 void CCamSoundPlayer::ConstructL() |
65 void CCamSoundPlayer::ConstructL() |
72 { |
66 { |
73 iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this, |
67 iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this, |
74 KAudioPriorityCameraTone, |
68 KAudioPriorityCameraTone, |
75 TMdaPriorityPreference( KAudioPrefCamera ) ); |
|
76 |
|
77 iTonePlayer = CMdaAudioToneUtility::NewL( *this, |
|
78 NULL, |
|
79 KAudioPriorityVideoRecording, |
|
80 TMdaPriorityPreference( KAudioPrefCamera ) ); |
69 TMdaPriorityPreference( KAudioPrefCamera ) ); |
81 } |
70 } |
82 |
71 |
83 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
84 // CCamSoundPlayer::NewL |
73 // CCamSoundPlayer::NewL |
220 case ECamStillCaptureSoundId4: |
207 case ECamStillCaptureSoundId4: |
221 { |
208 { |
222 StartPlaySound( KCamCaptureTone4(), aEnableCallback ); |
209 StartPlaySound( KCamCaptureTone4(), aEnableCallback ); |
223 break; |
210 break; |
224 } |
211 } |
225 #if 0 |
212 |
226 case ECamInCallToneId: |
213 case ECamSelfTimerSoundId: |
227 { |
214 { |
228 PlayTone( KCamInCallToneHz, KCamInCallToneLen, KCamInCallToneVol, aEnableCallback ); |
215 StartPlaySound( KCamSelfTimerTone(), aEnableCallback ); |
229 break; |
216 break; |
230 } |
217 } |
231 #endif |
|
232 |
218 |
233 default: |
219 default: |
234 { |
220 { |
235 // Other sounds are played using the key sound system |
|
236 #if !( defined(__WINS__) || defined(__WINSCW__) ) |
|
237 #if 0 |
|
238 iKeySoundSystem->PlaySound( aSoundId ); |
|
239 #endif |
|
240 #endif |
|
241 iEnableCallback = EFalse; |
221 iEnableCallback = EFalse; |
242 break; |
222 break; |
243 } |
223 } |
244 } |
224 } |
245 PRINT( _L("Camera <= CCamSoundPlayer::PlaySound") ); |
225 PRINT( _L("Camera <= CCamSoundPlayer::PlaySound") ); |
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CCamSoundPlayer::PlayTone |
|
250 // Plays the requested tone |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 void CCamSoundPlayer::PlayTone( TInt aToneHz, TInt aLenMicSec, TReal32 aVolume, TBool aEnableCallback ) |
|
254 { |
|
255 if ( !iOpenFileInProgress ) |
|
256 { |
|
257 iOpenFileInProgress = ETrue; |
|
258 TInt64 len = aLenMicSec; |
|
259 iTonePlayer->PrepareToPlayTone( aToneHz, TTimeIntervalMicroSeconds( len ) ); |
|
260 iTonePlayer->SetVolume( static_cast<TInt>( aVolume * iTonePlayer->MaxVolume() ) ); |
|
261 } |
|
262 else |
|
263 { |
|
264 if ( iEnableCallback ) |
|
265 { |
|
266 iObserver->PlaySoundComplete(); |
|
267 iEnableCallback = EFalse; |
|
268 } |
|
269 } |
|
270 |
|
271 iEnableCallback = aEnableCallback; |
|
272 } |
226 } |
273 |
227 |
274 |
228 |
275 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
276 // CCamSoundPlayer::StartPlaySound |
230 // CCamSoundPlayer::StartPlaySound |
306 iEnableCallback = EFalse; |
260 iEnableCallback = EFalse; |
307 } |
261 } |
308 } |
262 } |
309 |
263 |
310 // --------------------------------------------------------------------------- |
264 // --------------------------------------------------------------------------- |
311 // CCamSoundPlayer::StartPlayTone |
265 // CCamSoundPlayer::MapcInitComplete |
312 // Attempts to begin playing the specified tone |
266 // CMdaAudioPlayerUtility initialization complete |
313 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |
314 // |
268 // |
315 void CCamSoundPlayer::StartPlayTone( const TDesC& aFile, const TBool aEnableCallback ) |
269 void CCamSoundPlayer::MapcInitComplete( TInt aError, |
316 { |
270 const TTimeIntervalMicroSeconds& /*aDuration*/ ) |
317 // Check if we are already trying to open/play a tone, and stop it |
271 { |
318 // if so |
272 iOpenFileInProgress = EFalse; |
319 if ( iOpenFileInProgress ) |
273 |
320 { |
274 if ( !aError ) |
321 iTonePlayer->CancelPrepare(); |
275 { |
322 iOpenFileInProgress = EFalse; |
276 iAudioPlayer->Play(); |
|
277 } |
|
278 else |
|
279 { |
323 if ( iEnableCallback ) |
280 if ( iEnableCallback ) |
324 { |
281 { |
325 iObserver->PlaySoundComplete(); |
282 iObserver->PlaySoundComplete(); |
326 iEnableCallback = EFalse; |
283 iEnableCallback = EFalse; |
327 } |
284 } |
328 } |
|
329 else if ( iTonePlayInProgress ) |
|
330 { |
|
331 iTonePlayer->CancelPlay(); |
|
332 iTonePlayInProgress = EFalse; |
|
333 if ( iEnableCallback ) |
|
334 { |
|
335 iObserver->PlaySoundComplete(); |
|
336 iEnableCallback = EFalse; |
|
337 } |
|
338 } |
|
339 else |
|
340 { |
|
341 // empty statement to remove Lint error. |
|
342 } |
|
343 |
|
344 iEnableCallback = aEnableCallback; |
|
345 |
|
346 iOpenFileInProgress = ETrue; |
|
347 iTonePlayer->PrepareToPlayFileSequence( aFile ); |
|
348 iTonePlayer->SetVolume( static_cast<TInt>( KCamInCallToneVol * iTonePlayer->MaxVolume() ) ); |
|
349 } |
|
350 |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // CCamSoundPlayer::MapcInitComplete |
|
354 // CMdaAudioPlayerUtility initialization complete |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 void CCamSoundPlayer::MapcInitComplete( TInt aError, |
|
358 const TTimeIntervalMicroSeconds& /*aDuration*/ ) |
|
359 { |
|
360 iOpenFileInProgress = EFalse; |
|
361 |
|
362 if ( !aError ) |
|
363 { |
|
364 iAudioPlayer->Play(); |
|
365 } |
|
366 else |
|
367 { |
|
368 if ( iEnableCallback ) |
|
369 { |
|
370 iObserver->PlaySoundComplete(); |
|
371 iEnableCallback = EFalse; |
|
372 } |
|
373 } |
285 } |
374 } |
286 } |
375 |
287 |
376 |
288 |
377 // --------------------------------------------------------------------------- |
289 // --------------------------------------------------------------------------- |
380 // --------------------------------------------------------------------------- |
292 // --------------------------------------------------------------------------- |
381 // |
293 // |
382 void CCamSoundPlayer::MapcPlayComplete( TInt /*aError*/ ) |
294 void CCamSoundPlayer::MapcPlayComplete( TInt /*aError*/ ) |
383 { |
295 { |
384 if ( iEnableCallback && iObserver) |
296 if ( iEnableCallback && iObserver) |
385 { |
|
386 iObserver->PlaySoundComplete(); |
|
387 iEnableCallback = EFalse; |
|
388 } |
|
389 } |
|
390 |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 // CCamSoundPlayer::MatoPrepareComplete |
|
394 // Tone prepare complete. |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void CCamSoundPlayer::MatoPrepareComplete( TInt aError ) |
|
398 { |
|
399 iOpenFileInProgress = EFalse; |
|
400 |
|
401 if ( !aError ) |
|
402 { |
|
403 iTonePlayInProgress = ETrue; |
|
404 iTonePlayer->Play(); |
|
405 #ifdef __WINS__ |
|
406 // The tone player does not give a call back on the emulator so |
|
407 // we have to force a callback here |
|
408 MatoPlayComplete( KErrNone ); |
|
409 #endif // __WINS__ |
|
410 } |
|
411 else |
|
412 { |
|
413 if ( iEnableCallback ) |
|
414 { |
|
415 iObserver->PlaySoundComplete(); |
|
416 iEnableCallback = EFalse; |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 |
|
422 // --------------------------------------------------------------------------- |
|
423 // CCamSoundPlayer::MatoPlayComplete |
|
424 // Tone playback complete. |
|
425 // --------------------------------------------------------------------------- |
|
426 // |
|
427 void CCamSoundPlayer::MatoPlayComplete( TInt /*aError*/ ) |
|
428 { |
|
429 iTonePlayInProgress = EFalse; |
|
430 if ( iEnableCallback ) |
|
431 { |
297 { |
432 iObserver->PlaySoundComplete(); |
298 iObserver->PlaySoundComplete(); |
433 iEnableCallback = EFalse; |
299 iEnableCallback = EFalse; |
434 } |
300 } |
435 } |
301 } |
496 iKeySoundSystem->PopContext(); |
362 iKeySoundSystem->PopContext(); |
497 iAllKeysSilent = EFalse; |
363 iAllKeysSilent = EFalse; |
498 } |
364 } |
499 } |
365 } |
500 |
366 |
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // CCamSoundPlayer::CancelTonePlayer |
|
504 // Cancels any outstanding tone player activity |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void CCamSoundPlayer::CancelTonePlayer() |
|
508 { |
|
509 if ( iOpenFileInProgress && iTonePlayer ) |
|
510 { |
|
511 iTonePlayer->CancelPrepare(); |
|
512 iOpenFileInProgress = EFalse; |
|
513 |
|
514 if ( iEnableCallback && iObserver ) |
|
515 { |
|
516 iObserver->PlaySoundComplete(); |
|
517 iEnableCallback = EFalse; |
|
518 } |
|
519 } |
|
520 |
|
521 if ( iTonePlayInProgress && iTonePlayer ) |
|
522 { |
|
523 iTonePlayer->CancelPlay(); |
|
524 iTonePlayInProgress = EFalse; |
|
525 |
|
526 if ( iEnableCallback && iObserver ) |
|
527 { |
|
528 iObserver->PlaySoundComplete(); |
|
529 iEnableCallback = EFalse; |
|
530 } |
|
531 } |
|
532 } |
|
533 |
|
534 |
|
535 |
|
536 // End of File |
367 // End of File |