controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/tonepreviewprivate.cpp
changeset 25 19394c261aa5
parent 24 f5dfdd5e4a1b
child 27 848a3adde87f
child 31 e79ce701c376
equal deleted inserted replaced
24:f5dfdd5e4a1b 25:19394c261aa5
     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:
       
    15  *     The source file for tone previewing.
       
    16  *     
       
    17  */
       
    18 #include "tonepreviewprivate.h"
       
    19 #include "tonefetcherutils.h"
       
    20 #include <AudioPreference.h>             // KAudioPriorityPreview
       
    21 #include <c3dringingtoneinterface.h>     // C3DRingingToneInterface
       
    22 #include <ctsydomainpskeys.h>            // for phone call states
       
    23 #include <MProfileEngine.h>
       
    24 #include <MProfile.h>
       
    25 #include <MProfileTones.h>
       
    26 #include "TProfileToneSettings.h"
       
    27 #include <MProfileExtraSettings.h>
       
    28 #include <MProfile3DToneSettings.h>
       
    29 #include <ProfileInternal.hrh>
       
    30 #include <ProfileEngineDomainCRKeys.h>   // KProEngDefaultRingingTone
       
    31 #include <XQConversions>
       
    32 #include <QChar>
       
    33 
       
    34 CMFPreviewHandlerBase::CMFPreviewHandlerBase( QObject *parent  ) : QObject( parent )
       
    35     {
       
    36     iMediaType = KErrNotFound;
       
    37     iRingingVolume = KErrNotFound;
       
    38     iRingingType = KErrNotFound;
       
    39     iVibra = KErrNotFound;
       
    40     i3DEffect = KErrNotFound;
       
    41     i3DEcho = KErrNotFound;
       
    42     iFileSize = KErrNotFound;    
       
    43     iFullName = 0;    
       
    44     iActiveProfileRead = EFalse;
       
    45     iPlayerStatus = EPlayerNotCreated;
       
    46 
       
    47     }
       
    48 
       
    49 void CMFPreviewHandlerBase::ConstructL()
       
    50     {
       
    51     // To allow/not allow screensaver
       
    52     // Errors ignored, no actions needed if API is not available
       
    53     //iProperty.Attach( KPSUidScreenSaver, KScreenSaverAllowScreenSaver );    
       
    54     TRAP_IGNORE(User::LeaveIfError( iApaSession.Connect() ) );
       
    55     
       
    56     TRAP_IGNORE( ReadDefaultToneL() );
       
    57     // To keep backlight on while a video is being previewed
       
    58     iBacklightTimer = CPeriodic::NewL( EPriorityLow );
       
    59     }
       
    60 
       
    61 CMFPreviewHandlerBase::~CMFPreviewHandlerBase()
       
    62     {
       
    63     delete iFullName;
       
    64     iProperty.Close();
       
    65     
       
    66     iApaSession.Close();
       
    67     }
       
    68 
       
    69 void CMFPreviewHandlerBase::SetAttr(const QString &file )
       
    70     {
       
    71     if ( !file.isNull() )
       
    72         {
       
    73         QString path = ToneFetcherUtils::normalizeSeperator(file);
       
    74         delete iFullName;
       
    75         iFullName = 0;
       
    76         iFullName = XQConversions::qStringToS60Desc( path );         
       
    77         }
       
    78     }
       
    79 
       
    80 TInt CMFPreviewHandlerBase::RingingVolume()
       
    81     {
       
    82     const TInt KDefaultVolumeLevel = 7; // see profile.hrh for volume levels
       
    83     
       
    84     if ( iRingingVolume != KErrNotFound )
       
    85         {
       
    86         return iRingingVolume;
       
    87         }
       
    88         
       
    89     if ( iActiveProfileRead )
       
    90         {
       
    91         return iActiveProfileRingingVolume;
       
    92         }
       
    93 
       
    94     return KDefaultVolumeLevel;
       
    95     }
       
    96 
       
    97 TInt CMFPreviewHandlerBase::RingingType()
       
    98     {
       
    99     if ( iRingingType != KErrNotFound )
       
   100         {
       
   101         return iRingingType;
       
   102         }
       
   103         
       
   104     if ( iActiveProfileRead )
       
   105         {
       
   106         return iActiveProfileRingingType;
       
   107         }
       
   108 
       
   109     return ERingingTypeRinging;
       
   110     }
       
   111 
       
   112 TInt CMFPreviewHandlerBase::Vibra()
       
   113     {
       
   114     if ( iVibra != KErrNotFound )
       
   115         {
       
   116         return iVibra;
       
   117         }
       
   118         
       
   119     if ( iActiveProfileRead )
       
   120         {
       
   121         return iActiveProfileVibra;
       
   122         }
       
   123     
       
   124     return 0;  // in case of error vibra is off
       
   125     }
       
   126 
       
   127 TInt CMFPreviewHandlerBase::Echo3D()
       
   128     {
       
   129     if ( i3DEcho != KErrNotFound )
       
   130         {
       
   131         return i3DEcho;
       
   132         }
       
   133     
       
   134     if ( iActiveProfileRead )
       
   135         {
       
   136         return iActiveProfile3DEcho;
       
   137         }
       
   138 
       
   139     return EProfile3DEchoOff;  // from ProfileInternal.hrh
       
   140     }
       
   141 
       
   142 TInt CMFPreviewHandlerBase::Effect3D()
       
   143     {
       
   144     if ( i3DEffect != KErrNotFound )
       
   145         {
       
   146         return i3DEffect;
       
   147         }
       
   148     
       
   149     if ( iActiveProfileRead )
       
   150         {
       
   151         return iActiveProfile3DEffect;
       
   152         }
       
   153 
       
   154     return EProfile3DEffectOff;
       
   155     }
       
   156 
       
   157 TInt CMFPreviewHandlerBase::ConvertVolume( TInt aVolume, TInt aMaxVolume )
       
   158     {
       
   159     const TInt KMinVolumeLevel = 1;
       
   160     const TInt KMaxVolumeLevel = 10;
       
   161         
       
   162     TInt result = aMaxVolume * aVolume / KMaxVolumeLevel;
       
   163     
       
   164     // if user has selected minimum volume level set HW volume 1
       
   165     if ( aVolume == KMinVolumeLevel && result == 0 )
       
   166         {
       
   167         result = 1;
       
   168         }
       
   169 
       
   170     return result;
       
   171     }
       
   172   
       
   173 void CMFPreviewHandlerBase::ReadActiveProfileL()
       
   174     {
       
   175     iActiveProfileRead = EFalse;
       
   176     
       
   177     MProfileEngine* profileEngine = CreateProfileEngineL();
       
   178     CleanupReleasePushL( *profileEngine );
       
   179     
       
   180     MProfile* activeProfile  = profileEngine->ActiveProfileL();
       
   181     CleanupReleasePushL( *activeProfile );
       
   182         
       
   183     const MProfileTones& profileTones = activeProfile->ProfileTones();
       
   184      
       
   185     const TProfileToneSettings& toneSettings = profileTones.ToneSettings();
       
   186     iActiveProfileVibra = toneSettings.iVibratingAlert;
       
   187     iActiveProfileRingingVolume = toneSettings.iRingingVolume;
       
   188     iActiveProfileRingingType = toneSettings.iRingingType;
       
   189           
       
   190     const MProfileExtraSettings& extra = activeProfile->ProfileExtraSettings();
       
   191     const MProfile3DToneSettings& threeD = extra.Profile3DToneSettings();
       
   192     
       
   193     iActiveProfile3DEffect = threeD.Effect();
       
   194     iActiveProfile3DEcho = threeD.Echo();
       
   195    
       
   196     CleanupStack::PopAndDestroy( activeProfile ); 
       
   197     CleanupStack::PopAndDestroy( profileEngine );
       
   198     
       
   199     iActiveProfileRead = ETrue;
       
   200     }
       
   201  
       
   202 void CMFPreviewHandlerBase::ReadDefaultToneL()
       
   203     {
       
   204     CRepository* cenrep = CRepository::NewLC( KCRUidProfileEngine );
       
   205 
       
   206     User::LeaveIfError( cenrep->Get( KProEngDefaultRingingTone, iDefaultTone ) );
       
   207     CleanupStack::PopAndDestroy( cenrep );
       
   208     }
       
   209 
       
   210 TInt CMFPreviewHandlerBase::GetDataType( const TDesC& aFileName, TDataType& aDataType )
       
   211     {
       
   212     TUid dummyUid( KNullUid );
       
   213     return iApaSession.AppForDocument( aFileName, dummyUid, aDataType );
       
   214     }
       
   215 
       
   216 TInt CMFPreviewHandlerBase::DoResetInactivityTimer( TAny* /*aObject*/ )
       
   217     {
       
   218     User::ResetInactivityTime();
       
   219     return KErrNone;
       
   220     }
       
   221 
       
   222 void CMFPreviewHandlerBase::DisableBackLight()
       
   223     {
       
   224         const TInt KResetInactivityTimerDelay = 2000000;
       
   225     iBacklightTimer->Cancel(); // Just in case
       
   226     // Disable backlight turn off during video preview
       
   227     iBacklightTimer->Start( KResetInactivityTimerDelay,
       
   228                             KResetInactivityTimerDelay,
       
   229                             TCallBack( DoResetInactivityTimer, 0 ) );
       
   230     
       
   231     }
       
   232 
       
   233 
       
   234 
       
   235 TonePreviewPrivate::TonePreviewPrivate( QObject *parent ) : CMFPreviewHandlerBase( parent )
       
   236     {
       
   237     iAudioPlayerStatus = EPlayerNotCreated;
       
   238     CMFPreviewHandlerBase::ConstructL();
       
   239     iTonePlayerStatus = EPlayerNotCreated;
       
   240     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   241     coeEnv->AddForegroundObserverL( *this );
       
   242     }
       
   243 
       
   244 TonePreviewPrivate::~TonePreviewPrivate()
       
   245     {
       
   246     Cancel();
       
   247     
       
   248     delete iAudioPlayer;
       
   249     delete iTonePlayer;
       
   250     delete i3dRingingTonePlugin;
       
   251     }
       
   252 
       
   253 TBool TonePreviewPrivate::IsPlaying()
       
   254     {
       
   255     if ( iAudioPlayerStatus != EPlayerNotCreated )
       
   256         {
       
   257         return ETrue;
       
   258         }
       
   259     
       
   260     if ( iTonePlayerStatus != EPlayerNotCreated )
       
   261         {
       
   262         return ETrue;
       
   263         }
       
   264 
       
   265     return EFalse;
       
   266     }
       
   267 
       
   268 void TonePreviewPrivate::Play()
       
   269     {    
       
   270     //sequence for playing a beep once sound
       
   271     _LIT8( KFileListBeepSequence, "\x00\x11\x06\x0A\x08\x73\x0A\x40\x28\x0A\xF7\
       
   272     \x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B" ); 
       
   273 
       
   274     // rng mime type
       
   275     _LIT( KFileListRngMimeType, "application/vnd.nokia.ringing-tone" );
       
   276     
       
   277     Cancel(); // stop previous play
       
   278     
       
   279     if ( !iFullName || iFullName->Des().Length() == 0 )
       
   280         {
       
   281         User::Leave( KErrNotFound );
       
   282         }
       
   283 
       
   284     TRAP_IGNORE( ReadActiveProfileL() );
       
   285 
       
   286     TPtrC fileName( iFullName->Des() );
       
   287     TDataType dataType;
       
   288     TInt err = GetDataType( fileName, dataType );
       
   289     if ( err == KErrNotFound )
       
   290         {
       
   291         fileName.Set( iDefaultTone );
       
   292         if ( fileName.Length() == 0 )
       
   293              {
       
   294              User::Leave( KErrNotFound );
       
   295              }
       
   296         }
       
   297     else if ( err != KErrNone )
       
   298         {
       
   299         User::Leave( err );
       
   300         }
       
   301         
       
   302     TBool mimeTypeRng = EFalse;
       
   303     
       
   304     if ( err == KErrNone )
       
   305         {
       
   306         if( dataType.Des().CompareF( KFileListRngMimeType ) == 0 )
       
   307             {
       
   308             mimeTypeRng = ETrue;
       
   309             }
       
   310         }
       
   311 
       
   312     TInt ringingType = RingingType();
       
   313     if ( ringingType == ERingingTypeBeepOnce )
       
   314         {
       
   315         // Active profile ringing tone is set to Beep Once
       
   316         // Don't initialize a FileSequence but use DesSequence instead
       
   317         iTonePlayer = CMdaAudioToneUtility::NewL( *this );
       
   318         iTonePlayer->PrepareToPlayDesSequence( KFileListBeepSequence() );
       
   319         iTonePlayerStatus = EPlayerInitializing;
       
   320         }
       
   321     else
       
   322         {
       
   323         if( mimeTypeRng )
       
   324             {
       
   325             //Ringingtone is a RNG-file
       
   326             iTonePlayer = CMdaAudioToneUtility::NewL( *this );
       
   327             iTonePlayer->PrepareToPlayFileSequence( fileName );
       
   328             iTonePlayerStatus = EPlayerInitializing;
       
   329             }
       
   330         else
       
   331             {
       
   332             delete iAudioPlayer;
       
   333             iAudioPlayer = 0;
       
   334 
       
   335             iAudioPlayer = CDrmPlayerUtility::NewFilePlayerL(
       
   336                 fileName, *this, KAudioPriorityRingingTonePreview,
       
   337                 ( TMdaPriorityPreference )KAudioPrefRingFilePreview );
       
   338     
       
   339             iAudioPlayerStatus = EPlayerInitializing;
       
   340             }
       
   341         }
       
   342     DisableBackLight();
       
   343     }
       
   344 
       
   345 void TonePreviewPrivate::Stop()
       
   346     {
       
   347     Cancel();
       
   348     }
       
   349 
       
   350 TInt TonePreviewPrivate::ConvertVolume( TInt aVolume )
       
   351     {
       
   352     TInt result = 0;
       
   353     if ( iAudioPlayer )
       
   354         {
       
   355         result = CMFPreviewHandlerBase::ConvertVolume( aVolume, iAudioPlayer->MaxVolume() );
       
   356         }
       
   357     else if ( iTonePlayer )
       
   358         {
       
   359         result = CMFPreviewHandlerBase::ConvertVolume( aVolume, iTonePlayer->MaxVolume() );
       
   360         }
       
   361         
       
   362     //if user has selected silent ringing type, set volume off
       
   363     TInt ringingType = RingingType();
       
   364     if( ringingType == ERingingTypeSilent )
       
   365         {
       
   366         result = 0;
       
   367         }
       
   368 
       
   369     return result;
       
   370     }
       
   371 
       
   372 void TonePreviewPrivate::SetToneRingingType( TInt aRingingType )
       
   373     {
       
   374     const TInt KToneInterval = 1000000; // 1 second pause between tones
       
   375     const TInt KAscendingVolumeInterval = 3000000; // 3 seconds
       
   376     
       
   377     if ( !iTonePlayer )
       
   378         {
       
   379         return;
       
   380         }   
       
   381 
       
   382 
       
   383     TInt ringingVolume = RingingVolume();
       
   384 
       
   385     switch( aRingingType )
       
   386         {
       
   387         case ERingingTypeRinging:
       
   388         case ERingingTypeSilent:
       
   389             {
       
   390             iTonePlayer->SetRepeats( KMdaAudioToneRepeatForever,
       
   391                                      TTimeIntervalMicroSeconds( KToneInterval ) );
       
   392             break;
       
   393             }
       
   394         case ERingingTypeAscending:
       
   395             {
       
   396             iTonePlayer->SetRepeats( KMdaAudioToneRepeatForever,
       
   397                                      TTimeIntervalMicroSeconds( KToneInterval ) );
       
   398             
       
   399             TInt volRamp = KAscendingVolumeInterval * ringingVolume;
       
   400             iTonePlayer->SetVolumeRamp( TTimeIntervalMicroSeconds( volRamp ) );
       
   401             break;
       
   402             }
       
   403         case ERingingTypeRingOnce:
       
   404         case ERingingTypeBeepOnce:
       
   405             {
       
   406             iTonePlayer->SetRepeats( 0, TTimeIntervalMicroSeconds( KToneInterval ) );
       
   407             break;
       
   408             }
       
   409         default:
       
   410             {
       
   411             break;
       
   412             }
       
   413         }
       
   414     }
       
   415 
       
   416 void TonePreviewPrivate::SetAudioRingingType( TInt aRingingType )
       
   417     {
       
   418     const TInt KToneInterval = 1000000; // 1 second pause between tones
       
   419     const TInt KAscendingVolumeInterval = 3000000; // 3 seconds
       
   420     
       
   421     if ( !iAudioPlayer )
       
   422         {
       
   423         return;
       
   424         }
       
   425 
       
   426     TInt ringingVolume = RingingVolume();
       
   427         
       
   428     switch( aRingingType )
       
   429         {
       
   430         case ERingingTypeRinging:
       
   431         case ERingingTypeSilent:
       
   432             {
       
   433             iAudioPlayer->SetRepeats( KMdaAudioToneRepeatForever,
       
   434                                       TTimeIntervalMicroSeconds( KToneInterval ) );
       
   435             break;
       
   436             }
       
   437         case ERingingTypeAscending:
       
   438             {
       
   439             iAudioPlayer->SetRepeats( KMdaAudioToneRepeatForever,
       
   440                                       TTimeIntervalMicroSeconds( KToneInterval ) );
       
   441             TInt volRamp = KAscendingVolumeInterval * ringingVolume;
       
   442             iAudioPlayer->SetVolumeRamp( TTimeIntervalMicroSeconds( volRamp ) );
       
   443             break;
       
   444             }
       
   445         case ERingingTypeRingOnce:
       
   446             {
       
   447             iAudioPlayer->SetRepeats( 0, TTimeIntervalMicroSeconds( KToneInterval ) );
       
   448             break;
       
   449             }
       
   450 
       
   451         default:
       
   452             {
       
   453             break;
       
   454             }
       
   455         }
       
   456     }
       
   457 
       
   458 void TonePreviewPrivate::Cancel()
       
   459     {
       
   460     TBool isPlaying = EFalse;
       
   461     
       
   462     if ( iAudioPlayer )
       
   463         {
       
   464         isPlaying = ETrue;
       
   465         if ( iAudioPlayerStatus == EPlayerPlayingWith3DEffect )
       
   466             {
       
   467             i3dRingingTonePlugin->Stop();
       
   468             // plugin calls AudioPlayer->Stop()
       
   469             iAudioPlayer->Close();
       
   470             }
       
   471         if ( iAudioPlayerStatus == EPlayerPlaying )
       
   472             {
       
   473             iAudioPlayer->Stop();
       
   474             iAudioPlayer->Close();
       
   475             }
       
   476         
       
   477         delete iAudioPlayer;
       
   478         iAudioPlayer = 0;
       
   479         iAudioPlayerStatus = EPlayerNotCreated;
       
   480         }
       
   481     
       
   482     if ( iTonePlayer )
       
   483         {
       
   484         isPlaying = ETrue;
       
   485         if ( iTonePlayerStatus == EPlayerPlaying )
       
   486             {
       
   487             iTonePlayer->CancelPlay();
       
   488             }
       
   489         
       
   490         delete iTonePlayer;
       
   491         iTonePlayer = 0;
       
   492         iTonePlayerStatus = EPlayerNotCreated;
       
   493         }
       
   494         
       
   495 
       
   496     if ( isPlaying )
       
   497         {
       
   498         //User::InfoPrint(_L("cancel"));
       
   499 //        EnableScreenSaver( ETrue );
       
   500         iBacklightTimer->Cancel();
       
   501         }
       
   502     }
       
   503 
       
   504 void TonePreviewPrivate::MatoPlayComplete( TInt aError )
       
   505     {
       
   506     Cancel();
       
   507     emit notifyPreviewEvent( ToneFetcherEngine::EAudioPreviewComplete, aError );
       
   508     }
       
   509 
       
   510 void TonePreviewPrivate::MatoPrepareComplete( TInt aError )
       
   511     {
       
   512     if ( aError != KErrNone )
       
   513         {
       
   514         Cancel();
       
   515         
       
   516         emit notifyPreviewEvent( ToneFetcherEngine::EPreviewError, aError );        
       
   517         return;
       
   518         }
       
   519 
       
   520     TInt ringingVolume = RingingVolume();
       
   521     TInt ringingType = RingingType();
       
   522     TInt vibra = Vibra();
       
   523        
       
   524     iTonePlayerStatus = EPlayerInitialized;
       
   525     SetToneRingingType( ringingType );
       
   526     iTonePlayer->SetVolume( ConvertVolume( ringingVolume ) );
       
   527     
       
   528     TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;               
       
   529     if ( vibra )
       
   530         {
       
   531         pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
       
   532         }
       
   533     iTonePlayer->SetPriority( KAudioPriorityPreview, pref );
       
   534                                              
       
   535     iTonePlayer->Play();
       
   536     iTonePlayerStatus = EPlayerPlaying;
       
   537     }
       
   538 
       
   539 void TonePreviewPrivate::MdapcInitComplete( TInt aError, 
       
   540                         const TTimeIntervalMicroSeconds& /* aDuration */ )
       
   541     {
       
   542     if ( aError != KErrNone )
       
   543         {
       
   544         Cancel();
       
   545         emit notifyPreviewEvent( ToneFetcherEngine::EPreviewError, aError );
       
   546         return;
       
   547         }
       
   548         
       
   549 
       
   550     TInt ringingVolume = RingingVolume();
       
   551     TInt ringingType = RingingType();
       
   552     TInt vibra = Vibra();
       
   553     TInt echo3D = Echo3D();
       
   554     TInt effect3D = Effect3D();
       
   555 
       
   556     
       
   557 
       
   558     iAudioPlayerStatus = EPlayerInitialized;
       
   559     SetAudioRingingType( ringingType );
       
   560     iAudioPlayer->SetVolume( ConvertVolume( ringingVolume ) );
       
   561     
       
   562     TMdaPriorityPreference pref = (TMdaPriorityPreference) KAudioPrefRingFilePreview;               
       
   563     if ( vibra )
       
   564         {
       
   565         pref = (TMdaPriorityPreference) KAudioPrefRingFilePreviewVibra;
       
   566         }
       
   567     iAudioPlayer->SetPriority( KAudioPriorityPreview, pref );
       
   568      
       
   569     iAudioPlayerStatus = EPlayerPlaying;
       
   570     
       
   571     if ( effect3D == EProfile3DEffectOff )
       
   572         {
       
   573         iAudioPlayer->Play();  // 3D not used
       
   574         return;
       
   575         }
       
   576 
       
   577     if ( !i3dRingingTonePlugin )
       
   578         {
       
   579         TUid emptyUid = { 0 };
       
   580         TRAPD( err, i3dRingingTonePlugin = C3DRingingToneInterface::NewL( emptyUid ) );
       
   581         if ( err != KErrNone || !i3dRingingTonePlugin )
       
   582             {
       
   583             iAudioPlayer->Play();
       
   584             return;
       
   585             }
       
   586         }       
       
   587    
       
   588     i3dRingingTonePlugin->SetAttr( E3DRTIAttr3DEffect, effect3D );
       
   589     i3dRingingTonePlugin->SetAttr( E3DRTIAttr3DEcho, echo3D );    
       
   590     i3dRingingTonePlugin->SetAttr( E3DRTIAttrDrmPlayerUtility, iAudioPlayer );
       
   591     TRAP_IGNORE( i3dRingingTonePlugin->PlayL() );
       
   592 
       
   593     iAudioPlayerStatus = EPlayerPlayingWith3DEffect;
       
   594     }
       
   595 
       
   596 void TonePreviewPrivate::MdapcPlayComplete( TInt aError )
       
   597     {  
       
   598     Cancel();
       
   599     emit notifyPreviewEvent( ToneFetcherEngine::EAudioPreviewComplete, aError );
       
   600     }
       
   601 
       
   602 void TonePreviewPrivate::HandleLosingForeground()
       
   603     {
       
   604     if ( IsPlaying() )
       
   605         {
       
   606         Stop();
       
   607         }
       
   608     }
       
   609 void TonePreviewPrivate::HandleGainingForeground()
       
   610     {
       
   611     
       
   612     }