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 |
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. |