Update contrib.
1 // Copyright (c) 2002-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 MMFCLIENTAUDIOOUTPUTSTREAM_H
17 #define MMFCLIENTAUDIOOUTPUTSTREAM_H
19 #include <mmf/server/sounddevice.h>
20 #include <mmf/common/mmfstandardcustomcommands.h>
25 class MMdaAudioOutputStreamCallback;
27 class MMMFAudioResourceNotificationCallback;
29 class CMMFMdaAudioOutputStream;
30 NONSHARABLE_CLASS( CMMFMdaAudioOutputStream ): public CBase,
31 public MDevSoundObserver
36 EIsOpening, // Open() called but not responded to
37 EIsOpen, // Open callback made and successfully opened
40 static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback);
41 static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback, TInt aPriority, TInt aPref);
42 virtual ~CMMFMdaAudioOutputStream();
44 void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
45 void Open(TMdaPackage* aSettings);
46 void SetVolume(const TInt aVolume);
49 void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
50 TInt GetBalanceL() const;
51 void SetPriority(TInt aPriority, TInt aPref);
52 void WriteL(const TDesC8& aData);
56 const TTimeIntervalMicroSeconds& Position();
58 void SetDataTypeL(TFourCC aAudioType);
59 TFourCC DataType() const;
60 TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback,TUid aNotificationEventUid,const TDesC8& aNotificationRegistrationData = KNullDesC8);
61 TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
62 TInt WillResumePlay();
63 TAny* CustomInterface(TUid aInterfaceId);
67 // from MDevSoundObserver
68 virtual void InitializeComplete(TInt aError);
69 virtual void ToneFinished(TInt aError);
70 virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
71 virtual void PlayError(TInt aError);
72 virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
73 virtual void RecordError(TInt aError);
74 virtual void ConvertError(TInt aError);
75 virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
76 virtual void SendEventToClient(const TMMFEvent& aEvent);
79 void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
82 // class to allow asynchronous user callbacks
83 class CActiveCallback : public CActive
87 CActiveCallback(MMdaAudioOutputStreamCallback& aCallback);
88 void Signal(const TInt aReason);
91 virtual void DoCancel();
93 MMdaAudioOutputStreamCallback& iCallback;
96 CMMFMdaAudioOutputStream(MMdaAudioOutputStreamCallback& aCallback);
97 void ConstructL(TInt aPriority, TInt aPref);
99 enum TState { EStopped, EPlaying, EStopping, EPaused};
100 void EmptyFifo(TInt aError);
101 void StartShutDownTimer();
102 static TInt ShutDownTimerComplete(TAny* aSamplesPlayed);
103 void DoShutDownTimerComplete();
105 MMdaAudioOutputStreamCallback& iCallback;
106 MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
107 CMMFFifo<const TDesC8>* iFifo;
109 CMMFDevSound* iDevSound;
111 TTimeIntervalMicroSeconds iPosition;
112 CActiveCallback* iActiveCallback;
114 TBuf8<256> iNotificationDataHolder;
116 friend class CTestStepUnitMMFAudClient;
118 TFourCC iDataTypeCode;
119 TIsOpenState iIsOpenState;
124 TBool iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
125 TInt iInitializeState;
126 CActiveSchedulerWait* iActiveSchedulerWait;
127 TBool iKeepOpenAtEnd;
128 CPeriodic* iShutDownTimer;
129 TInt iCurrentSamplesPlayed;
130 TBool iDevSoundIgnoresUnderflow;