sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef MMFCLIENTAUDIOOUTPUTSTREAM_H
|
sl@0
|
17 |
#define MMFCLIENTAUDIOOUTPUTSTREAM_H
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <mmf/server/sounddevice.h>
|
sl@0
|
20 |
#include <mmf/common/mmfstandardcustomcommands.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
template<class T>
|
sl@0
|
23 |
class CMMFFifo;
|
sl@0
|
24 |
class CMMFBuffer;
|
sl@0
|
25 |
class MMdaAudioOutputStreamCallback;
|
sl@0
|
26 |
class TMdaPackage;
|
sl@0
|
27 |
class MMMFAudioResourceNotificationCallback;
|
sl@0
|
28 |
|
sl@0
|
29 |
class CMMFMdaAudioOutputStream;
|
sl@0
|
30 |
NONSHARABLE_CLASS( CMMFMdaAudioOutputStream ): public CBase,
|
sl@0
|
31 |
public MDevSoundObserver
|
sl@0
|
32 |
{
|
sl@0
|
33 |
enum TIsOpenState
|
sl@0
|
34 |
{
|
sl@0
|
35 |
EIsNotOpen,
|
sl@0
|
36 |
EIsOpening, // Open() called but not responded to
|
sl@0
|
37 |
EIsOpen, // Open callback made and successfully opened
|
sl@0
|
38 |
};
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback);
|
sl@0
|
41 |
static CMMFMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallback, TInt aPriority, TInt aPref);
|
sl@0
|
42 |
virtual ~CMMFMdaAudioOutputStream();
|
sl@0
|
43 |
//
|
sl@0
|
44 |
void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
|
sl@0
|
45 |
void Open(TMdaPackage* aSettings);
|
sl@0
|
46 |
void SetVolume(const TInt aVolume);
|
sl@0
|
47 |
TInt Volume();
|
sl@0
|
48 |
TInt MaxVolume();
|
sl@0
|
49 |
void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
|
sl@0
|
50 |
TInt GetBalanceL() const;
|
sl@0
|
51 |
void SetPriority(TInt aPriority, TInt aPref);
|
sl@0
|
52 |
void WriteL(const TDesC8& aData);
|
sl@0
|
53 |
void Stop();
|
sl@0
|
54 |
TInt Pause();
|
sl@0
|
55 |
TInt Resume();
|
sl@0
|
56 |
const TTimeIntervalMicroSeconds& Position();
|
sl@0
|
57 |
TInt GetBytes();
|
sl@0
|
58 |
void SetDataTypeL(TFourCC aAudioType);
|
sl@0
|
59 |
TFourCC DataType() const;
|
sl@0
|
60 |
TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback,TUid aNotificationEventUid,const TDesC8& aNotificationRegistrationData = KNullDesC8);
|
sl@0
|
61 |
TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
|
sl@0
|
62 |
TInt WillResumePlay();
|
sl@0
|
63 |
TAny* CustomInterface(TUid aInterfaceId);
|
sl@0
|
64 |
TInt KeepOpenAtEnd();
|
sl@0
|
65 |
TInt RequestStop();
|
sl@0
|
66 |
public:
|
sl@0
|
67 |
// from MDevSoundObserver
|
sl@0
|
68 |
virtual void InitializeComplete(TInt aError);
|
sl@0
|
69 |
virtual void ToneFinished(TInt aError);
|
sl@0
|
70 |
virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
|
sl@0
|
71 |
virtual void PlayError(TInt aError);
|
sl@0
|
72 |
virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
|
sl@0
|
73 |
virtual void RecordError(TInt aError);
|
sl@0
|
74 |
virtual void ConvertError(TInt aError);
|
sl@0
|
75 |
virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
|
sl@0
|
76 |
virtual void SendEventToClient(const TMMFEvent& aEvent);
|
sl@0
|
77 |
|
sl@0
|
78 |
private:
|
sl@0
|
79 |
void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
|
sl@0
|
80 |
|
sl@0
|
81 |
private:
|
sl@0
|
82 |
// class to allow asynchronous user callbacks
|
sl@0
|
83 |
class CActiveCallback : public CActive
|
sl@0
|
84 |
{
|
sl@0
|
85 |
public:
|
sl@0
|
86 |
~CActiveCallback();
|
sl@0
|
87 |
CActiveCallback(MMdaAudioOutputStreamCallback& aCallback);
|
sl@0
|
88 |
void Signal(const TInt aReason);
|
sl@0
|
89 |
protected:
|
sl@0
|
90 |
virtual void RunL();
|
sl@0
|
91 |
virtual void DoCancel();
|
sl@0
|
92 |
private:
|
sl@0
|
93 |
MMdaAudioOutputStreamCallback& iCallback;
|
sl@0
|
94 |
};
|
sl@0
|
95 |
private:
|
sl@0
|
96 |
CMMFMdaAudioOutputStream(MMdaAudioOutputStreamCallback& aCallback);
|
sl@0
|
97 |
void ConstructL(TInt aPriority, TInt aPref);
|
sl@0
|
98 |
void StartPlayL();
|
sl@0
|
99 |
enum TState { EStopped, EPlaying, EStopping, EPaused};
|
sl@0
|
100 |
void EmptyFifo(TInt aError);
|
sl@0
|
101 |
void StartShutDownTimer();
|
sl@0
|
102 |
static TInt ShutDownTimerComplete(TAny* aSamplesPlayed);
|
sl@0
|
103 |
void DoShutDownTimerComplete();
|
sl@0
|
104 |
private:
|
sl@0
|
105 |
MMdaAudioOutputStreamCallback& iCallback;
|
sl@0
|
106 |
MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
|
sl@0
|
107 |
CMMFFifo<const TDesC8>* iFifo;
|
sl@0
|
108 |
TInt iFifoItemPos;
|
sl@0
|
109 |
CMMFDevSound* iDevSound;
|
sl@0
|
110 |
TState iState;
|
sl@0
|
111 |
TTimeIntervalMicroSeconds iPosition;
|
sl@0
|
112 |
CActiveCallback* iActiveCallback;
|
sl@0
|
113 |
TUid iEventHolder;
|
sl@0
|
114 |
TBuf8<256> iNotificationDataHolder;
|
sl@0
|
115 |
// only for testing
|
sl@0
|
116 |
friend class CTestStepUnitMMFAudClient;
|
sl@0
|
117 |
CMMFBuffer* iBuffer;
|
sl@0
|
118 |
TFourCC iDataTypeCode;
|
sl@0
|
119 |
TIsOpenState iIsOpenState;
|
sl@0
|
120 |
TBool iValuesCached;
|
sl@0
|
121 |
TInt iSampleRate;
|
sl@0
|
122 |
TInt iChannels;
|
sl@0
|
123 |
TInt iVolume;
|
sl@0
|
124 |
TBool iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
|
sl@0
|
125 |
TInt iInitializeState;
|
sl@0
|
126 |
CActiveSchedulerWait* iActiveSchedulerWait;
|
sl@0
|
127 |
TBool iKeepOpenAtEnd;
|
sl@0
|
128 |
CPeriodic* iShutDownTimer;
|
sl@0
|
129 |
TInt iCurrentSamplesPlayed;
|
sl@0
|
130 |
TBool iDevSoundIgnoresUnderflow;
|
sl@0
|
131 |
};
|
sl@0
|
132 |
|
sl@0
|
133 |
#endif
|