phoneapp/phoneuiview/src/cphoneaudioplayer.cpp
branchRCL_3
changeset 5 2a26698d78ba
parent 3 8871b09be73b
equal deleted inserted replaced
4:24062c24fe38 5:2a26698d78ba
    28 
    28 
    29 #include "cphoneaudioplayer.h"
    29 #include "cphoneaudioplayer.h"
    30 #include "cphoneringingtone.h"
    30 #include "cphoneringingtone.h"
    31 #include "mphoneaudioplayerobserver.h"
    31 #include "mphoneaudioplayerobserver.h"
    32 #include "phoneconstants.h"
    32 #include "phoneconstants.h"
    33 #include "phonelogger.h"
    33 #include "phoneuiviewtrace.h"
    34 #include "phoneui.pan"
    34 #include "phoneui.pan"
    35 
    35 
    36 
    36 
    37 // CONSTANTS
    37 // CONSTANTS
    38 
    38 
    67 //
    67 //
    68 void CPhoneAudioPlayer::ConstructL(
    68 void CPhoneAudioPlayer::ConstructL(
    69     const TDesC& aFileName,
    69     const TDesC& aFileName,
    70     CMdaServer* aMdaServer )
    70     CMdaServer* aMdaServer )
    71     {
    71     {
    72     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::ConstructL()" );
    72     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructL() <" );
    73     if ( iFormat == EFormatTone )
    73     if ( iFormat == EFormatTone )
    74         {
    74         {
    75         iTonePlayer = CMdaAudioToneUtility::NewL( *this, aMdaServer );
    75         iTonePlayer = CMdaAudioToneUtility::NewL( *this, aMdaServer );
    76         iTonePlayer->PrepareToPlayFileSequence( aFileName );
    76         iTonePlayer->PrepareToPlayFileSequence( aFileName );
    77         iPlayerStatus = EToneLoading;
    77         iPlayerStatus = EToneLoading;
    78         }
    78         }
    79     else
    79     else
    80         {
    80         {
    81         //audio sample player
    81         //audio sample player
    82         __PHONELOG3( 
    82         PHONEUIVIEW_PRINTF3(
    83             EBasic, 
       
    84             EPhoneUIView, 
       
    85             "CPhoneAudioPlayer::ConstructL - aFileName(%S), iPriority(%d), iPreference(%d)",
    83             "CPhoneAudioPlayer::ConstructL - aFileName(%S), iPriority(%d), iPreference(%d)",
    86             &aFileName, 
    84             &aFileName, 
    87             iPriority, 
    85             iPriority, 
    88             iPreference );
    86             iPreference );
    89 
    87 
    90         iSamplePlayer = CMdaAudioPlayerUtility::NewFilePlayerL( 
    88         iSamplePlayer = CMdaAudioPlayerUtility::NewFilePlayerL( 
    91             aFileName,
    89             aFileName,
    92             *this, 
    90             *this, 
    93             iPriority,
    91             iPriority,
    94             static_cast< TMdaPriorityPreference >( iPreference ),
    92             static_cast< TMdaPriorityPreference >( iPreference ),
    95             aMdaServer );            
    93             aMdaServer );
    96         iPlayerStatus = EToneLoading;
    94         iPlayerStatus = EToneLoading;
    97         
    95 
    98         }
    96         }
       
    97     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructL() >" );
    99     }
    98     }
   100 
    99 
   101 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   102 // CPhoneAudioPlayer::ConstructSeqL
   101 // CPhoneAudioPlayer::ConstructSeqL
   103 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   104 //
   103 //
   105 void CPhoneAudioPlayer::ConstructSeqL( 
   104 void CPhoneAudioPlayer::ConstructSeqL( 
   106     const TDesC8& aSequence,
   105     const TDesC8& aSequence,
   107         CMdaServer* aMdaServer )
   106         CMdaServer* aMdaServer )
   108     {
   107     {
   109     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::ConstructSeqL()" );
   108     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructSeqL() <" );
   110     iTonePlayer = CMdaAudioToneUtility::NewL( *this, aMdaServer );
   109     iTonePlayer = CMdaAudioToneUtility::NewL( *this, aMdaServer );
   111     iSequence = aSequence.AllocL();
   110     iSequence = aSequence.AllocL();
   112     iTonePlayer->PrepareToPlayDesSequence( *iSequence );
   111     iTonePlayer->PrepareToPlayDesSequence( *iSequence );
   113     iPlayerStatus = EToneLoading;
   112     iPlayerStatus = EToneLoading;
       
   113     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructSeqL() >" );
   114     }
   114     }
   115 
   115 
   116 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
   117 // CPhoneAudioPlayer::ConstructTtsL
   117 // CPhoneAudioPlayer::ConstructTtsL
   118 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   120 void CPhoneAudioPlayer::ConstructTtsL( 
   120 void CPhoneAudioPlayer::ConstructTtsL( 
   121     const TDesC& aTtsText, 
   121     const TDesC& aTtsText, 
   122     TInt aPriority,
   122     TInt aPriority,
   123     TUint aPreference )
   123     TUint aPreference )
   124     {
   124     {
   125     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::ConstructTtsL()" );
   125     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructTtsL() <" );
   126     delete iTtsPlayer; // if any
   126     delete iTtsPlayer; // if any
   127     iTtsPlayer = NULL;
   127     iTtsPlayer = NULL;
   128     iTtsPlayer = 
   128     iTtsPlayer = 
   129         CMdaAudioPlayerUtility::NewL( 
   129         CMdaAudioPlayerUtility::NewL( 
   130             *this, aPriority, 
   130             *this, aPriority, 
   131             static_cast< TMdaPriorityPreference >( aPreference ) );
   131             static_cast< TMdaPriorityPreference >( aPreference ) );
   132     
   132 
   133     delete iTtsText;  // if any
   133     delete iTtsText;  // if any
   134     iTtsText = NULL;
   134     iTtsText = NULL;
   135     // UTF-8 strings can take up to 4 bytes per character
   135     // UTF-8 strings can take up to 4 bytes per character
   136     iTtsText = HBufC8::NewL( aTtsText.Length() << KTimesToMultiply ); 
   136     iTtsText = HBufC8::NewL( aTtsText.Length() << KTimesToMultiply ); 
   137     
   137 
   138     TPtr8 refText = iTtsText->Des(); 
   138     TPtr8 refText = iTtsText->Des(); 
   139     User::LeaveIfError( 
   139     User::LeaveIfError( 
   140         CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, aTtsText ) );
   140         CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, aTtsText ) );
   141 
   141 
   142     // UTF-8 chars can be up to 4 bytes long, but usually 
   142     // UTF-8 chars can be up to 4 bytes long, but usually 
   146     if ( !iTtsText )
   146     if ( !iTtsText )
   147         {
   147         {
   148         // ReAlloc failed, set back to original.
   148         // ReAlloc failed, set back to original.
   149         iTtsText = oldText;
   149         iTtsText = oldText;
   150         }
   150         }
   151     
   151 
   152     iTtsPlayer->OpenDesL( *iTtsText );
   152     iTtsPlayer->OpenDesL( *iTtsText );
       
   153     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ConstructTtsL() >" );
   153     }
   154     }
   154 
   155 
   155 // -----------------------------------------------------------------------------
   156 // -----------------------------------------------------------------------------
   156 // CPhoneAudioPlayer::New
   157 // CPhoneAudioPlayer::New
   157 // -----------------------------------------------------------------------------
   158 // -----------------------------------------------------------------------------
   163     MPhoneAudioPlayerObserver& aObserver, 
   164     MPhoneAudioPlayerObserver& aObserver, 
   164     TInt aId,
   165     TInt aId,
   165     CMdaServer* aMdaServer,
   166     CMdaServer* aMdaServer,
   166     TBool aExtSecNeeded )
   167     TBool aExtSecNeeded )
   167     {
   168     {
   168     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::New()" );
   169     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::New() <" );
   169     CPhoneAudioPlayer* self = NULL;
   170     CPhoneAudioPlayer* self = NULL;
   170     TRAPD( err, self = CPhoneAudioPlayer::NewL( 
   171     TRAPD( err, self = CPhoneAudioPlayer::NewL( 
   171         aRingingTone,
   172         aRingingTone,
   172         aPriority,
   173         aPriority,
   173         aPreference,
   174         aPreference,
   177         aExtSecNeeded ) );
   178         aExtSecNeeded ) );
   178     if ( err != KErrNone )
   179     if ( err != KErrNone )
   179         {
   180         {
   180         return NULL;
   181         return NULL;
   181         }
   182         }
       
   183     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::New() >" );
   182     return self;
   184     return self;
   183     }
   185     }
   184 
   186 
   185 // -----------------------------------------------------------------------------
   187 // -----------------------------------------------------------------------------
   186 // CPhoneAudioPlayer::NewL
   188 // CPhoneAudioPlayer::NewL
   193     MPhoneAudioPlayerObserver& aObserver,
   195     MPhoneAudioPlayerObserver& aObserver,
   194     TInt aId,
   196     TInt aId,
   195     CMdaServer* aMdaServer,
   197     CMdaServer* aMdaServer,
   196     TBool aExtSecNeeded )
   198     TBool aExtSecNeeded )
   197     {
   199     {
   198     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::NewL()" );
   200     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL() <" );
   199     __PHONELOG1( EBasic, EPhoneUIView, "CPhoneAudioPlayer::NewL - aExtSecNeeded(%d)",
   201     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::NewL - aExtSecNeeded(%d)",
   200         aExtSecNeeded );
   202         aExtSecNeeded );
   201     
   203 
   202     // Check the file DRM property if extend secure is needed.
   204     // Check the file DRM property if extend secure is needed.
   203     if ( aExtSecNeeded )
   205     if ( aExtSecNeeded )
   204         {
   206         {
   205         if ( !aRingingTone.IsFileInRom() &&
   207         if ( !aRingingTone.IsFileInRom() &&
   206              !aRingingTone.IsFileDrmProtected() )
   208              !aRingingTone.IsFileDrmProtected() )
   207             {
   209             {
   208             __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::NewL - DRM extend security check permission denied" );
   210             PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL - DRM extend security check permission denied" );
   209             User::Leave( KErrPermissionDenied );
   211             User::Leave( KErrPermissionDenied );
   210             }
   212             }
   211         __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::NewL - DRM extend security check ok" );
   213         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL - DRM extend security check ok" );
   212         }
   214         }
   213 	// RNG file types have to be played with CMdaAudioToneUtility player.
   215     // RNG file types have to be played with CMdaAudioToneUtility player.
   214 	// Otherwise use sample player
   216     // Otherwise use sample player
   215     TAudioDataFormat format = 
   217     TAudioDataFormat format = 
   216     ( aRingingTone.MimeType().CompareF( KFileListRngMimeType ) == KErrNone ) 
   218     ( aRingingTone.MimeType().CompareF( KFileListRngMimeType ) == KErrNone ) 
   217     ? EFormatTone :EFormatSample;
   219     ? EFormatTone :EFormatSample;
   218 
   220 
   219     CPhoneAudioPlayer* self = 
   221     CPhoneAudioPlayer* self = 
   221             format,
   223             format,
   222             aObserver, 
   224             aObserver, 
   223             aPriority,
   225             aPriority,
   224             aPreference,
   226             aPreference,
   225             aId );
   227             aId );
   226     
   228 
   227     CleanupStack::PushL( self );
   229     CleanupStack::PushL( self );
   228     self->ConstructL( aRingingTone.FileName(), aMdaServer );
   230     self->ConstructL( aRingingTone.FileName(), aMdaServer );
   229     CleanupStack::Pop( self );
   231     CleanupStack::Pop( self );
   230 
   232     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL() >" );
   231     return self;
   233     return self;
   232     }
   234     }
   233 
   235 
   234 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   235 // CPhoneAudioPlayer::NewL
   237 // CPhoneAudioPlayer::NewL
   242     MPhoneAudioPlayerObserver& aObserver,
   244     MPhoneAudioPlayerObserver& aObserver,
   243     TInt aId,
   245     TInt aId,
   244     CMdaServer* aMdaServer,
   246     CMdaServer* aMdaServer,
   245     TBool aExtSecNeeded )
   247     TBool aExtSecNeeded )
   246     {
   248     {
   247     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::NewL()" );
   249     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL() <" );
   248     CPhoneRingingTone* tone = CPhoneRingingTone::NewL( aFileName );
   250     CPhoneRingingTone* tone = CPhoneRingingTone::NewL( aFileName );
   249     CleanupStack::PushL( tone );
   251     CleanupStack::PushL( tone );
   250 
   252 
   251     CPhoneAudioPlayer* player = CPhoneAudioPlayer::NewL( *tone,
   253     CPhoneAudioPlayer* player = CPhoneAudioPlayer::NewL( *tone,
   252                                                          aPriority,
   254                                                          aPriority,
   255                                                          aId,
   257                                                          aId,
   256                                                          aMdaServer,
   258                                                          aMdaServer,
   257                                                          aExtSecNeeded );
   259                                                          aExtSecNeeded );
   258 
   260 
   259     CleanupStack::PopAndDestroy( tone );
   261     CleanupStack::PopAndDestroy( tone );
   260     
   262     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewL() >");
   261     return player;        
   263     return player;
   262     }
   264     }
   263 
   265 
   264 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   265 // CPhoneAudioPlayer::NewSeqL
   267 // CPhoneAudioPlayer::NewSeqL
   266 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   271     TUint aPreference,
   273     TUint aPreference,
   272     MPhoneAudioPlayerObserver& aObserver, 
   274     MPhoneAudioPlayerObserver& aObserver, 
   273     TInt aId,
   275     TInt aId,
   274     CMdaServer* aMdaServer )
   276     CMdaServer* aMdaServer )
   275     {
   277     {
   276     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::NewSeqL()" );
   278     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewSeqL() <" );
   277     CPhoneAudioPlayer* self = 
   279     CPhoneAudioPlayer* self = 
   278         new (ELeave) CPhoneAudioPlayer( 
   280         new (ELeave) CPhoneAudioPlayer( 
   279             EFormatTone, 
   281             EFormatTone, 
   280             aObserver, 
   282             aObserver, 
   281             aPriority,
   283             aPriority,
   282             aPreference,
   284             aPreference,
   283             aId );
   285             aId );
   284     
   286 
   285     CleanupStack::PushL( self );
   287     CleanupStack::PushL( self );
   286     self->ConstructSeqL( aSequence, aMdaServer  );
   288     self->ConstructSeqL( aSequence, aMdaServer  );
   287     CleanupStack::Pop( self );
   289     CleanupStack::Pop( self );
   288 
   290 
       
   291     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewSeqL() >" );
   289     return self;
   292     return self;
   290     }
   293     }
   291 
   294 
   292 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   293 // CPhoneAudioPlayer::NewTtsL
   296 // CPhoneAudioPlayer::NewTtsL
   298     TInt aPriority,
   301     TInt aPriority,
   299     TUint aPreference,
   302     TUint aPreference,
   300     MPhoneAudioPlayerObserver& aObserver, 
   303     MPhoneAudioPlayerObserver& aObserver, 
   301     TInt aId )
   304     TInt aId )
   302     {
   305     {
   303     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::NewTtsL()" );
   306     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewTtsL() <" );
   304     CPhoneAudioPlayer* self = 
   307     CPhoneAudioPlayer* self = 
   305         new (ELeave) CPhoneAudioPlayer( 
   308         new (ELeave) CPhoneAudioPlayer( 
   306             EFormatTts, 
   309             EFormatTts, 
   307             aObserver, 
   310             aObserver, 
   308             aPriority,
   311             aPriority,
   309             aPreference,
   312             aPreference,
   310             aId );
   313             aId );
   311     
   314 
   312     CleanupStack::PushL( self );
   315     CleanupStack::PushL( self );
   313     self->ConstructTtsL( aText, aPriority, aPreference );
   316     self->ConstructTtsL( aText, aPriority, aPreference );
   314     CleanupStack::Pop( self );
   317     CleanupStack::Pop( self );
   315 
   318     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::NewTtsL() >" );
   316     return self;
   319     return self;
   317     }
   320     }
   318 
   321 
   319 // -----------------------------------------------------------------------------
   322 // -----------------------------------------------------------------------------
   320 // CPhoneAudioPlayer::~CPhoneAudioPlayer
   323 // CPhoneAudioPlayer::~CPhoneAudioPlayer
   321 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   322 //
   325 //
   323 CPhoneAudioPlayer::~CPhoneAudioPlayer()
   326 CPhoneAudioPlayer::~CPhoneAudioPlayer()
   324     {
   327     {
   325     
   328 
   326     if ( iAudioOutput )
   329     if ( iAudioOutput )
   327         {
   330         {
   328     	delete iAudioOutput;    
   331         delete iAudioOutput;
   329         }  
   332         }
   330     if ( iTonePlayer )  
   333     if ( iTonePlayer )
   331         {
   334         {
   332         delete iTonePlayer;  
   335         delete iTonePlayer;
   333         } 
   336         } 
   334     if ( i3DPlugin )
   337     if ( i3DPlugin )
   335        {
   338        {
   336         i3DPlugin->Stop();
   339         i3DPlugin->Stop();
   337         delete i3DPlugin;
   340         delete i3DPlugin;
   338         }
   341         }
   339     // ECom cleanup
   342     // ECom cleanup
   340     REComSession::FinalClose();
   343     REComSession::FinalClose();
   341     if ( iSamplePlayer )    
   344     if ( iSamplePlayer )
   342         {
   345         {
   343         delete iSamplePlayer; 
   346         delete iSamplePlayer; 
   344         }
   347         }
   345     if ( iTtsPlayer )
   348     if ( iTtsPlayer )
   346         {
   349         {
   347         delete iTtsPlayer;   
   350         delete iTtsPlayer; 
   348         }
   351         }
   349     if ( iSequence )
   352     if ( iSequence )
   350         {
   353         {
   351         delete iSequence; 
   354         delete iSequence; 
   352         }
   355         }
   353     if ( iTtsText )  
   356     if ( iTtsText )
   354         {
   357         {
   355         delete iTtsText;
   358         delete iTtsText;
   356         }   
   359         } 
   357     }
   360     }
   358 
   361 
   359 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   360 // CPhoneAudioPlayer::Play
   363 // CPhoneAudioPlayer::Play
   361 // -----------------------------------------------------------------------------
   364 // -----------------------------------------------------------------------------
   362 //
   365 //
   363 void CPhoneAudioPlayer::Play( TRingingType aRingType, TInt aVolume, TInt aTTsToBePlayed )
   366 void CPhoneAudioPlayer::Play( TRingingType aRingType, TInt aVolume, TInt aTTsToBePlayed )
   364     {
   367     {
   365     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::Play()" );
   368     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::Play() <" );
   366     __PHONELOG2( 
   369     PHONEUIVIEW_PRINTF2( 
   367         EBasic, 
       
   368         EPhoneUIView, 
       
   369         "CPhoneAudioPlayer::Play - iFormat(%d), iPlayerStatus(%d)",
   370         "CPhoneAudioPlayer::Play - iFormat(%d), iPlayerStatus(%d)",
   370         iFormat, 
   371         iFormat, 
   371         iPlayerStatus );
   372         iPlayerStatus );
   372     __PHONELOG3( 
   373     PHONEUIVIEW_PRINTF3( 
   373         EBasic, 
       
   374         EPhoneUIView, 
       
   375         "CPhoneAudioPlayer::Play - aRingType(%d), aVolume(%d), aTTsToBePlayed(%d)",
   374         "CPhoneAudioPlayer::Play - aRingType(%d), aVolume(%d), aTTsToBePlayed(%d)",
   376         aRingType, 
   375         aRingType, 
   377         aVolume,
   376         aVolume,
   378         aTTsToBePlayed );
   377         aTTsToBePlayed );
   379     iRingType = aRingType;
   378     iRingType = aRingType;
   380     iVolume = aVolume;
   379     iVolume = aVolume;
   381     iTTsToBePlayed = aTTsToBePlayed;
   380     iTTsToBePlayed = aTTsToBePlayed;
   382     
   381 
   383     if ( iFormat == EFormatTone )
   382     if ( iFormat == EFormatTone )
   384         {
   383         {
   385         switch ( iPlayerStatus )
   384         switch ( iPlayerStatus )
   386             {
   385             {
   387             case ETonePlaying:
   386             case ETonePlaying:
   398                 iToBePlaying = ETrue;
   397                 iToBePlaying = ETrue;
   399                 break;
   398                 break;
   400 
   399 
   401             default:
   400             default:
   402                 __ASSERT_DEBUG( EFalse, 
   401                 __ASSERT_DEBUG( EFalse, 
   403 
   402                        Panic( EPhoneViewCaseNotHandled ) );
   404                       Panic( EPhoneViewCaseNotHandled ) );
       
   405             }
   403             }
   406         }
   404         }
   407     else if ( iFormat == EFormatTts )
   405     else if ( iFormat == EFormatTts )
   408         {
   406         {
   409         switch ( iPlayerStatus )
   407         switch ( iPlayerStatus )
   448                 iToBePlaying = ETrue;
   446                 iToBePlaying = ETrue;
   449                 break;
   447                 break;
   450 
   448 
   451             default:
   449             default:
   452                 __ASSERT_DEBUG( EFalse, 
   450                 __ASSERT_DEBUG( EFalse, 
   453 
       
   454                         Panic( EPhoneViewCaseNotHandled ) );
   451                         Panic( EPhoneViewCaseNotHandled ) );
   455             }
   452             }
   456         }
   453         }
   457     }
   454     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::Play() >" );
   458     
   455     }
       
   456 
   459 // -----------------------------------------------------------------------------
   457 // -----------------------------------------------------------------------------
   460 // CPhoneAudioPlayer::ReStartPlaying
   458 // CPhoneAudioPlayer::ReStartPlaying
   461 // -----------------------------------------------------------------------------
   459 // -----------------------------------------------------------------------------
   462 //    
   460 //
   463 void CPhoneAudioPlayer::ReStartPlaying()
   461 void CPhoneAudioPlayer::ReStartPlaying()
   464     {
   462     {
   465     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::ReStartPlaying()" );
   463     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ReStartPlaying() <" );
   466     __PHONELOG3( 
   464     PHONEUIVIEW_PRINTF3( 
   467         EBasic, 
       
   468         EPhoneUIView, 
       
   469         "CPhoneAudioPlayer::ReStartPlaying - iFormat(%d), iRingType(%d), iVolume(%d)",
   465         "CPhoneAudioPlayer::ReStartPlaying - iFormat(%d), iRingType(%d), iVolume(%d)",
   470         iFormat, 
   466         iFormat, 
   471         iRingType, 
   467         iRingType, 
   472         iVolume );
   468         iVolume );
   473         
   469 
   474     if ( iFormat == EFormatTone )
   470     if ( iFormat == EFormatTone )
   475         {
   471         {
   476         iTonePlayer->Play();
   472         iTonePlayer->Play();
   477         iPlayerStatus = ETonePlaying;
   473         iPlayerStatus = ETonePlaying;
   478         }
   474         }
   479     else if ( iFormat == EFormatTts )
   475     else if ( iFormat == EFormatTts )
   480         {
   476         {
   481         iTtsPlayer->Play();
   477         iTtsPlayer->Play();
   482         iPlayerStatus = ETonePlaying;
   478         iPlayerStatus = ETonePlaying;
   483         }        
   479         }
   484     else
   480     else
   485         {
   481         {
   486         iSamplePlayer->Play();
   482         iSamplePlayer->Play();
   487         iPlayerStatus = ETonePlaying;
   483         iPlayerStatus = ETonePlaying;
   488         }    
   484         }
       
   485     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::ReStartPlaying() >" );
   489     }
   486     }
   490 
   487 
   491 // -----------------------------------------------------------------------------
   488 // -----------------------------------------------------------------------------
   492 // CPhoneAudioPlayer::StopPlaying
   489 // CPhoneAudioPlayer::StopPlaying
   493 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   494 //
   491 //
   495 void CPhoneAudioPlayer::StopPlaying()
   492 void CPhoneAudioPlayer::StopPlaying()
   496     {
   493     {
   497     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::StopPlaying()" );
   494    PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::StopPlaying() <" );
       
   495 
   498     iToBePlaying = EFalse;
   496     iToBePlaying = EFalse;
   499     
   497 
   500     if ( iFormat == EFormatTone )
   498     if ( iFormat == EFormatTone )
   501         {
   499         {
   502         if ( EMdaAudioToneUtilityPrepared == iTonePlayer->State() )
   500         if ( EMdaAudioToneUtilityPrepared == iTonePlayer->State() )
   503             {
   501             {
   504             iTonePlayer->CancelPrepare();
   502             iTonePlayer->CancelPrepare();
   520             delete i3DPlugin;
   518             delete i3DPlugin;
   521             i3DPlugin = NULL;
   519             i3DPlugin = NULL;
   522             }
   520             }
   523         else
   521         else
   524             {
   522             {
   525             iSamplePlayer->Stop();        
   523             iSamplePlayer->Stop();
   526             }
   524             }
   527         }
   525         }
   528     
   526 
   529     iPlayerStatus = EToneReady;
   527     iPlayerStatus = EToneReady;
       
   528     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::StopPlaying() >" );
   530     }
   529     }
   531 
   530 
   532 // -----------------------------------------------------------------------------
   531 // -----------------------------------------------------------------------------
   533 // CPhoneAudioPlayer::MapcInitComplete
   532 // CPhoneAudioPlayer::MapcInitComplete
   534 // -----------------------------------------------------------------------------
   533 // -----------------------------------------------------------------------------
   535 //
   534 //
   536 void CPhoneAudioPlayer::MapcInitComplete(
   535 void CPhoneAudioPlayer::MapcInitComplete(
   537     TInt aError, 
   536     TInt aError, 
   538     const TTimeIntervalMicroSeconds& /*aDuration*/ )
   537     const TTimeIntervalMicroSeconds& /*aDuration*/ )
   539     {
   538     {
   540     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::MapcInitComplete()" );
   539     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MapcInitComplete() <" );
   541     __PHONELOG1( EBasic, EPhoneUIView, "CPhoneAudioPlayer::MapcInitComplete - aError(%d)",
   540     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::MapcInitComplete - aError(%d)",
   542         aError );
   541         aError );
   543     __ASSERT_DEBUG( ( ( iFormat == EFormatSample ) || ( iFormat == EFormatTts ) ) && 
   542     __ASSERT_DEBUG( ( ( iFormat == EFormatSample ) || ( iFormat == EFormatTts ) ) && 
   544         ( iPlayerStatus == EToneLoading ), Panic( EPhoneViewGeneralError ) );
   543         ( iPlayerStatus == EToneLoading ), Panic( EPhoneViewGeneralError ) );
   545     if ( aError == KErrNone )
   544     if ( aError == KErrNone )
   546         {
   545         {
   560         {
   559         {
   561         iObserver.HandleAudioPlayerError( 
   560         iObserver.HandleAudioPlayerError( 
   562             MPhoneAudioPlayerObserver::EAudioPlayerInitializingFailure, 
   561             MPhoneAudioPlayerObserver::EAudioPlayerInitializingFailure, 
   563             aError, iId );
   562             aError, iId );
   564         }
   563         }
       
   564     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MapcInitComplete() >" );
   565     }
   565     }
   566 
   566 
   567 // -----------------------------------------------------------------------------
   567 // -----------------------------------------------------------------------------
   568 // CPhoneAudioPlayer::MapcPlayComplete
   568 // CPhoneAudioPlayer::MapcPlayComplete
   569 // -----------------------------------------------------------------------------
   569 // -----------------------------------------------------------------------------
   570 //
   570 //
   571 void CPhoneAudioPlayer::MapcPlayComplete( TInt aError )
   571 void CPhoneAudioPlayer::MapcPlayComplete( TInt aError )
   572     {
   572     {
   573     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::MapcPlayComplete()" );
   573     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MapcPlayComplete() <" );
   574     __PHONELOG2( EBasic, EPhoneUIView, "CPhoneAudioPlayer::MapcPlayComplete - iFormat(%d), aError(%d)",
   574     PHONEUIVIEW_PRINTF2( "CPhoneAudioPlayer::MapcPlayComplete - iFormat(%d), aError(%d)",
   575         iFormat, aError );
   575         iFormat, aError );
   576     iPlayerStatus = EToneReady;
   576     iPlayerStatus = EToneReady;
   577 
   577 
   578     //Destruct 3D plugin before player itself gets destructed.
   578     //Destruct 3D plugin before player itself gets destructed.
   579     //In case of continuous ringing type, stopplaying() handles
   579     //In case of continuous ringing type, stopplaying() handles
   580     //3d plugin destruction
   580     //3d plugin destruction
   581     if ( i3DPlugin )
   581     if ( i3DPlugin )
   582         {
   582         {
   583         i3DPlugin->Stop();
   583         i3DPlugin->Stop();
   584         delete i3DPlugin;
   584         delete i3DPlugin;
   585         i3DPlugin = NULL;            
   585         i3DPlugin = NULL;
   586         }
   586         }
   587 
   587 
   588     if ( aError != KErrNone )
   588     if ( aError != KErrNone )
   589         {
   589         {
   590         iObserver.HandleAudioPlayerError( 
   590         iObserver.HandleAudioPlayerError( 
   593         }
   593         }
   594     else
   594     else
   595         {
   595         {
   596         iObserver.HandlePlayingComplete( iId );
   596         iObserver.HandlePlayingComplete( iId );
   597         }
   597         }
       
   598     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MapcPlayComplete() >" );
   598     }
   599     }
   599 
   600 
   600 // -----------------------------------------------------------------------------
   601 // -----------------------------------------------------------------------------
   601 // CPhoneAudioPlayer::MatoPrepareComplete
   602 // CPhoneAudioPlayer::MatoPrepareComplete
   602 // -----------------------------------------------------------------------------
   603 // -----------------------------------------------------------------------------
   603 //
   604 //
   604 void CPhoneAudioPlayer::MatoPrepareComplete( TInt aError )
   605 void CPhoneAudioPlayer::MatoPrepareComplete( TInt aError )
   605     {
   606     {
   606     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::MatoPrepareComplete()" );
   607     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MatoPrepareComplete() <" );
   607     __PHONELOG1( EBasic, EPhoneUIView, "CPhoneAudioPlayer::MatoPrepareComplete - aError(%d)",
   608     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::MatoPrepareComplete - aError(%d)",
   608         aError );
   609         aError );
   609         
   610 
   610 	__ASSERT_DEBUG( ( iFormat == EFormatTone ) && ( iPlayerStatus == EToneLoading ), 
   611     __ASSERT_DEBUG( ( iFormat == EFormatTone ) && ( iPlayerStatus == EToneLoading ), 
   611         Panic( EPhoneViewGeneralError ) );
   612         Panic( EPhoneViewGeneralError ) );
   612     if ( aError == KErrNone )
   613     if ( aError == KErrNone )
   613         {
   614         {
   614         if ( iToBePlaying )
   615         if ( iToBePlaying )
   615             {
   616             {
   627         {
   628         {
   628         iObserver.HandleAudioPlayerError( 
   629         iObserver.HandleAudioPlayerError( 
   629             MPhoneAudioPlayerObserver::EAudioPlayerInitializingFailure, 
   630             MPhoneAudioPlayerObserver::EAudioPlayerInitializingFailure, 
   630             aError, iId );
   631             aError, iId );
   631         }
   632         }
       
   633     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MatoPrepareComplete() >" );
   632     }
   634     }
   633 
   635 
   634 // -----------------------------------------------------------------------------
   636 // -----------------------------------------------------------------------------
   635 // CPhoneAudioPlayer::MatoPlayComplete
   637 // CPhoneAudioPlayer::MatoPlayComplete
   636 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   637 //
   639 //
   638 void CPhoneAudioPlayer::MatoPlayComplete(TInt aError)
   640 void CPhoneAudioPlayer::MatoPlayComplete(TInt aError)
   639     {
   641     {
   640     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::MatoPlayComplete()" );
   642     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MatoPlayComplete() <" );
   641     __PHONELOG1( EBasic, EPhoneUIView, "CPhoneAudioPlayer::MatoPlayComplete - aError(%d)",
   643     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::MatoPlayComplete - aError(%d)",
   642         aError );
   644         aError );
   643     if ( aError != KErrNone )
   645     if ( aError != KErrNone )
   644         {
   646         {
   645         iObserver.HandleAudioPlayerError( 
   647         iObserver.HandleAudioPlayerError( 
   646             MPhoneAudioPlayerObserver::EAudioPlayerPlayingFailure, 
   648             MPhoneAudioPlayerObserver::EAudioPlayerPlayingFailure, 
   648         }
   650         }
   649     else
   651     else
   650         {
   652         {
   651         iObserver.HandlePlayingComplete( iId );
   653         iObserver.HandlePlayingComplete( iId );
   652         }
   654         }
       
   655     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::MatoPlayComplete() >" );
   653     }
   656     }
   654 
   657 
   655 // -----------------------------------------------------------------------------
   658 // -----------------------------------------------------------------------------
   656 // CPhoneAudioPlayer::DoPlay
   659 // CPhoneAudioPlayer::DoPlay
   657 // -----------------------------------------------------------------------------
   660 // -----------------------------------------------------------------------------
   658 //
   661 //
   659 void CPhoneAudioPlayer::DoPlay()
   662 void CPhoneAudioPlayer::DoPlay()
   660     {
   663     {
   661     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::DoPlay()" );
   664     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::DoPlay() <" );
   662     __ASSERT_DEBUG( iPlayerStatus == ETonePlaying, 
   665     __ASSERT_DEBUG( iPlayerStatus == ETonePlaying, 
   663         Panic( EPhoneViewGeneralError ) );
   666         Panic( EPhoneViewGeneralError ) );
   664         
   667 
   665     SetRingingTypeProperties();
   668     SetRingingTypeProperties();
   666     
   669 
   667     TInt err(KErrNone);
   670     TInt err(KErrNone);
   668     if ( iFormat == EFormatTone )
   671     if ( iFormat == EFormatTone )
   669         {
   672         {
   670         iTonePlayer->Play();
   673         iTonePlayer->Play();
   671         }
   674         }
   672     else if ( iFormat == EFormatTts )
   675     else if ( iFormat == EFormatTts )
   673         {
   676         {
   674         iTtsPlayer->Play();
   677         iTtsPlayer->Play();
   675         }        
   678         }
   676     else
   679     else
   677         {
   680         {
   678         TRAP( err,i3DPlugin = C3DRingingToneInterface::NewL( KNullUid ) );
   681         TRAP( err,i3DPlugin = C3DRingingToneInterface::NewL( KNullUid ) );
   679         if ( !err && i3DPlugin )
   682         if ( !err && i3DPlugin )
   680             {
   683             {
   683             }
   686             }
   684         if ( err || !i3DPlugin )
   687         if ( err || !i3DPlugin )
   685             {
   688             {
   686             if ( !iAudioOutput )
   689             if ( !iAudioOutput )
   687                  {
   690                  {
   688                  __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::DoPlay c aud ");
   691                  PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::DoPlay c aud ");
   689                  TRAP (err, iAudioOutput = CAudioOutput::NewL( *iSamplePlayer ) );
   692                  TRAP (err, iAudioOutput = CAudioOutput::NewL( *iSamplePlayer ) );
   690                 if ( err )
   693                 if ( err )
   691                     {
   694                     {
   692                     __PHONELOG1(EBasic, EPhoneUIView, 
   695                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::DoPlay iAudioOutput.err ", err );
   693                         "P.AudPlayer.DoPlay.iAudioOutput.err ", err );
   696                     }
   694                     }                      	        
       
   695                }
   697                }
   696             if ( !err && iAudioOutput )
   698             if ( !err && iAudioOutput )
   697                  {
   699                  {
   698                  __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::DoPlay EALL ");
   700                  PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::DoPlay EALL ");
   699                  TRAP (err, iAudioOutput->SetAudioOutputL( CAudioOutput::EAll ) );
   701                  TRAP (err, iAudioOutput->SetAudioOutputL( CAudioOutput::EAll ) );
   700                  if ( err )
   702                  if ( err )
   701                      {
   703                      {
   702                      __PHONELOG1( EBasic, EPhoneUIView, 
   704                      PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::DoPlay SetAudioOutputL.err ", err ); 
   703                          "P.AudPlayer.DoPlay.SetAudioOutputL.err ", err );   
       
   704                      }
   705                      }
   705 
   706 
   706                  }
   707                  }
   707             iSamplePlayer->Play();
   708             iSamplePlayer->Play();
   708             }
   709             }
   709         }
   710         }
       
   711     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::DoPlay() >" );
   710     }
   712     }
   711 
   713 
   712 // -----------------------------------------------------------------------------
   714 // -----------------------------------------------------------------------------
   713 // CPhoneAudioPlayer::SetRingingTypeProperties
   715 // CPhoneAudioPlayer::SetRingingTypeProperties
   714 // -----------------------------------------------------------------------------
   716 // -----------------------------------------------------------------------------
   715 //
   717 //
   716 void CPhoneAudioPlayer::SetRingingTypeProperties()
   718 void CPhoneAudioPlayer::SetRingingTypeProperties()
   717     {
   719     {
   718     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::SetRingingTypeProperties()" );
   720     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetRingingTypeProperties() <" );
   719     __PHONELOG2( EBasic, EPhoneUIView, "CPhoneAudioPlayer::SetRingingTypeProperties - iFormat(%d), iRingType(%d)",
   721     PHONEUIVIEW_PRINTF2( "CPhoneAudioPlayer::SetRingingTypeProperties - iFormat(%d), iRingType(%d)",
   720         iFormat, iRingType );
   722         iFormat, iRingType );
   721     TInt rampTime( 0 );     
   723     TInt rampTime( 0 ); 
   722     if ( iFormat == EFormatTone )
   724     if ( iFormat == EFormatTone )
   723         {
   725         {
   724         switch ( iRingType )
   726         switch ( iRingType )
   725             {
   727             {
   726             case ETypeRinging:
   728             case ETypeRinging:
   727                 //If we have TTS activated and ringingtype is ringing:
   729                 //If we have TTS activated and ringingtype is ringing:
   728                 //We need to play TTS sequence again when ringingtone restarts.
   730                 //We need to play TTS sequence again when ringingtone restarts.
   729                 //Thats why we need to set ringingtype to ETypeRingingOnce because  
   731                 //Thats why we need to set ringingtype to ETypeRingingOnce because
   730                 //it is the only way of knowing when ringingtone is completed. 
   732                 //it is the only way of knowing when ringingtone is completed. 
   731                 //Then we can restart it with new TTS iterations.
   733                 //Then we can restart it with new TTS iterations.
   732                 if ( iTTsToBePlayed )
   734                 if ( iTTsToBePlayed )
   733                     {
   735                     {
   734                      //play only once
   736                      //play only once
   735                     iTonePlayer->SetRepeats( 0, 
   737                     iTonePlayer->SetRepeats( 0, 
   736                         TTimeIntervalMicroSeconds(
   738                         TTimeIntervalMicroSeconds(
   737                         KPhoneRingingRepeatsTrailPause ) ); 
   739                         KPhoneRingingRepeatsTrailPause ) ); 
   738                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   740                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   739                     __PHONELOG1( 
   741                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing tone with TTS, Set volume(%d) and ring once",
   740                         EBasic, 
       
   741                         EPhoneUIView, 
       
   742                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing tone with TTS, Set volume(%d) and ring once",
       
   743                         iVolume );
   742                         iVolume );
   744                     }
   743                     }
   745                 else
   744                 else
   746                     {
   745                     {
   747                     iTonePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   746                     iTonePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   748                         TTimeIntervalMicroSeconds( 
   747                         TTimeIntervalMicroSeconds( 
   749                          KPhoneRingingRepeatsTrailPause ) );
   748                          KPhoneRingingRepeatsTrailPause ) );
   750                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   749                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   751                     __PHONELOG1( 
   750                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing tone, Set volume(%d)",
   752                         EBasic, 
       
   753                         EPhoneUIView, 
       
   754                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing tone, Set volume(%d)",
       
   755                         iVolume );
   751                         iVolume );
   756                     }
   752                     }
   757                 break;
   753                 break;
   758 
   754 
   759             case ETypeRingingOnce:
   755             case ETypeRingingOnce:
   760                 //play only once
   756                 //play only once
   761                 iTonePlayer->SetRepeats( 0, 
   757                 iTonePlayer->SetRepeats( 0, 
   762                     TTimeIntervalMicroSeconds(
   758                     TTimeIntervalMicroSeconds(
   763                     KPhoneRingingRepeatsTrailPause ) ); 
   759                     KPhoneRingingRepeatsTrailPause ) ); 
   764                 iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   760                 iTonePlayer->SetVolume( ConvertVolume( iVolume ) );
   765                 __PHONELOG1( 
   761                 PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ring once tone, set volume(%d)",
   766                     EBasic, 
       
   767                     EPhoneUIView, 
       
   768                     "CPhoneAudioPlayer::SetRingingTypeProperties - Ring once tone, set volume(%d)",
       
   769                     iVolume );
   762                     iVolume );
   770                 break;
   763                 break;
   771 
   764 
   772             case ETypeAscending:
   765             case ETypeAscending:
   773                 iTonePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   766                 iTonePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   778                 //and ramptime needs to be different as usual
   771                 //and ramptime needs to be different as usual
   779                 if ( iTTsToBePlayed )
   772                 if ( iTTsToBePlayed )
   780                     {
   773                     {
   781                     //rampTime in this case is only 3 seconds and volume is 1.
   774                     //rampTime in this case is only 3 seconds and volume is 1.
   782                     rampTime = KPhoneAudioAscendingRampDuration;
   775                     rampTime = KPhoneAudioAscendingRampDuration;
   783                     __PHONELOG1( 
   776                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending tone with TTS, Start from lowest volume, rampTime(%d)",
   784                         EBasic, 
       
   785                         EPhoneUIView, 
       
   786                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending tone with TTS, Start from lowest volume, rampTime(%d)",
       
   787                         rampTime );
   777                         rampTime );
   788                     iTonePlayer->SetVolumeRamp( 
   778                     iTonePlayer->SetVolumeRamp( 
   789                         TTimeIntervalMicroSeconds( rampTime ) ); 
   779                         TTimeIntervalMicroSeconds( rampTime ) ); 
   790 
   780 
   791                     iCurrentVolume = 1; //we start from the lowest volume
   781                     iCurrentVolume = 1; //we start from the lowest volume
   793                     }
   783                     }
   794                 else
   784                 else
   795                     {
   785                     {
   796                     //rampTime: time for one step * volume level
   786                     //rampTime: time for one step * volume level
   797                     rampTime = KPhoneAudioAscendingRampDuration*iVolume;
   787                     rampTime = KPhoneAudioAscendingRampDuration*iVolume;
   798                     __PHONELOG2( 
   788                     PHONEUIVIEW_PRINTF2( "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending tone, Set volume(%d), rampTime(%d)",
   799                         EBasic, 
       
   800                         EPhoneUIView, 
       
   801                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending tone, Set volume(%d), rampTime(%d)",
       
   802                         iVolume, rampTime );
   789                         iVolume, rampTime );
   803                     iTonePlayer->SetVolumeRamp( 
   790                     iTonePlayer->SetVolumeRamp( 
   804                         TTimeIntervalMicroSeconds( rampTime ) );
   791                         TTimeIntervalMicroSeconds( rampTime ) );
   805                         
   792 
   806                     iCurrentVolume = 1; //we start from the lowest volume
   793                     iCurrentVolume = 1; //we start from the lowest volume
   807                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) );       
   794                     iTonePlayer->SetVolume( ConvertVolume( iVolume ) ); 
   808                     }
   795                     }
   809                 break;
   796                 break;
   810 
   797 
   811             default:
   798             default:
   812                 Panic( EPhoneViewGeneralError );
   799                 Panic( EPhoneViewGeneralError );
   813                 break;
   800                 break;
   814             }
   801             }
   815 
   802 
   816         __PHONELOG3( 
   803         PHONEUIVIEW_PRINTF3( "CPhoneAudioPlayer::SetRingingTypeProperties - Tone, iPriority(%d), iPreference(%d), iVolume(%d)",
   817             EBasic, 
       
   818             EPhoneUIView, 
       
   819             "CPhoneAudioPlayer::SetRingingTypeProperties - Tone, iPriority(%d), iPreference(%d), iVolume(%d)",
       
   820             iPriority, iPreference, iVolume );
   804             iPriority, iPreference, iVolume );
   821 
   805 
   822         //Set priority and preference
   806         //Set priority and preference
   823         iTonePlayer->SetPriority( iPriority, 
   807         iTonePlayer->SetPriority( iPriority, 
   824             static_cast< TMdaPriorityPreference >( iPreference ) );
   808             static_cast< TMdaPriorityPreference >( iPreference ) );
   835             case ETypeRingingOnce:
   819             case ETypeRingingOnce:
   836                 iTtsPlayer->SetRepeats( 0, // play only once
   820                 iTtsPlayer->SetRepeats( 0, // play only once
   837                     TTimeIntervalMicroSeconds( 
   821                     TTimeIntervalMicroSeconds( 
   838                     KPhoneRingingRepeatsTrailPause ) );
   822                     KPhoneRingingRepeatsTrailPause ) );
   839                 iTtsPlayer->SetVolume( ConvertVolume( iVolume ) );
   823                 iTtsPlayer->SetVolume( ConvertVolume( iVolume ) );
   840                 __PHONELOG1( 
   824                 PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - TTS, Set volume(%d)",
   841                     EBasic, 
       
   842                     EPhoneUIView, 
       
   843                     "CPhoneAudioPlayer::SetRingingTypeProperties - TTS, Set volume(%d)",
       
   844                     iVolume );
   825                     iVolume );
   845                 break;
   826                 break;
   846             
   827 
   847             default:
   828             default:
   848                 __ASSERT_DEBUG( EFalse, 
   829                 __ASSERT_DEBUG( EFalse, 
   849                         Panic( EPhoneViewCaseNotHandled ) );
   830                         Panic( EPhoneViewCaseNotHandled ) );
   850             }
   831             }
   851         __PHONELOG( 
   832         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetRingingTypeProperties - TTS" );
   852             EBasic, 
       
   853             EPhoneUIView, 
       
   854             "CPhoneAudioPlayer::SetRingingTypeProperties - TTS" );
       
   855         }
   833         }
   856     else
   834     else
   857         {
   835         {
   858         switch ( iRingType )
   836         switch ( iRingType )
   859             {
   837             {
   860             case ETypeRinging:
   838             case ETypeRinging:
   861                 //If we have TTS activated and ringingtype is ringing:
   839                 //If we have TTS activated and ringingtype is ringing:
   862                 //We need to play TTS sequence again when ringingtone restarts.
   840                 //We need to play TTS sequence again when ringingtone restarts.
   863                 //Thats why we need to set ringingtype to ETypeRingingOnce because  
   841                 //Thats why we need to set ringingtype to ETypeRingingOnce because
   864                 //it is theonly way of knowing when ringingtone is completed. 
   842                 //it is theonly way of knowing when ringingtone is completed. 
   865                 //Then we can restartit with new TTS iterations.
   843                 //Then we can restartit with new TTS iterations.
   866                 if ( iTTsToBePlayed )
   844                 if ( iTTsToBePlayed )
   867                     {
   845                     {
   868                      //play only once
   846                      //play only once
   869                     iSamplePlayer->SetRepeats( 0, 
   847                     iSamplePlayer->SetRepeats( 0, 
   870                         TTimeIntervalMicroSeconds(
   848                         TTimeIntervalMicroSeconds(
   871                         KPhoneRingingRepeatsTrailPause ) ); 
   849                         KPhoneRingingRepeatsTrailPause ) ); 
   872                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   850                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   873                     __PHONELOG1( 
   851                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing sample with TTS, Ring only once, Set volume(%d)",
   874                         EBasic, 
       
   875                         EPhoneUIView, 
       
   876                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing sample with TTS, Ring only once, Set volume(%d)",
       
   877                         iVolume );
   852                         iVolume );
   878                     }
   853                     }
   879                 else
   854                 else
   880                     {
   855                     {
   881                     iSamplePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   856                     iSamplePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   882                         TTimeIntervalMicroSeconds( 
   857                         TTimeIntervalMicroSeconds( 
   883                         KPhoneRingingRepeatsTrailPause ) );
   858                         KPhoneRingingRepeatsTrailPause ) );
   884                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   859                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   885                     __PHONELOG1( 
   860                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing sample, Set volume(%d)",
   886                         EBasic, 
       
   887                         EPhoneUIView, 
       
   888                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ringing sample, Set volume(%d)",
       
   889                         iVolume );
   861                         iVolume );
   890                     }
   862                     }
   891                 break;
   863                 break;
   892 
   864 
   893             case ETypeRingingOnce:
   865             case ETypeRingingOnce:
   894                 iSamplePlayer->SetRepeats( 0,//play only once
   866                 iSamplePlayer->SetRepeats( 0,//play only once
   895                     TTimeIntervalMicroSeconds( 
   867                     TTimeIntervalMicroSeconds( 
   896                     KPhoneRingingRepeatsTrailPause ) ); 
   868                     KPhoneRingingRepeatsTrailPause ) ); 
   897                 iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   869                 iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   898                 __PHONELOG1( 
   870                 PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ring once sample, set volume(%d)",
   899                     EBasic, 
       
   900                     EPhoneUIView, 
       
   901                     "CPhoneAudioPlayer::SetRingingTypeProperties - Ring once sample, set volume(%d)",
       
   902                     iVolume );
   871                     iVolume );
   903                 break;
   872                 break;
   904 
   873 
   905             case ETypeAscending:
   874             case ETypeAscending:
   906                 iSamplePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   875                 iSamplePlayer->SetRepeats( KPhoneMdaAudioToneRepeatForever,
   911                 //and ramptime needs to be different as usual
   880                 //and ramptime needs to be different as usual
   912                 if ( iTTsToBePlayed )
   881                 if ( iTTsToBePlayed )
   913                     {
   882                     {
   914                     //rampTime in this case is only 3 seconds and volume is 1.
   883                     //rampTime in this case is only 3 seconds and volume is 1.
   915                     rampTime = KPhoneAudioAscendingRampDuration;
   884                     rampTime = KPhoneAudioAscendingRampDuration;
   916                     __PHONELOG1( 
   885                     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending sample with TTS, Start from lowest volume, rampTime(%d)",
   917                         EBasic, 
       
   918                         EPhoneUIView, 
       
   919                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending sample with TTS, Start from lowest volume, rampTime(%d)",
       
   920                         rampTime );
   886                         rampTime );
   921                     iSamplePlayer->SetVolumeRamp( 
   887                     iSamplePlayer->SetVolumeRamp( 
   922                         TTimeIntervalMicroSeconds( rampTime ) ); 
   888                         TTimeIntervalMicroSeconds( rampTime ) ); 
   923 
   889 
   924                     iCurrentVolume = 1; //we start from the lowest volume
   890                     iCurrentVolume = 1; //we start from the lowest volume
   926                     }
   892                     }
   927                 else
   893                 else
   928                     {
   894                     {
   929                     //rampTime: time for one step * volume level
   895                     //rampTime: time for one step * volume level
   930                     rampTime = KPhoneAudioAscendingRampDuration*iVolume;
   896                     rampTime = KPhoneAudioAscendingRampDuration*iVolume;
   931                     __PHONELOG2( 
   897                     PHONEUIVIEW_PRINTF2( "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending sample, Set volume(%d), rampTime(%d)",
   932                         EBasic, 
       
   933                         EPhoneUIView, 
       
   934                         "CPhoneAudioPlayer::SetRingingTypeProperties - Ascending sample, Set volume(%d), rampTime(%d)",
       
   935                         iVolume, rampTime );
   898                         iVolume, rampTime );
   936                     iSamplePlayer->SetVolumeRamp( 
   899                     iSamplePlayer->SetVolumeRamp( 
   937                         TTimeIntervalMicroSeconds( rampTime ) );
   900                         TTimeIntervalMicroSeconds( rampTime ) );
   938                         
   901 
   939                     iCurrentVolume = 1; //we start from the lowest volume
   902                     iCurrentVolume = 1; //we start from the lowest volume
   940                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   903                     iSamplePlayer->SetVolume( ConvertVolume( iVolume ) );
   941                     }
   904                     }
   942                 break;
   905                 break;
   943 
   906 
   944             default:
   907             default:
   945                 Panic( EPhoneViewGeneralError );
   908                 Panic( EPhoneViewGeneralError );
   946                 break;
   909                 break;
   947             }
   910             }
   948 
   911 
   949         __PHONELOG( 
   912         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetRingingTypeProperties - Sample" );
   950             EBasic, 
   913         }
   951             EPhoneUIView, 
   914     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetRingingTypeProperties() >" );
   952             "CPhoneAudioPlayer::SetRingingTypeProperties - Sample" );
       
   953         }
       
   954     }
   915     }
   955 
   916 
   956 // -----------------------------------------------------------------------------
   917 // -----------------------------------------------------------------------------
   957 // CPhoneAudioPlayer::SetNewVolumeAndRamptime
   918 // CPhoneAudioPlayer::SetNewVolumeAndRamptime
   958 // -----------------------------------------------------------------------------
   919 // -----------------------------------------------------------------------------
   959 //    
   920 //
   960 void CPhoneAudioPlayer::SetNewVolumeAndRamptime( TInt aVolume, TInt aRamptime )
   921 void CPhoneAudioPlayer::SetNewVolumeAndRamptime( TInt aVolume, TInt aRamptime )
   961     {
   922     {
   962     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioPlayer::SetNewVolumeAndRamptime()" );
   923     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetNewVolumeAndRamptime() <" );
   963    
   924  
   964     //Check that volume is in valid range.
   925     //Check that volume is in valid range.
   965    TInt volume = aVolume<1 ? 1:aVolume;
   926     TInt volume = aVolume<1 ? 1:aVolume;
   966     __PHONELOG1( EBasic, EPhoneUIView, "CPhoneAudioPlayer::SetNewVolumeAndRamptime - aVolume(%d)",
   927     PHONEUIVIEW_PRINTF( "CPhoneAudioPlayer::SetNewVolumeAndRamptime - aVolume(%d)",
   967         aVolume ); 
   928         aVolume ); 
   968             
   929 
   969     if ( iFormat == EFormatTone && iTonePlayer )
   930     if ( iFormat == EFormatTone && iTonePlayer )
   970         {
   931         {
   971         iTonePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   932         iTonePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   972         iTonePlayer->SetVolume( ConvertVolume( volume ) );
   933         iTonePlayer->SetVolume( ConvertVolume( volume ) );
   973         __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::SetNewVolumeAndRamptime - Tone player" );
   934         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetNewVolumeAndRamptime - Tone player" );
   974         }
   935         }
   975     else if ( iFormat == EFormatTts && iTtsPlayer )
   936     else if ( iFormat == EFormatTts && iTtsPlayer )
   976         {
   937         {
   977         iTtsPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   938         iTtsPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   978         iTtsPlayer->SetVolume( ConvertVolume( volume ) );
   939         iTtsPlayer->SetVolume( ConvertVolume( volume ) );
   979         __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::SetNewVolumeAndRamptime - TTS player" );
   940         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetNewVolumeAndRamptime - TTS player" );
   980         }
   941         }
   981     else 
   942     else 
   982         {
   943         {
   983         iSamplePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   944         iSamplePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds( aRamptime ) );
   984         iSamplePlayer->SetVolume( ConvertVolume( volume ) );
   945         iSamplePlayer->SetVolume( ConvertVolume( volume ) );
   985         __PHONELOG( EBasic, EPhoneUIView, "CPhoneAudioPlayer::SetNewVolumeAndRamptime - Sample player" );
   946         PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetNewVolumeAndRamptime - Sample player" );
   986         }
   947         }
   987    
   948  
   988     }
   949     PHONEUIVIEW_PRINT( "CPhoneAudioPlayer::SetNewVolumeAndRamptime() >" );
   989    
   950     }
       
   951  
   990 
   952 
   991 // -----------------------------------------------------------------------------
   953 // -----------------------------------------------------------------------------
   992 // CPhoneAudioPlayer::ConvertVolume
   954 // CPhoneAudioPlayer::ConvertVolume
   993 // -----------------------------------------------------------------------------
   955 // -----------------------------------------------------------------------------
   994 //  
   956 //
   995 TInt CPhoneAudioPlayer::ConvertVolume( TInt aVolume )
   957 TInt CPhoneAudioPlayer::ConvertVolume( TInt aVolume )
   996     {
   958     {
   997     //_DDPRINT( 5, "P.AudPlayer.ConvertVolume.aVolume", aVolume );
   959     TInt result( 0 );
   998 
   960 
   999     TInt result( 0 );    
       
  1000     
       
  1001     if ( iFormat == EFormatTone && iTonePlayer )
   961     if ( iFormat == EFormatTone && iTonePlayer )
  1002         {
   962         {
  1003         result = iTonePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
   963         result = iTonePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
  1004         }
   964         }
  1005     else if ( iFormat == EFormatTts && iTtsPlayer )
   965     else if ( iFormat == EFormatTts && iTtsPlayer )
  1006         {
   966         {
  1007         result = iTtsPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;    
   967         result = iTtsPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
  1008         }
   968         }
  1009     else
   969     else
  1010         {
   970         {
  1011         result = iSamplePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;       
   971         result = iSamplePlayer->MaxVolume() * aVolume / KMaxVolumeLevel; 
  1012         }
   972         }
  1013         
   973 
  1014 	// if user has selected minimum volume level
   974     // if user has selected minimum volume level
  1015 	// set HW volume 1
   975     // set HW volume 1
  1016     if ( aVolume == KMinVolumeLevel && result == 0 )
   976     if ( aVolume == KMinVolumeLevel && result == 0 )
  1017         {
   977         {
  1018         result = 1; 
   978         result = 1; 
  1019         }
   979         }
  1020        
   980  
  1021     //_DDPRINT( 5, "P.AudPlayer.ConvertVolume.result", result );       
   981     //_DDPRINT( 5, "P.AudPlayer.ConvertVolume.result", result ); 
  1022     return result;    
   982     return result;
  1023     }
   983     }
  1024 
   984 
  1025        
   985  
  1026 // -----------------------------------------------------------------------------
   986 // -----------------------------------------------------------------------------
  1027 // CPhoneAudioPlayer::SetTTsToBePlayed
   987 // CPhoneAudioPlayer::SetTTsToBePlayed
  1028 // -----------------------------------------------------------------------------
   988 // -----------------------------------------------------------------------------
  1029 //  
   989 //
  1030 void CPhoneAudioPlayer::SetTTsToBePlayed( TBool aTTsToBePlayed )
   990 void CPhoneAudioPlayer::SetTTsToBePlayed( TBool aTTsToBePlayed )
  1031 	{
   991     {
  1032 	iTTsToBePlayed = aTTsToBePlayed;
   992     iTTsToBePlayed = aTTsToBePlayed;
  1033 	}  
   993     }
  1034 
   994 
  1035 // -----------------------------------------------------------------------------
   995 // -----------------------------------------------------------------------------
  1036 // CPhoneAudioPlayer::MutePlaying
   996 // CPhoneAudioPlayer::MutePlaying
  1037 // -----------------------------------------------------------------------------
   997 // -----------------------------------------------------------------------------
  1038 //	
   998 //
  1039 void CPhoneAudioPlayer::MutePlaying()
   999 void CPhoneAudioPlayer::MutePlaying()
  1040     {
  1000     {
  1041     //_DPRINT( 5, "P.Aud.Mute" );
  1001     //_DPRINT( 5, "P.Aud.Mute" );
  1042     if ( iPlayerStatus == ETonePlaying )
  1002     if ( iPlayerStatus == ETonePlaying )
  1043         {
  1003         {
  1049             {
  1009             {
  1050             iTtsPlayer->SetVolume(0);
  1010             iTtsPlayer->SetVolume(0);
  1051             }
  1011             }
  1052         else // EFormatSample
  1012         else // EFormatSample
  1053             {
  1013             {
  1054             iSamplePlayer->SetVolume(0);        
  1014             iSamplePlayer->SetVolume(0);
  1055             }
  1015             }
  1056         }
  1016         }
  1057     else
  1017     else
  1058         {
  1018         {
  1059         // Mute called during EToneLoading state.
  1019         // Mute called during EToneLoading state.
  1060         iToBePlaying = EFalse;    
  1020         iToBePlaying = EFalse;
  1061         }                   
  1021         } 
  1062     }
  1022     }
  1063    
  1023  
  1064 //  End of File  
  1024 //  End of File