664 return iState; |
702 return iState; |
665 } |
703 } |
666 |
704 |
667 TInt CMMFMdaAudioToneUtility::MaxVolume() |
705 TInt CMMFMdaAudioToneUtility::MaxVolume() |
668 { |
706 { |
669 return iDevSound->MaxVolume(); |
707 return 100; |
670 } |
708 } |
671 |
709 |
672 TInt CMMFMdaAudioToneUtility::Volume() |
710 TInt CMMFMdaAudioToneUtility::Volume() |
673 { |
711 { |
674 return iDevSound->Volume(); |
712 return iDevSoundVolume; |
675 } |
713 } |
676 |
714 |
677 void CMMFMdaAudioToneUtility::SetVolume(TInt aVolume) |
715 void CMMFMdaAudioToneUtility::SetVolume(TInt aVolume) |
678 { |
716 { |
679 iDevSound->SetVolume(aVolume); |
717 iDevSoundVolume = aVolume; |
680 } |
718 } |
681 |
719 |
682 void CMMFMdaAudioToneUtility::SetPriority(TInt aPriority, TInt aPref) |
720 void CMMFMdaAudioToneUtility::SetPriority(TInt aPriority, TInt aPref) |
683 { |
721 { |
684 iPrioritySettings.iPref = aPref; |
722 iPrioritySettings.iPref = aPref; |
685 iPrioritySettings.iPriority = aPriority; |
723 iPrioritySettings.iPriority = aPriority; |
686 iDevSound->SetPrioritySettings(iPrioritySettings); |
|
687 } |
724 } |
688 |
725 |
689 void CMMFMdaAudioToneUtility::SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength, |
726 void CMMFMdaAudioToneUtility::SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength, |
690 TTimeIntervalMicroSeconds32 aToneOffLength, |
727 TTimeIntervalMicroSeconds32 aToneOffLength, |
691 TTimeIntervalMicroSeconds32 aPauseLength) |
728 TTimeIntervalMicroSeconds32 aPauseLength) |
692 { |
729 { |
693 iDevSound->SetDTMFLengths(aToneLength, aToneOffLength, aPauseLength); |
|
694 } |
730 } |
695 |
731 |
696 void CMMFMdaAudioToneUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) |
732 void CMMFMdaAudioToneUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) |
697 { |
733 { |
698 iDevSound->SetToneRepeats(aRepeatNumberOfTimes, aTrailingSilence); |
734 // iDevSound->SetToneRepeats(aRepeatNumberOfTimes, aTrailingSilence); |
699 } |
735 } |
700 |
736 |
701 void CMMFMdaAudioToneUtility::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration) |
737 void CMMFMdaAudioToneUtility::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration) |
702 { |
738 { |
703 iDevSound->SetVolumeRamp(aRampDuration); |
|
704 } |
739 } |
705 |
740 |
706 TInt CMMFMdaAudioToneUtility::FixedSequenceCount() |
741 TInt CMMFMdaAudioToneUtility::FixedSequenceCount() |
707 { |
742 { |
708 return iDevSound->FixedSequenceCount(); |
743 return 1; // iDevSound->FixedSequenceCount(); |
709 } |
744 } |
710 |
745 |
|
746 _LIT(KFixedSequenceName, "FixedSequenceName"); |
711 const TDesC& CMMFMdaAudioToneUtility::FixedSequenceName(TInt aSequenceNumber) |
747 const TDesC& CMMFMdaAudioToneUtility::FixedSequenceName(TInt aSequenceNumber) |
712 { |
748 { |
713 return iDevSound->FixedSequenceName(aSequenceNumber); |
749 return KFixedSequenceName; |
714 } |
750 } |
715 |
751 |
716 /** |
|
717 * CalculateBalance |
|
718 * @param aBalance |
|
719 * @param aLeft |
|
720 * @param aRight |
|
721 * |
|
722 * follows a simple straight line transformation |
|
723 * y = m x + c |
|
724 * m = (KMMFBalanceMaxLeft-KMMFBalanceMaxRight)/ 100 |
|
725 * c = KMMFBalanceMaxRight |
|
726 * by substitution |
|
727 * when aLeft = 0 |
|
728 * KMMFBalanceMaxRight = m * 0 + c |
|
729 * c = KMMFBalanceMaxRight |
|
730 * when aLeft = 100 |
|
731 * KMMFBalanceMaxLeft = m * 100 + KMMFBalanceMaxRight |
|
732 * m = ( KMMFBalanceMaxLeft - KMMFBalanceMaxRight ) /100 |
|
733 */ |
|
734 void CMMFMdaAudioToneUtility::CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const |
752 void CMMFMdaAudioToneUtility::CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const |
735 { |
753 { |
736 //[ assert pre conditions ] |
754 } |
737 __ASSERT_ALWAYS( (( aLeft + aRight ) == 100 ), Panic( EBadArgument )); |
755 |
738 __ASSERT_ALWAYS( (( 0 <= aLeft) && ( 100 >= aLeft)), Panic( EBadArgument) ); |
756 |
739 __ASSERT_ALWAYS( (( 0 <= aRight) && ( 100 >= aRight)), Panic( EBadArgument) ); |
|
740 |
|
741 aBalance = (aLeft * (KMMFBalanceMaxLeft-KMMFBalanceMaxRight))/100 + KMMFBalanceMaxRight; |
|
742 |
|
743 //[ assert post condition that aBalance is within limits ] |
|
744 __ASSERT_ALWAYS( !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight), Panic(EBadArgument)); |
|
745 |
|
746 } |
|
747 |
|
748 |
|
749 /** |
|
750 * CalculateLeftRightBalance |
|
751 * @param aLeft |
|
752 * @param aRight |
|
753 * @param aBalance |
|
754 * Preconditions: |
|
755 * !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight) |
|
756 * y = m x + c |
|
757 * aLeft = m ( aBalance ) + c |
|
758 * when aBalance = KMMFBalanceMaxLeft aLeft = 100 |
|
759 * when aBalance = KMMFBalanceMaxRight aLeft = 0 |
|
760 * 100 = m( KMMFBalanceMaxLeft ) + c |
|
761 * 0 = m( KMMFBalanceMaxRight ) + c |
|
762 * c = -(KMMFBalanceMaxRight) m |
|
763 * 100 = m(KMMFBalanceMaxLeft ) - m(KMMFBalanceMaxRight) |
|
764 * m = 100/(KMMFBalanceMaxLeft - KMMFBalanceMaxRight ) |
|
765 * c = -(KMMFBalanceMaxRight) * 100 /(KMMFBalanceMaxLeft - KMMFBalanceMaxRight ) |
|
766 * aLeft = ( aBalance - KMMFBalanceMaxRight ) * 100 /( KMMFBalanceMaxLeft - KMMFBalanceMaxRight ) |
|
767 */ |
|
768 void CMMFMdaAudioToneUtility::CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const |
757 void CMMFMdaAudioToneUtility::CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const |
769 { |
758 { |
770 // [ assert precondition that aBalance is within limits ] |
|
771 __ASSERT_ALWAYS( !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight), Panic(EBadArgument)); |
|
772 |
|
773 //[ Now separate percentage balances out from aBalance ] |
|
774 aLeft = (100 * (aBalance-KMMFBalanceMaxRight)) / (KMMFBalanceMaxLeft-KMMFBalanceMaxRight); |
|
775 aRight = 100 - aLeft; |
|
776 |
|
777 //[ assert post condition that left and right are within range ] |
|
778 __ASSERT_ALWAYS( ( (aLeft <= 100) && (aLeft >= 0) ), Panic(EPostConditionViolation)); |
|
779 __ASSERT_ALWAYS( ( (aRight <= 100) && (aRight >= 0) ), Panic(EPostConditionViolation)); |
|
780 } |
759 } |
781 |
760 |
782 |
761 |
783 void CMMFMdaAudioToneUtility::SetBalanceL(TInt aBalance) |
762 void CMMFMdaAudioToneUtility::SetBalanceL(TInt aBalance) |
784 { |
763 { |
785 TInt left; |
764 iDevSoundBalance = aBalance; |
786 TInt right; |
|
787 CalculateLeftRightBalance(left,right,aBalance); |
|
788 iDevSound->SetPlayBalanceL(left,right); |
|
789 } |
765 } |
790 |
766 |
791 TInt CMMFMdaAudioToneUtility::GetBalanceL() |
767 TInt CMMFMdaAudioToneUtility::GetBalanceL() |
792 { |
768 { |
793 TInt left; |
769 return iDevSoundBalance; |
794 TInt right; |
|
795 TInt balance; |
|
796 iDevSound->GetPlayBalanceL(left, right); |
|
797 CalculateBalance(balance,left,right); |
|
798 return balance; |
|
799 } |
770 } |
800 |
771 |
801 void CMMFMdaAudioToneUtility::PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration) |
772 void CMMFMdaAudioToneUtility::PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration) |
802 { |
773 { |
803 delete iToneConfig; |
774 iDuration = aDuration; |
804 iToneConfig = NULL; |
775 iAsyncCallback->MatoPrepareComplete(KErrNone); |
805 TRAPD(error, iToneConfig = CMMFSimpleToneConfig::NewL(aFrequency, aDuration)); |
|
806 iAsyncCallback->MatoPrepareComplete(error); |
|
807 } |
776 } |
808 |
777 |
809 void CMMFMdaAudioToneUtility::PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration) |
778 void CMMFMdaAudioToneUtility::PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration) |
810 { |
779 { |
811 delete iToneConfig; |
780 iDuration = aDuration; |
812 iToneConfig = NULL; |
781 iAsyncCallback->MatoPrepareComplete(KErrNone); |
813 TRAPD(error, iToneConfig = CMMFDualToneConfig::NewL(aFrequencyOne, aFrequencyTwo, aDuration)); |
|
814 iAsyncCallback->MatoPrepareComplete(error); |
|
815 } |
782 } |
816 |
783 |
817 void CMMFMdaAudioToneUtility::PrepareToPlayDTMFString(const TDesC& aDTMF) |
784 void CMMFMdaAudioToneUtility::PrepareToPlayDTMFString(const TDesC& aDTMF) |
818 { |
785 { |
819 delete iToneConfig; |
786 iDuration = TTimeIntervalMicroSeconds(100); |
820 iToneConfig = NULL; |
787 iAsyncCallback->MatoPrepareComplete(KErrNone); |
821 TRAPD(error, iToneConfig = CMMFDTMFStringToneConfig::NewL(aDTMF)); |
|
822 iAsyncCallback->MatoPrepareComplete(error); |
|
823 } |
788 } |
824 |
789 |
825 void CMMFMdaAudioToneUtility::PrepareToPlayDesSequence(const TDesC8& aSequence) |
790 void CMMFMdaAudioToneUtility::PrepareToPlayDesSequence(const TDesC8& aSequence) |
826 { |
791 { |
827 delete iToneConfig; |
792 iDuration = TTimeIntervalMicroSeconds(100); |
828 iToneConfig = NULL; |
793 iAsyncCallback->MatoPrepareComplete(KErrNone); |
829 TRAPD(error, iToneConfig = CMMFDesSeqToneConfig::NewL(aSequence)); |
|
830 iAsyncCallback->MatoPrepareComplete(error); |
|
831 } |
794 } |
832 |
795 |
833 void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(const TDesC& aFileName) |
796 void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(const TDesC& aFileName) |
834 { |
797 { |
835 delete iToneConfig; |
798 iDuration = TTimeIntervalMicroSeconds(100); |
836 iToneConfig = NULL; |
799 iAsyncCallback->MatoPrepareComplete(KErrNone); |
837 TRAPD(error, iToneConfig = CMMFFileSeqToneConfig::NewL(aFileName)); |
|
838 iAsyncCallback->MatoPrepareComplete(error); |
|
839 } |
800 } |
840 |
801 |
841 void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(RFile& aFileName) |
802 void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(RFile& aFileName) |
842 { |
803 { |
843 delete iToneConfig; |
804 iDuration = TTimeIntervalMicroSeconds(100); |
844 iToneConfig = NULL; |
805 iAsyncCallback->MatoPrepareComplete(KErrNone); |
845 TRAPD(error, iToneConfig = CMMFFileSeqToneConfig::NewL(aFileName)); |
|
846 iAsyncCallback->MatoPrepareComplete(error); |
|
847 } |
806 } |
848 |
807 |
849 |
808 |
850 |
809 |
851 |
810 |
852 void CMMFMdaAudioToneUtility::PrepareToPlayFixedSequence(TInt aSequenceNumber) |
811 void CMMFMdaAudioToneUtility::PrepareToPlayFixedSequence(TInt aSequenceNumber) |
853 { |
812 { |
854 delete iToneConfig; |
813 iDuration = TTimeIntervalMicroSeconds(100); |
855 iToneConfig = NULL; |
|
856 TRAPD(error, iToneConfig = CMMFFixedSeqToneConfig::NewL(aSequenceNumber)); |
|
857 iSequenceNumber = aSequenceNumber; |
814 iSequenceNumber = aSequenceNumber; |
858 iAsyncCallback->MatoPrepareComplete(error); |
815 iAsyncCallback->MatoPrepareComplete(KErrNone); |
859 } |
816 } |
860 |
817 |
861 void CMMFMdaAudioToneUtility::CancelPrepare() |
818 void CMMFMdaAudioToneUtility::CancelPrepare() |
862 { |
819 { |
863 // FIXME - do we need to cancel the callback? What if the callback is actually calling back another error? Probably best not to cancel... |
|
864 delete iToneConfig; |
|
865 iToneConfig = NULL; |
|
866 |
|
867 if (iState == EMdaAudioToneUtilityPrepared) |
820 if (iState == EMdaAudioToneUtilityPrepared) |
868 { |
821 { |
869 iState = EMdaAudioToneUtilityNotReady; |
822 iState = EMdaAudioToneUtilityNotReady; |
870 } |
823 } |
871 // Cancel the AO |
824 // Cancel the AO |
878 if (iState != EMdaAudioToneUtilityPlaying || (iState == EMdaAudioToneUtilityPlaying && !iInitialized)) |
831 if (iState != EMdaAudioToneUtilityPlaying || (iState == EMdaAudioToneUtilityPlaying && !iInitialized)) |
879 { |
832 { |
880 return KErrNotReady; |
833 return KErrNotReady; |
881 } |
834 } |
882 |
835 |
883 else if(! iDevSound->IsResumeSupported() || iToneConfig->Type() != CMMFToneConfig::EMmfToneTypeFileSeq) |
|
884 { |
|
885 return KErrNotSupported; |
|
886 } |
|
887 |
|
888 iDevSound->Pause(); |
|
889 iState = EMdaAudioToneUtilityPaused; |
836 iState = EMdaAudioToneUtilityPaused; |
890 return KErrNone; |
837 return KErrNone; |
891 } |
838 } |
892 |
839 |
893 TInt CMMFMdaAudioToneUtility::Resume() |
840 TInt CMMFMdaAudioToneUtility::Resume() |
894 { |
841 { |
895 TInt err = KErrNone; |
|
896 if (iState != EMdaAudioToneUtilityPaused) |
842 if (iState != EMdaAudioToneUtilityPaused) |
897 { |
843 { |
898 err = KErrNotReady; |
844 return KErrNotReady; |
899 } |
845 } |
900 |
846 |
901 else if( iDevSound->IsResumeSupported() == EFalse || iToneConfig->Type() != CMMFToneConfig::EMmfToneTypeFileSeq) |
847 iState = EMdaAudioToneUtilityPlaying; |
902 { |
848 return KErrNone; |
903 err = KErrNotSupported; |
|
904 } |
|
905 |
|
906 if(err == KErrNone) |
|
907 { |
|
908 err = iDevSound->Resume(); |
|
909 if(err == KErrNone) |
|
910 { |
|
911 iState = EMdaAudioToneUtilityPlaying; |
|
912 } |
|
913 } |
|
914 return err; |
|
915 } |
849 } |
916 |
850 |
917 void CMMFMdaAudioToneUtility::Play() |
851 void CMMFMdaAudioToneUtility::Play() |
918 { |
852 { |
919 TInt error = KErrNone; |
853 TInt error = KErrNone; |
920 |
854 |
921 if ((iState == EMdaAudioToneUtilityPlaying) || (iState == EMdaAudioToneUtilityPaused) || iPlayCalled) |
855 if ((iState == EMdaAudioToneUtilityPlaying) || (iState == EMdaAudioToneUtilityPaused) || iPlayCalled) |
922 { |
|
923 error = KErrInUse; |
|
924 } |
|
925 |
|
926 if (!error) |
|
927 { |
|
928 if (!iToneConfig) |
|
929 { |
|
930 TRAP(error, iToneConfig = CMMFFixedSeqToneConfig::NewL(iSequenceNumber)); |
|
931 } |
|
932 } |
|
933 // If there was an error, notify the client now. Otherwise, client will be notified when |
|
934 // play has finished. |
|
935 if (error) |
|
936 { |
856 { |
937 iState = EMdaAudioToneUtilityNotReady; |
857 iState = EMdaAudioToneUtilityNotReady; |
938 iAsyncCallback->MatoPlayComplete(error); |
858 iAsyncCallback->MatoPlayComplete(error); |
|
859 return; |
939 } |
860 } |
940 |
861 |
941 if (!error) |
862 iState = EMdaAudioToneUtilityPlaying; |
942 { |
863 |
943 iState = EMdaAudioToneUtilityPlaying; |
864 if (iInitialized) |
944 |
865 { |
945 if (iInitialized) |
866 // Play() is called after InitializeComplete() |
|
867 if (iInitializeState) |
946 { |
868 { |
947 // Play() is called after InitializeComplete() |
869 // InitializeComplete() with error other than KErrNone |
948 if (iInitializeState) |
870 iState = EMdaAudioToneUtilityNotReady; |
949 { |
871 iAsyncCallback->MatoPlayComplete(iInitializeState); |
950 // InitializeComplete() with error other than KErrNone |
|
951 iState = EMdaAudioToneUtilityNotReady; |
|
952 iAsyncCallback->MatoPlayComplete(iInitializeState); |
|
953 } |
|
954 else |
|
955 { |
|
956 PlayAfterInitialized(); |
|
957 } |
|
958 } |
872 } |
959 else |
873 else |
960 { |
874 { |
961 // Play() is called before InitializeComplete() |
875 PlayAfterInitialized(); |
962 iPlayCalled = ETrue; |
|
963 } |
876 } |
|
877 } |
|
878 else |
|
879 { |
|
880 // Play() is called before InitializeComplete() |
|
881 iPlayCalled = ETrue; |
964 } |
882 } |
965 } |
883 } |
966 |
884 |
967 void CMMFMdaAudioToneUtility::PlayAfterInitialized() |
885 void CMMFMdaAudioToneUtility::PlayAfterInitialized() |
968 { |
886 { |
971 { |
889 { |
972 iPlayCalledBeforeInitialized = ETrue; |
890 iPlayCalledBeforeInitialized = ETrue; |
973 } |
891 } |
974 #endif |
892 #endif |
975 |
893 |
976 TInt error = KErrNone; |
894 // Really play something! |
977 switch (iToneConfig->Type()) |
895 // TRAP(error, iDevSound->PlayToneL(c->Frequency(), c->Duration())); |
978 { |
896 iTimer->Play(iDuration); |
979 case CMMFToneConfig::EMmfToneTypeSimple: |
897 |
980 { |
898 #if 0 // the error case |
981 CMMFSimpleToneConfig* c = STATIC_CAST(CMMFSimpleToneConfig*, iToneConfig); |
899 iState = EMdaAudioToneUtilityNotReady; |
982 TRAP(error, iDevSound->PlayToneL(c->Frequency(), c->Duration())); |
900 iAsyncCallback->MatoPlayComplete(error); |
983 break; |
901 return; |
984 } |
902 #endif |
985 case CMMFToneConfig::EMmfToneTypeDual: |
903 |
986 { |
904 if(iPlayStartObserver) |
987 CMMFDualToneConfig* c = STATIC_CAST(CMMFDualToneConfig*, iToneConfig); |
905 { |
988 TRAP(error, iDevSound->PlayDualToneL(c->FrequencyOne(), c->FrequencyTwo(), c->Duration())); |
906 iAsyncCallback->MatoPlayStarted(KErrNone); |
989 break; |
|
990 } |
|
991 case CMMFToneConfig::EMmfToneTypeDTMF: |
|
992 { |
|
993 CMMFDTMFStringToneConfig* c = STATIC_CAST(CMMFDTMFStringToneConfig*, iToneConfig); |
|
994 TRAP(error, iDevSound->PlayDTMFStringL(c->DTMF())); |
|
995 break; |
|
996 } |
|
997 case CMMFToneConfig::EMmfToneTypeDesSeq: |
|
998 { |
|
999 CMMFDesSeqToneConfig* c = STATIC_CAST(CMMFDesSeqToneConfig*, iToneConfig); |
|
1000 TRAP(error, iDevSound->PlayToneSequenceL(c->DesSeq())); |
|
1001 break; |
|
1002 } |
|
1003 case CMMFToneConfig::EMmfToneTypeFileSeq: |
|
1004 { |
|
1005 CMMFFileSeqToneConfig* c = STATIC_CAST(CMMFFileSeqToneConfig*, iToneConfig); |
|
1006 |
|
1007 // check we have rights to play |
|
1008 TRAP(error, c->ExecuteIntentL()); |
|
1009 |
|
1010 // if we have rights then go ahead and play |
|
1011 if (error == KErrNone) |
|
1012 { |
|
1013 TRAP(error, iDevSound->PlayToneSequenceL(c->FileSeq())); |
|
1014 } |
|
1015 |
|
1016 break; |
|
1017 } |
|
1018 case CMMFToneConfig::EMmfToneTypeFixedSeq: |
|
1019 { |
|
1020 CMMFFixedSeqToneConfig* c = STATIC_CAST(CMMFFixedSeqToneConfig*, iToneConfig); |
|
1021 TRAP(error, iDevSound->PlayFixedSequenceL(c->SequenceNumber())); |
|
1022 break; |
|
1023 } |
|
1024 default: |
|
1025 { |
|
1026 User::Panic(KMMFMdaAudioToneUtilityPanicCategory, EMMFMdaAudioToneUtilityBadToneConfig); |
|
1027 break; |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 // If there was an error, notify the client now. Otherwise, client will be notified when |
|
1032 // play has finished. |
|
1033 if (error) |
|
1034 { |
|
1035 iState = EMdaAudioToneUtilityNotReady; |
|
1036 iAsyncCallback->MatoPlayComplete(error); |
|
1037 } |
|
1038 else |
|
1039 { |
|
1040 if(iPlayStartObserver) |
|
1041 { |
|
1042 iAsyncCallback->MatoPlayStarted(KErrNone); |
|
1043 } |
|
1044 } |
907 } |
1045 } |
908 } |
1046 |
909 |
1047 void CMMFMdaAudioToneUtility::CancelPlay() |
910 void CMMFMdaAudioToneUtility::CancelPlay() |
1048 { |
911 { |
1049 iDevSound->Stop(); |
912 iTimer->Cancel(); |
1050 |
|
1051 if(iState == EMdaAudioToneUtilityPlaying || iState == EMdaAudioToneUtilityPaused) |
913 if(iState == EMdaAudioToneUtilityPlaying || iState == EMdaAudioToneUtilityPaused) |
1052 { |
914 { |
1053 iState = EMdaAudioToneUtilityPrepared; |
915 iState = EMdaAudioToneUtilityPrepared; |
1054 } |
916 } |
1055 // Cancel the AO |
917 // Cancel the AO |
1186 void CMMFMdaAudioToneObserverCallback::DoCancel() |
1048 void CMMFMdaAudioToneObserverCallback::DoCancel() |
1187 { |
1049 { |
1188 //nothing to cancel |
1050 //nothing to cancel |
1189 } |
1051 } |
1190 |
1052 |
1191 |
1053 void MMMFClientUtility::ReservedVirtual1() {} |
1192 |
1054 void MMMFClientUtility::ReservedVirtual2() {} |
1193 |
1055 void MMMFClientUtility::ReservedVirtual3() {} |
1194 |
1056 void MMMFClientUtility::ReservedVirtual4() {} |
1195 |
1057 void MMMFClientUtility::ReservedVirtual5() {} |
1196 // Tone config classes |
1058 void MMMFClientUtility::ReservedVirtual6() {} |
1197 |
1059 |
1198 // Simple Tone |
|
1199 CMMFToneConfig* CMMFSimpleToneConfig::NewL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration) |
|
1200 { |
|
1201 return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFSimpleToneConfig(aFrequency, aDuration)); |
|
1202 } |
|
1203 |
|
1204 CMMFSimpleToneConfig::CMMFSimpleToneConfig(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration) : |
|
1205 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeSimple), |
|
1206 iFrequency(aFrequency), |
|
1207 iDuration(aDuration) |
|
1208 { |
|
1209 } |
|
1210 |
|
1211 CMMFSimpleToneConfig::~CMMFSimpleToneConfig() |
|
1212 { |
|
1213 } |
|
1214 |
|
1215 TInt CMMFSimpleToneConfig::Frequency() |
|
1216 { |
|
1217 return iFrequency; |
|
1218 } |
|
1219 |
|
1220 const TTimeIntervalMicroSeconds& CMMFSimpleToneConfig::Duration() |
|
1221 { |
|
1222 return iDuration; |
|
1223 } |
|
1224 |
|
1225 |
|
1226 // Dual Tone |
|
1227 CMMFToneConfig* CMMFDualToneConfig::NewL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration) |
|
1228 { |
|
1229 return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFDualToneConfig(aFrequencyOne, aFrequencyTwo, aDuration)); |
|
1230 } |
|
1231 |
|
1232 CMMFDualToneConfig::CMMFDualToneConfig(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration) : |
|
1233 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDual), |
|
1234 iFrequencyOne(aFrequencyOne), |
|
1235 iFrequencyTwo(aFrequencyTwo), |
|
1236 iDuration(aDuration) |
|
1237 { |
|
1238 } |
|
1239 |
|
1240 CMMFDualToneConfig::~CMMFDualToneConfig() |
|
1241 { |
|
1242 } |
|
1243 |
|
1244 TInt CMMFDualToneConfig::FrequencyOne() |
|
1245 { |
|
1246 return iFrequencyOne; |
|
1247 } |
|
1248 |
|
1249 TInt CMMFDualToneConfig::FrequencyTwo() |
|
1250 { |
|
1251 return iFrequencyTwo; |
|
1252 } |
|
1253 |
|
1254 const TTimeIntervalMicroSeconds& CMMFDualToneConfig::Duration() |
|
1255 { |
|
1256 return iDuration; |
|
1257 } |
|
1258 |
|
1259 |
|
1260 CMMFToneConfig* CMMFDTMFStringToneConfig::NewL(const TDesC& aDTMF) |
|
1261 { |
|
1262 CMMFDTMFStringToneConfig* s = new(ELeave) CMMFDTMFStringToneConfig; |
|
1263 CleanupStack::PushL(s); |
|
1264 s->ConstructL(aDTMF); |
|
1265 CleanupStack::Pop(); |
|
1266 return STATIC_CAST(CMMFToneConfig*, s); |
|
1267 } |
|
1268 |
|
1269 CMMFDTMFStringToneConfig::CMMFDTMFStringToneConfig() : |
|
1270 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDTMF) |
|
1271 { |
|
1272 } |
|
1273 |
|
1274 LOCAL_C void validateDTMFL(const TDesC& aDTMF) |
|
1275 // |
|
1276 // Validate that the supplied DTMf string contains only playable characters |
|
1277 // |
|
1278 { |
|
1279 TInt stringLength = aDTMF.Length(); |
|
1280 TChar ch; |
|
1281 for (TInt index = 0; index < stringLength ; index++) |
|
1282 { |
|
1283 ch = aDTMF[index]; |
|
1284 if (!ch.IsDigit() && !ch.IsHexDigit() && !ch.IsSpace() && |
|
1285 (ch != '*') && (ch != '#') && (ch != ',')) |
|
1286 { |
|
1287 User::Leave(KErrArgument); // Bad DTMF string |
|
1288 } |
|
1289 } |
|
1290 } |
|
1291 |
|
1292 void CMMFDTMFStringToneConfig::ConstructL(const TDesC& aDTMF) |
|
1293 { |
|
1294 validateDTMFL(aDTMF); |
|
1295 iDTMF = aDTMF.AllocL(); |
|
1296 } |
|
1297 |
|
1298 CMMFDTMFStringToneConfig::~CMMFDTMFStringToneConfig() |
|
1299 { |
|
1300 delete iDTMF; |
|
1301 } |
|
1302 |
|
1303 const TDesC& CMMFDTMFStringToneConfig::DTMF() |
|
1304 { |
|
1305 return *iDTMF; |
|
1306 } |
|
1307 |
|
1308 |
|
1309 CMMFToneConfig* CMMFDesSeqToneConfig::NewL(const TDesC8& aDesSeq) |
|
1310 { |
|
1311 CMMFDesSeqToneConfig* s = new(ELeave) CMMFDesSeqToneConfig; |
|
1312 CleanupStack::PushL(s); |
|
1313 s->ConstructL(aDesSeq); |
|
1314 CleanupStack::Pop(); |
|
1315 return STATIC_CAST(CMMFToneConfig*, s); |
|
1316 } |
|
1317 |
|
1318 CMMFDesSeqToneConfig::CMMFDesSeqToneConfig() : |
|
1319 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDesSeq) |
|
1320 { |
|
1321 } |
|
1322 |
|
1323 void CMMFDesSeqToneConfig::ConstructL(const TDesC8& aDesSeq) |
|
1324 { |
|
1325 iDesSeq = aDesSeq.AllocL(); |
|
1326 } |
|
1327 |
|
1328 CMMFDesSeqToneConfig::~CMMFDesSeqToneConfig() |
|
1329 { |
|
1330 delete iDesSeq; |
|
1331 } |
|
1332 |
|
1333 const TDesC8& CMMFDesSeqToneConfig::DesSeq() |
|
1334 { |
|
1335 return *iDesSeq; |
|
1336 } |
|
1337 |
|
1338 |
|
1339 CMMFToneConfig* CMMFFileSeqToneConfig::NewL(const TDesC& aFileSeq) |
|
1340 { |
|
1341 CMMFFileSeqToneConfig* s = new(ELeave) CMMFFileSeqToneConfig; |
|
1342 CleanupStack::PushL(s); |
|
1343 s->ConstructL(aFileSeq); |
|
1344 CleanupStack::Pop(); |
|
1345 return STATIC_CAST(CMMFToneConfig*, s); |
|
1346 } |
|
1347 |
|
1348 CMMFFileSeqToneConfig::CMMFFileSeqToneConfig() : |
|
1349 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeFileSeq) |
|
1350 { |
|
1351 } |
|
1352 |
|
1353 void CMMFFileSeqToneConfig::ConstructL(const TDesC& aFileSeq) |
|
1354 { |
|
1355 // get access to DRM content through filename |
|
1356 iCAFContent = CContent::NewL(aFileSeq); |
|
1357 |
|
1358 // open the CAF source with play intent |
|
1359 iCAFData = iCAFContent->OpenContentL(ContentAccess::EPlay, KDefaultContentObject); |
|
1360 |
|
1361 // read into a descriptor |
|
1362 TInt dataSize = 0; |
|
1363 iCAFData->DataSizeL(dataSize); |
|
1364 |
|
1365 iDesSeq = HBufC8::NewL(dataSize); |
|
1366 TPtr8 desSeqPtr = iDesSeq->Des(); |
|
1367 iCAFData->Read(desSeqPtr); |
|
1368 } |
|
1369 |
|
1370 |
|
1371 |
|
1372 CMMFToneConfig* CMMFFileSeqToneConfig::NewL(RFile& aFile) |
|
1373 { |
|
1374 CMMFFileSeqToneConfig* s = new(ELeave) CMMFFileSeqToneConfig; |
|
1375 CleanupStack::PushL(s); |
|
1376 s->ConstructL(aFile); |
|
1377 CleanupStack::Pop(); |
|
1378 return STATIC_CAST(CMMFToneConfig*, s); |
|
1379 } |
|
1380 |
|
1381 |
|
1382 void CMMFFileSeqToneConfig::ConstructL(RFile& aFile) |
|
1383 { |
|
1384 // get DRM access to file handle |
|
1385 iCAFContent = CContent::NewL(aFile); |
|
1386 |
|
1387 // open the CAF source with play intent |
|
1388 iCAFData = iCAFContent->OpenContentL(ContentAccess::EPlay, KDefaultContentObject); |
|
1389 |
|
1390 // read into a descriptor |
|
1391 TInt dataSize = 0; |
|
1392 iCAFData->DataSizeL(dataSize); |
|
1393 |
|
1394 iDesSeq = HBufC8::NewL(dataSize); |
|
1395 TPtr8 desSeqPtr = iDesSeq->Des(); |
|
1396 iCAFData->Read(desSeqPtr); |
|
1397 } |
|
1398 |
|
1399 |
|
1400 CMMFFileSeqToneConfig::~CMMFFileSeqToneConfig() |
|
1401 { |
|
1402 delete iCAFData; |
|
1403 iCAFData = NULL; |
|
1404 |
|
1405 delete iCAFContent; |
|
1406 iCAFContent = NULL; |
|
1407 |
|
1408 delete iDesSeq; |
|
1409 } |
|
1410 |
|
1411 const TDesC8& CMMFFileSeqToneConfig::FileSeq() |
|
1412 { |
|
1413 return *iDesSeq; |
|
1414 } |
|
1415 |
|
1416 void CMMFFileSeqToneConfig::ExecuteIntentL() |
|
1417 { |
|
1418 if (iCAFData) |
|
1419 { |
|
1420 User::LeaveIfError(iCAFData->ExecuteIntent(ContentAccess::EPlay)); |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 CMMFToneConfig* CMMFFixedSeqToneConfig::NewL(TInt aSeqNo) |
|
1425 { |
|
1426 return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFFixedSeqToneConfig(aSeqNo)); |
|
1427 } |
|
1428 |
|
1429 CMMFFixedSeqToneConfig::CMMFFixedSeqToneConfig(TInt aSeqNo) : |
|
1430 CMMFToneConfig(CMMFToneConfig::EMmfToneTypeFixedSeq), |
|
1431 iSequenceNumber(aSeqNo) |
|
1432 { |
|
1433 } |
|
1434 |
|
1435 CMMFFixedSeqToneConfig::~CMMFFixedSeqToneConfig() |
|
1436 { |
|
1437 } |
|
1438 |
|
1439 TInt CMMFFixedSeqToneConfig::SequenceNumber() |
|
1440 { |
|
1441 return iSequenceNumber; |
|
1442 } |
|