First public contribution.
1 // Copyright (c) 2001-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 __SOUNDDEVICEBODY__H__
17 #define __SOUNDDEVICEBODY__H__
19 #include "MmfDevSoundCallbackHandler.h"
20 #include <mmf/plugin/devsoundplugin.h>
21 #include <mmf/server/mmfdevsoundcustominterfacesupport.h>
22 #include <mmf/server/mmfdevsoundcustominterface.h>
23 #include "MmfDevSoundCIMuxUtility.h"
28 * Class Name: CMMFDevSoundClientImp
30 * Reference internals for CMMFDevSound
34 class CMMFDevSoundClientImp : public CBase,
35 public MMMFDevSoundPlugin,
36 public MAudioClientThreadInfo,
37 public MAutoPauseResumeSupport,
38 public MMMFDevSoundCustomInterfaceChannel,
39 public MMMFDevSoundEmptyBuffers,
40 public MMMFDevSoundCustomInterfaceObserver,
41 public MMMFDevSoundTimePlayed
45 static CMMFDevSoundClientImp* NewL();
46 ~CMMFDevSoundClientImp();
48 // Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz.
49 void InitializeL(MDevSoundObserver& aDevSoundObserver, TMMFState aMode);
50 // Initializes with hardware device and mode (play, record, convert)
51 void InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode);
52 // Initializes with hardware device associated with specific FourCC code
53 // and desired mode (play, record, convert)
54 void InitializeL(MDevSoundObserver& aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode);
56 // Returns device capabilities
57 TMMFCapabilities Capabilities();
58 // Returns device configuration
59 TMMFCapabilities Config() const;
60 // Sets device configuration
61 void SetConfigL(const TMMFCapabilities& aCaps);
63 // Returns maximum play volume device supports
65 // Returns play volume device is configured to
67 // Sets device play volume
68 void SetVolume(TInt aVolume);
70 // Returns maximum record gain device supports
72 // Returns record gain device is configured to
74 // Sets device record gain
75 void SetGain(TInt aGain);
77 // Returns play balance
78 void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
80 void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
82 // Returns record balance
83 void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
84 // Sets record balance
85 void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
87 // Initializes audio device and start play process
89 // Initializes audio device and start record process
91 // Plays the data in the buffer
93 // Records data into buffer
95 // Stops the ongoing operation
97 // Tempororily Stops the ongoing operation
100 // Returns the Sample recorded so far
101 TInt SamplesRecorded();
102 // Returns the Sample played so far
103 TInt SamplesPlayed();
105 // Initializes device and start playing tone
106 void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
107 // Initializes device and start playing dual tone
108 void PlayDualToneL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
109 // Initializes device and start playing DTMF String
110 void PlayDTMFStringL(const TDesC& aDTMFString);
111 // Initializes device and start playing tone sequence
112 void PlayToneSequenceL(const TDesC8& aData);
113 // Initializes device and start playing fixed sequence
114 void PlayFixedSequenceL(TInt aSequenceNumber);
116 // Sets tone repeat attributes
117 void SetToneRepeats(TInt aRepeatCount,
118 const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
119 // Sets DTMF tone attributes
120 void SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
121 TTimeIntervalMicroSeconds32& aToneOffLength,
122 TTimeIntervalMicroSeconds32& aPauseLength);
123 // Sets volume ramp for playing
124 void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
125 // Sets priority settings
126 void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
128 // Provides interface for sending custom commands for the audio device
129 TAny* CustomInterface(TUid aInterfaceId);
131 // Provides interface for querying fixed sequence count
132 TInt FixedSequenceCount();
133 // Provides interface for querying fixed sequence name
134 const TDesC& FixedSequenceName(TInt aSequenceNumber);
135 // Gets the supported input datatypes
136 void GetSupportedInputDataTypesL(RArray<TFourCC>& aSupportedDataTypesconst, const TMMFPrioritySettings& aPrioritySettings) const;
137 // Gets the supported output datatypes
138 void GetSupportedOutputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const;
139 // Set the real client thread with thread Id
140 TInt SetClientThreadInfo(TThreadId aTid);
142 // Registers the client for notification
143 TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
144 //cancels the registered notification
145 TInt CancelRegisterAsClient(TUid aEventType);
146 //get the notification data to resume
147 TInt GetResourceNotificationData(TUid aEventType,TDes8& aNotificationData);
148 //if client need more than the default timeout period
149 TInt WillResumePlay();
151 // from MMMFDevSoundEmptyBuffers
152 //Empties the buffers below DevSound without causing the codec to be deleted.
155 // added to support custom command passing through DevSound
156 TInt SyncCustomCommand(TUid aUid, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam);
157 void AsyncCustomCommand(TUid aUid, TRequestStatus& aStatus, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam);
159 //from MMMFDevSoundCustomInterfaceObserver
160 void CloseCustomInterface(TInt aIndex);
162 //from MMMFDevSoundTimePlayed
163 TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
165 // So that nobody can extend
166 CMMFDevSoundClientImp();
167 // Second phase constructor
170 TInt FindCustomInterface(TUid aInterfaceId);
172 // custom interface storage
173 RArray<TMMFDevSoundCustomInterfaceData> iCustomInterfaceArray;
174 CMMFDevSoundCIMuxUtility* iMuxUtility;
176 RMMFDevSoundProxy* iDevSoundProxy;
177 MDevSoundObserver* iDevSoundObserver;
179 RMsgQueue<TMMFDevSoundQueueItem> iMsgQueue;
180 CMsgQueueHandler* iMsgQueueHandler;
183 #include "SoundDeviceBody.inl"
185 #endif // __SOUNDDEVICEBODY__H__