mmserv/tms/tmsserver/src/tmsrtaudiohdlr.cpp
changeset 14 80975da52420
parent 12 5a06f39ad45b
child 20 b67dd1fc57c5
equal deleted inserted replaced
12:5a06f39ad45b 14:80975da52420
    97     TRACE_PRN_FN_ENT;
    97     TRACE_PRN_FN_ENT;
    98     delete iTtsPlayer;
    98     delete iTtsPlayer;
    99     iTtsPlayer = NULL;
    99     iTtsPlayer = NULL;
   100     iTtsPlayer = CMdaAudioPlayerUtility::NewL(*this, aPriority, aPreference);
   100     iTtsPlayer = CMdaAudioPlayerUtility::NewL(*this, aPriority, aPreference);
   101 
   101 
       
   102     __ASSERT_DEBUG(iTtsPlayer, PANIC(TMS_RESULT_UNINITIALIZED_OBJECT));
       
   103 
   102     delete iTtsText;
   104     delete iTtsText;
   103     iTtsText = NULL;
   105     iTtsText = NULL;
   104     // UTF-8 strings can take up to 4 bytes per character
   106     // UTF-8 strings can take up to 4 bytes per character
   105     iTtsText = HBufC8::NewL(aTtsText.Length() << KUTF8Multiply);
   107     iTtsText = HBufC8::NewL(aTtsText.Length() << KUTF8Multiply);
       
   108 
       
   109     __ASSERT_DEBUG(iTtsText, PANIC(TMS_RESULT_UNINITIALIZED_OBJECT));
   106 
   110 
   107     TPtr8 refText = iTtsText->Des();
   111     TPtr8 refText = iTtsText->Des();
   108     User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(refText,
   112     User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(refText,
   109             aTtsText));
   113             aTtsText));
   110 
   114 
   532 void TMSRtAudioHdlr::SetRingingTypeProperties()
   536 void TMSRtAudioHdlr::SetRingingTypeProperties()
   533     {
   537     {
   534     TInt rampTime(0);
   538     TInt rampTime(0);
   535     if (iFormat == EFormatTone)
   539     if (iFormat == EFormatTone)
   536         {
   540         {
       
   541         __ASSERT_DEBUG(iTonePlayer, PANIC(TMS_RESULT_UNINITIALIZED_OBJECT));
   537         switch (iRingType)
   542         switch (iRingType)
   538             {
   543             {
   539             case ETypeRinging:
   544             case ETypeRinging:
   540                 {
   545                 {
   541                 // If we have TTS activated and ringing type is "ringing", then
   546                 // If we have TTS activated and ringing type is "ringing", then
   602         //Set priority and preference
   607         //Set priority and preference
   603         iTonePlayer->SetPriority(iPriority, iPreference);
   608         iTonePlayer->SetPriority(iPriority, iPreference);
   604         }
   609         }
   605     else if (iFormat == EFormatTts)
   610     else if (iFormat == EFormatTts)
   606         {
   611         {
       
   612         __ASSERT_DEBUG(iTtsPlayer, PANIC(TMS_RESULT_UNINITIALIZED_OBJECT));
   607         switch (iRingType)
   613         switch (iRingType)
   608             {
   614             {
   609             case ETypeRinging:
   615             case ETypeRinging:
   610             case ETypeAscending:
   616             case ETypeAscending:
   611                 {
   617                 {
   626                 }
   632                 }
   627             }
   633             }
   628         }
   634         }
   629     else
   635     else
   630         {
   636         {
       
   637         __ASSERT_DEBUG(iSamplePlayer, PANIC(TMS_RESULT_UNINITIALIZED_OBJECT));
   631         switch (iRingType)
   638         switch (iRingType)
   632             {
   639             {
   633             case ETypeRinging:
   640             case ETypeRinging:
   634                 {
   641                 {
   635                 // If we have TTS activated and ringing type is "ringing", then
   642                 // If we have TTS activated and ringing type is "ringing", then
   705 void TMSRtAudioHdlr::SetNewVolumeAndRamptime(TInt aVolume, TInt aRamptime)
   712 void TMSRtAudioHdlr::SetNewVolumeAndRamptime(TInt aVolume, TInt aRamptime)
   706     {
   713     {
   707     // Check that volume is in a valid range.
   714     // Check that volume is in a valid range.
   708     TInt volume = aVolume < 1 ? 1 : aVolume;
   715     TInt volume = aVolume < 1 ? 1 : aVolume;
   709 
   716 
   710     if (iFormat == EFormatTone && iTonePlayer)
   717     if (iFormat == EFormatTone)
   711         {
   718         {
   712         iTonePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
   719         if (iTonePlayer)
   713         iTonePlayer->SetVolume(ConvertVolume(volume));
   720             {
   714         }
   721             iTonePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
   715     else if (iFormat == EFormatTts && iTtsPlayer)
   722             iTonePlayer->SetVolume(ConvertVolume(volume));
   716         {
   723             }
   717         iTtsPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
   724         }
   718         iTtsPlayer->SetVolume(ConvertVolume(volume));
   725     else if (iFormat == EFormatTts)
       
   726         {
       
   727         if (iTtsPlayer)
       
   728             {
       
   729             iTtsPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
       
   730             iTtsPlayer->SetVolume(ConvertVolume(volume));
       
   731             }
   719         }
   732         }
   720     else
   733     else
   721         {
   734         {
   722         iSamplePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
   735         if (iSamplePlayer)
   723         iSamplePlayer->SetVolume(ConvertVolume(volume));
   736             {
       
   737             iSamplePlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(aRamptime));
       
   738             iSamplePlayer->SetVolume(ConvertVolume(volume));
       
   739             }
   724         }
   740         }
   725     }
   741     }
   726 
   742 
   727 // -----------------------------------------------------------------------------
   743 // -----------------------------------------------------------------------------
   728 // TMSRtAudioHdlr::ConvertVolume
   744 // TMSRtAudioHdlr::ConvertVolume
   732     {
   748     {
   733     TInt result(0);
   749     TInt result(0);
   734 
   750 
   735     if (iFormat == EFormatTone)
   751     if (iFormat == EFormatTone)
   736         {
   752         {
   737         result = iTonePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
   753         if (iTonePlayer)
       
   754             {
       
   755             result = iTonePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
       
   756             }
   738         }
   757         }
   739     else if (iFormat == EFormatTts)
   758     else if (iFormat == EFormatTts)
   740         {
   759         {
   741         result = iTtsPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
   760         if (iTtsPlayer)
       
   761             {
       
   762             result = iTtsPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
       
   763             }
   742         }
   764         }
   743     else
   765     else
   744         {
   766         {
   745         result = iSamplePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
   767         if (iSamplePlayer)
       
   768             {
       
   769             result = iSamplePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
       
   770             }
   746         }
   771         }
   747 
   772 
   748     // If user selected minimum volume level set HW volume 1
   773     // If user selected minimum volume level set HW volume 1
   749     if (aVolume == KMinVolumeLevel && result == 0)
   774     if (aVolume == KMinVolumeLevel && result == 0)
   750         {
   775         {
   770     {
   795     {
   771     if (iPlayerStatus == ETonePlaying)
   796     if (iPlayerStatus == ETonePlaying)
   772         {
   797         {
   773         if (iFormat == EFormatTone)
   798         if (iFormat == EFormatTone)
   774             {
   799             {
   775             iTonePlayer->SetVolume(0);
   800             if (iTonePlayer)
   776             }
   801                 {
   777         else if (iFormat == EFormatTts)
   802                 iTonePlayer->SetVolume(0);
   778             {
   803                 }
   779             iTtsPlayer->SetVolume(0);
   804             }
       
   805         else if (iFormat == EFormatTts && iTtsPlayer)
       
   806             {
       
   807             if (iTtsPlayer)
       
   808                 {
       
   809                 iTtsPlayer->SetVolume(0);
       
   810                 }
   780             }
   811             }
   781         else // EFormatSample
   812         else // EFormatSample
   782             {
   813             {
   783             iSamplePlayer->SetVolume(0);
   814             if (iSamplePlayer)
       
   815                 {
       
   816                 iSamplePlayer->SetVolume(0);
       
   817                 }
   784             }
   818             }
   785         }
   819         }
   786     else
   820     else
   787         {
   821         {
   788         // Mute during EToneLoading state.
   822         // Mute during EToneLoading state.