1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/devsoundrefplugin/src/controller/audio/MmfAudioToneController.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,178 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MMF_AUDIOTONECONTROLLER_H__
1.20 +#define __MMF_AUDIOTONECONTROLLER_H__
1.21 +
1.22 +// Standard EPOC32 includes required by this header file
1.23 +#include <e32base.h>
1.24 +#include <e32std.h>
1.25 +#include <ecom/implementationproxy.h>
1.26 +
1.27 +// Public Media Server includes
1.28 +#include <mmf/common/mmfcontroller.h>
1.29 +#include <mmf/server/mmfdatasink.h>
1.30 +#include <mmf/server/mmfdatasource.h>
1.31 +
1.32 +#include <mmf/common/mmfstandardcustomcommands.h>
1.33 +#include <mmf/server/sounddevice.h>
1.34 +
1.35 +
1.36 +/**
1.37 +Panic category and codes for the Audio Tone Controller
1.38 +@internalTechnology
1.39 +*/
1.40 +_LIT(KMMFAudioToneControllerPanicCategory, "MMFAudioToneController");
1.41 +enum TMMFMdaAudioToneControllerPanicCodes
1.42 + {
1.43 + EMMFMdaAudioToneControllerAlreadyPrepared,
1.44 + EMMFMdaAudioToneControllerBadToneConfig,
1.45 + EMMFMdaAudioToneControllerBadMixinCall
1.46 + };
1.47 +
1.48 +/**
1.49 +The public API for clients of the MMFAudioToneController
1.50 +@internalTechnology
1.51 +*/
1.52 +
1.53 +class CMMFAudioToneController : public CMMFController,
1.54 + public MMMFAudioPlayDeviceCustomCommandImplementor,
1.55 + public MMMFAudioPlayControllerCustomCommandImplementor,
1.56 + public MDevSoundObserver,
1.57 + public MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
1.58 + {
1.59 +public:
1.60 + static CMMFController* NewL();
1.61 + virtual ~CMMFAudioToneController();
1.62 +
1.63 + //implement CMMFController ecom plugin interface
1.64 + virtual void AddDataSourceL(MDataSource& aDataSource);
1.65 + virtual void AddDataSinkL(MDataSink& aDataSink);
1.66 + virtual void RemoveDataSourceL(MDataSource& aDataSource);
1.67 + virtual void RemoveDataSinkL(MDataSink& aDataSink);
1.68 +
1.69 + virtual void ResetL();
1.70 + virtual void PrimeL();
1.71 + virtual void PrimeL(TMMFMessage& aMessage);
1.72 + virtual void PlayL();
1.73 + virtual void PauseL();
1.74 + virtual void StopL();
1.75 +
1.76 + virtual TTimeIntervalMicroSeconds PositionL() const {User::Leave(KErrNotSupported); TTimeIntervalMicroSeconds zero(0); return zero;}
1.77 + virtual void SetPositionL(const TTimeIntervalMicroSeconds& /*aPosition*/){}
1.78 + virtual TTimeIntervalMicroSeconds DurationL() const {TTimeIntervalMicroSeconds zero(0); return zero;}
1.79 + virtual void CustomCommand(TMMFMessage& aMessage);
1.80 +
1.81 + virtual void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
1.82 +
1.83 + virtual void GetNumberOfMetaDataEntriesL(TInt& /*aNumberOfEntries*/){User::Leave(KErrNotSupported);}
1.84 + virtual CMMFMetaDataEntry* GetMetaDataEntryL(TInt /*aIndex*/){User::Leave(KErrNotSupported); return NULL;}
1.85 +
1.86 + //from MMMFAudioPlayDeviceCustomCommandImplementor
1.87 + virtual void MapdSetVolumeL(TInt aVolume);
1.88 + virtual void MapdGetMaxVolumeL(TInt& aMaxVolume);
1.89 + virtual void MapdGetVolumeL(TInt& aVolume);
1.90 + virtual void MapdSetVolumeRampL(const TTimeIntervalMicroSeconds& aRampDuration);
1.91 + virtual void MapdSetBalanceL(TInt aBalance);
1.92 + virtual void MapdGetBalanceL(TInt& aBalance);
1.93 +
1.94 + //from MMMFAudioPlayControllerCustomCommandImplementor
1.95 + virtual void MapcSetPlaybackWindowL(const TTimeIntervalMicroSeconds& /*aStart*/, const TTimeIntervalMicroSeconds& /*aEnd*/) {User::Leave(KErrNotSupported);}
1.96 + virtual void MapcDeletePlaybackWindowL() {User::Leave(KErrNotSupported);}
1.97 + virtual void MapcGetLoadingProgressL(TInt& /*aPercentageComplete*/) {User::Leave(KErrNotSupported);}
1.98 +
1.99 +
1.100 +
1.101 + // From DevSoundObserver
1.102 + void InitializeComplete(TInt aError);
1.103 + void ToneFinished(TInt aError);
1.104 + void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.105 + void PlayError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.106 + void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.107 + void RecordError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.108 + void ConvertError(TInt /*aError*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.109 + void DeviceMessage(TUid /*aMessageId*/, const TDesC8& /*aMsg*/) {Panic(EMMFMdaAudioToneControllerBadMixinCall);}
1.110 + void SendEventToClient(const TMMFEvent& aEvent);
1.111 +
1.112 + //from MMMFAudioPlayControllerSetRepeatsCustomCommandImplementor
1.113 + virtual TInt MapcSetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
1.114 +
1.115 +
1.116 +public:
1.117 +
1.118 +/**
1.119 + TControllerState is an enumeration within the namespace CMMFAudioToneController
1.120 + The enumeration provides a set of control states:
1.121 + EStopped is the initial state the controller resides in after it has been loaded
1.122 + EPrimed is the state the controller is in when it has been associated with datapaths but is not streaming data
1.123 + EPlaying is the state the controller is in when it is streaming data
1.124 +*/
1.125 + enum TControllerState
1.126 + {
1.127 + EStopped,
1.128 + EPrimed,
1.129 + EPriming,
1.130 + EPausePlaying,
1.131 + EPlaying,
1.132 + };
1.133 +
1.134 +protected:
1.135 + CMMFAudioToneController();
1.136 +protected:
1.137 + void ConstructL();
1.138 + void NegotiateL();
1.139 +
1.140 + // state accessor functions
1.141 + TBool SetState( TControllerState aState );
1.142 + TControllerState State() const ;
1.143 + TBool IsValidStateTransition( TControllerState aState ) const;
1.144 + TBool Invariant() const;
1.145 + TBool IsValidState( TControllerState aState ) const ;
1.146 + TBool ResetPostCondition() const;
1.147 +
1.148 + void CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const;
1.149 + void CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const;
1.150 +
1.151 +
1.152 + void Panic(TInt aPanicCode) const {User::Panic(KMMFAudioToneControllerPanicCategory, aPanicCode);}
1.153 +
1.154 +private:
1.155 +/** The data source provided by the Controller Framework, not owned (do not delete) */
1.156 + MDataSource* iDataSource;
1.157 +
1.158 +/** buffer that holds the data to be played */
1.159 + CMMFDataBuffer* iToneSequenceData;
1.160 +
1.161 +/** the Dev Sound that will be used to play the tone*/
1.162 + CMMFDevSound* iMMFDevSound;
1.163 +
1.164 +/** Current state of the controller, see TControllerState*/
1.165 + TControllerState iState;
1.166 +
1.167 +/** Priority setting used to controll access the Dev Sound*/
1.168 + TMMFPrioritySettings iPrioritySettings;
1.169 +
1.170 +/** Indicates whether both a surce and data sink have been supplied by the Controller Framework*/
1.171 + TBool iSourceAndSinkAdded;
1.172 +
1.173 +/** Indicates whether DevSound supports resume for current configuration*/
1.174 + TBool iIsResumeSupported;
1.175 +
1.176 +/** Used to store message */
1.177 + TMMFMessage* iMessage;
1.178 + };
1.179 +
1.180 +
1.181 +#endif