os/mm/mmlibs/mmfw/src/Client/Audio/mmfclientaudiooutputstream.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Audio/mmfclientaudiooutputstream.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,133 @@
     1.4 +// Copyright (c) 2002-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 MMFCLIENTAUDIOOUTPUTSTREAM_H
    1.20 +#define MMFCLIENTAUDIOOUTPUTSTREAM_H
    1.21 +
    1.22 +#include <mmf/server/sounddevice.h>
    1.23 +#include <mmf/common/mmfstandardcustomcommands.h>
    1.24 +
    1.25 +template<class T>
    1.26 +class CMMFFifo;
    1.27 +class CMMFBuffer;
    1.28 +class MMdaAudioOutputStreamCallback;
    1.29 +class TMdaPackage;
    1.30 +class MMMFAudioResourceNotificationCallback;
    1.31 +
    1.32 +class CMMFMdaAudioOutputStream;
    1.33 +NONSHARABLE_CLASS( CMMFMdaAudioOutputStream ): public CBase,
    1.34 +								 			   public MDevSoundObserver
    1.35 +	{
    1.36 +	enum TIsOpenState
    1.37 +		{
    1.38 +		EIsNotOpen,
    1.39 +		EIsOpening,  // Open() called but not responded to
    1.40 +		EIsOpen,     // Open callback made and successfully opened
    1.41 +		};
    1.42 +public:
    1.43 +	static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback);
    1.44 +	static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback, TInt aPriority, TInt aPref);
    1.45 +	virtual ~CMMFMdaAudioOutputStream();
    1.46 +//
    1.47 +	void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
    1.48 +	void Open(TMdaPackage* aSettings);
    1.49 +	void SetVolume(const TInt aVolume);
    1.50 +	TInt Volume();
    1.51 +	TInt MaxVolume();
    1.52 +	void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
    1.53 +	TInt GetBalanceL() const;
    1.54 +	void SetPriority(TInt aPriority, TInt aPref);
    1.55 +	void WriteL(const TDesC8& aData);
    1.56 +	void Stop();
    1.57 +	TInt Pause();
    1.58 +	TInt Resume();
    1.59 +	const TTimeIntervalMicroSeconds& Position();
    1.60 +	TInt GetBytes();
    1.61 +	void SetDataTypeL(TFourCC aAudioType);
    1.62 +	TFourCC DataType() const;
    1.63 +	TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback,TUid aNotificationEventUid,const TDesC8& aNotificationRegistrationData = KNullDesC8);
    1.64 +	TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
    1.65 +	TInt WillResumePlay();
    1.66 +	TAny* CustomInterface(TUid aInterfaceId);
    1.67 +	TInt KeepOpenAtEnd();
    1.68 +	TInt RequestStop();
    1.69 +public:		
    1.70 +	// from MDevSoundObserver
    1.71 +	virtual void InitializeComplete(TInt aError);
    1.72 +	virtual void ToneFinished(TInt aError); 
    1.73 +	virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
    1.74 +	virtual void PlayError(TInt aError); 
    1.75 +	virtual void BufferToBeEmptied(CMMFBuffer* aBuffer); 
    1.76 +	virtual void RecordError(TInt aError); 
    1.77 +	virtual void ConvertError(TInt aError);
    1.78 +	virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
    1.79 +	virtual void SendEventToClient(const TMMFEvent& aEvent);
    1.80 +	
    1.81 +private:
    1.82 +	void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
    1.83 +
    1.84 +private:
    1.85 +	// class to allow asynchronous user callbacks
    1.86 +	class CActiveCallback : public CActive
    1.87 +		{
    1.88 +	public:
    1.89 +		~CActiveCallback();
    1.90 +		CActiveCallback(MMdaAudioOutputStreamCallback& aCallback);
    1.91 +		void Signal(const TInt aReason);
    1.92 +	protected:
    1.93 +		virtual void RunL();
    1.94 +		virtual void DoCancel();
    1.95 +	private:
    1.96 +		MMdaAudioOutputStreamCallback& iCallback;
    1.97 +		};
    1.98 +private:
    1.99 +	CMMFMdaAudioOutputStream(MMdaAudioOutputStreamCallback& aCallback);
   1.100 +	void ConstructL(TInt aPriority, TInt aPref);
   1.101 +	void StartPlayL();
   1.102 +	enum TState { EStopped, EPlaying, EStopping, EPaused};
   1.103 +	void EmptyFifo(TInt aError);
   1.104 +	void StartShutDownTimer();
   1.105 +	static TInt ShutDownTimerComplete(TAny* aSamplesPlayed);
   1.106 +	void DoShutDownTimerComplete();
   1.107 +private:
   1.108 +	MMdaAudioOutputStreamCallback&		iCallback;
   1.109 +	MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
   1.110 +	CMMFFifo<const TDesC8>*				iFifo;
   1.111 +	TInt								iFifoItemPos;
   1.112 +	CMMFDevSound*						iDevSound;
   1.113 +	TState								iState;
   1.114 +	TTimeIntervalMicroSeconds			iPosition;
   1.115 +	CActiveCallback*					iActiveCallback;
   1.116 +	TUid 								iEventHolder;
   1.117 +	TBuf8<256> 						iNotificationDataHolder;
   1.118 +	// only for testing
   1.119 +	friend class						CTestStepUnitMMFAudClient;
   1.120 +	CMMFBuffer*							iBuffer;
   1.121 +	TFourCC								iDataTypeCode;
   1.122 +	TIsOpenState						iIsOpenState;
   1.123 +	TBool								iValuesCached;
   1.124 +	TInt								iSampleRate;
   1.125 +	TInt								iChannels;
   1.126 +	TInt								iVolume;
   1.127 +	TBool								iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
   1.128 +	TInt								iInitializeState;
   1.129 +	CActiveSchedulerWait*				iActiveSchedulerWait;
   1.130 +	TBool								iKeepOpenAtEnd;
   1.131 +	CPeriodic*							iShutDownTimer;
   1.132 +	TInt								iCurrentSamplesPlayed;
   1.133 +	TBool 								iDevSoundIgnoresUnderflow;
   1.134 +	}; 
   1.135 +
   1.136 +#endif