Update contrib.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMF_AUDIOTONECONTROLLER_H__
17 #define __MMF_AUDIOTONECONTROLLER_H__
19 // Standard EPOC32 includes required by this header file
22 #include <ecom/implementationproxy.h>
24 // Public Media Server includes
25 #include <mmf/common/mmfcontroller.h>
26 #include <mmf/server/mmfdatasink.h>
27 #include <mmf/server/mmfdatasource.h>
29 #include <mmf/common/mmfstandardcustomcommands.h>
30 #include <mmf/server/sounddevice.h>
34 Panic category and codes for the Audio Tone Controller
37 _LIT(KMMFAudioToneControllerPanicCategory, "MMFAudioToneController");
38 enum TMMFMdaAudioToneControllerPanicCodes
40 EMMFMdaAudioToneControllerAlreadyPrepared,
41 EMMFMdaAudioToneControllerBadToneConfig,
42 EMMFMdaAudioToneControllerBadMixinCall
46 The public API for clients of the MMFAudioToneController
50 class CMMFAudioToneController : public CMMFController,
51 public MMMFAudioPlayDeviceCustomCommandImplementor,
52 public MMMFAudioPlayControllerCustomCommandImplementor,
53 public MDevSoundObserver,
54 public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
57 static CMMFController* NewL();
58 virtual ~CMMFAudioToneController();
60 //implement CMMFController ecom plugin interface
61 virtual void AddDataSourceL(MDataSource& aDataSource);
62 virtual void AddDataSinkL(MDataSink& aDataSink);
63 virtual void RemoveDataSourceL(MDataSource& aDataSource);
64 virtual void RemoveDataSinkL(MDataSink& aDataSink);
66 virtual void ResetL();
67 virtual void PrimeL();
68 virtual void PrimeL(TMMFMessage& aMessage);
70 virtual void PauseL();
73 virtual TTimeIntervalMicroSeconds PositionL() const {User::Leave(KErrNotSupported); TTimeIntervalMicroSeconds zero(0); return zero;}
74 virtual void SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/){}
75 virtual TTimeIntervalMicroSeconds DurationL() const {TTimeIntervalMicroSeconds zero(0); return zero;}
76 virtual void CustomCommand(TMMFMessage& aMessage);
78 virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
80 virtual void GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/){User::Leave(KErrNotSupported);}
81 virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt /*aIndex*/){User::Leave(KErrNotSupported); return NULL;}
83 //from MMMFAudioPlayDeviceCustomCommandImplementor
84 virtual void MapdSetVolumeL(TInt aVolume);
85 virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
86 virtual void MapdGetVolumeL(TInt& aVolume);
87 virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
88 virtual void MapdSetBalanceL(TInt aBalance);
89 virtual void MapdGetBalanceL(TInt& aBalance);
91 //from MMMFAudioPlayControllerCustomCommandImplementor
92 virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& /*aStart*/, const TTimeIntervalMicroSeconds& /*aEnd*/) {User::Leave(KErrNotSupported);}
93 virtual void MapcDeletePlaybackWindowL() {User::Leave(KErrNotSupported);}
94 virtual void MapcGetLoadingProgressL(TInt& /*aPercentageComplete*/) {User::Leave(KErrNotSupported);}
98 // From DevSoundObserver
99 void InitializeComplete(TInt aError);
100 void ToneFinished(TInt aError);
101 void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
102 void PlayError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
103 void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
104 void RecordError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
105 void ConvertError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
106 void DeviceMessage(TUid /*aMessageId*/, const TDesC8& /*aMsg*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
107 void SendEventToClient(const TMMFEvent& aEvent);
109 //from MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
110 virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
116 TControllerState is an enumeration within the namespace CMMFAudioToneController
117 The enumeration provides a set of control states:
118 EStopped is the initial state the controller resides in after it has been loaded
119 EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data
120 EPlaying is the state the controller is in when it is streaming data
122 enum TControllerState
132 CMMFAudioToneController();
137 // state accessor functions
138 TBool SetState( TControllerState aState );
139 TControllerState State() const ;
140 TBool IsValidStateTransition( TControllerState aState ) const;
141 TBool Invariant() const;
142 TBool IsValidState( TControllerState aState ) const ;
143 TBool ResetPostCondition() const;
145 void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const;
146 void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const;
149 void Panic(TInt aPanicCode) const {User::Panic(KMMFAudioToneControllerPanicCategory, aPanicCode);}
152 /** The data source provided by the Controller Framework, not owned (do not delete) */
153 MDataSource* iDataSource;
155 /** buffer that holds the data to be played */
156 CMMFDataBuffer* iToneSequenceData;
158 /** the Dev Sound that will be used to play the tone*/
159 CMMFDevSound* iMMFDevSound;
161 /** Current state of the controller, see TControllerState*/
162 TControllerState iState;
164 /** Priority setting used to controll access the Dev Sound*/
165 TMMFPrioritySettings iPrioritySettings;
167 /** Indicates whether both a surce and data sink have been supplied by the Controller Framework*/
168 TBool iSourceAndSinkAdded;
170 /** Indicates whether DevSound supports resume for current configuration*/
171 TBool iIsResumeSupported;
173 /** Used to store message */
174 TMMFMessage* iMessage;