|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for producing audio feedback. |
|
15 * Part of: Tactile Feedback. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef C_TACTILEAUDIOPLAYER_H |
|
21 #define C_TACTILEAUDIOPLAYER_H |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <cenrepnotifyhandler.h> |
|
26 #include <mdaaudiooutputstream.h> |
|
27 #include <touchlogicalfeedback.h> |
|
28 |
|
29 #include "tactileplayer.h" |
|
30 |
|
31 |
|
32 /** |
|
33 * Class for procuding audio feedback based on logical |
|
34 * feedback type. |
|
35 * |
|
36 * @lib tactileaudioplugin.lib |
|
37 * @since S60 5.2 |
|
38 */ |
|
39 |
|
40 NONSHARABLE_CLASS( CTactileAudioPlayer ): public CTactilePlayer, |
|
41 public MCenRepNotifyHandlerCallback, |
|
42 public MMdaAudioOutputStreamCallback |
|
43 { |
|
44 public: |
|
45 /** Possible states of this player */ |
|
46 enum TTactileAudioWavState |
|
47 { |
|
48 ETactileAudioInitialising, |
|
49 ETactileAudioError, |
|
50 ETactileAudioReady, |
|
51 ETactileAudioPlaying |
|
52 }; |
|
53 |
|
54 /** |
|
55 * 2-phased constructor. |
|
56 * @param aRepository - Reference to Central Repository. |
|
57 * @return Instance of CTactileAudioPlayer. |
|
58 */ |
|
59 static CTactileAudioPlayer* NewL( CRepository& aRepository ); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CTactileAudioPlayer(); |
|
65 |
|
66 private: // from base class CTactilePlayer |
|
67 /** |
|
68 * @see CTactilePlayer. |
|
69 */ |
|
70 TInt PlayFeedback( TTouchLogicalFeedback aFeedback ); |
|
71 |
|
72 /** |
|
73 * @see CTactilePlayer. |
|
74 */ |
|
75 TInt PlayPreviewFeedback( TInt aLevel, TTouchLogicalFeedback aFeedback ); |
|
76 |
|
77 private: // From MMdaAudioOutputStreamCallback. |
|
78 |
|
79 /** |
|
80 * @see MMdaAudioOutputStreamCallback. |
|
81 */ |
|
82 void MaoscOpenComplete( TInt aError ); |
|
83 |
|
84 /** |
|
85 * @see MMdaAudioOutputStreamCallback. |
|
86 */ |
|
87 void MaoscBufferCopied( TInt aError, const TDesC8 &aBuffer ); |
|
88 |
|
89 /** |
|
90 * @see MMdaAudioOutputStreamCallback. |
|
91 */ |
|
92 void MaoscPlayComplete( TInt aError ); |
|
93 |
|
94 private: // From MCenRepNotifyHandlerCallback. |
|
95 |
|
96 /** |
|
97 * @see MCenRepNotifyHandlerCallback. |
|
98 */ |
|
99 void HandleNotifyInt( TUint32 aId, TInt aNewValue ); |
|
100 |
|
101 private: |
|
102 /** |
|
103 * Read new settings values. |
|
104 */ |
|
105 void ReadSettingsL(); |
|
106 |
|
107 /** |
|
108 * Scale volume. |
|
109 */ |
|
110 TInt ScaledVolume(); |
|
111 |
|
112 /** |
|
113 * Creation of the actual player is handled inside this function. It |
|
114 * it assumed that current settings have been read to members |
|
115 * iFileName and iVolumeLevels before calling this function. |
|
116 */ |
|
117 void CreateWavPlayerL(); |
|
118 |
|
119 /** |
|
120 * Read audio sample. |
|
121 */ |
|
122 void ReadSampleL( RFile& aFile, HBufC8*& aDes, TUint& aChannels, TUint& aSampleRate ); |
|
123 |
|
124 private: |
|
125 /** |
|
126 * Constructor. |
|
127 */ |
|
128 CTactileAudioPlayer( CRepository& aRepository ); |
|
129 |
|
130 /** |
|
131 * 2nd phase constructor. |
|
132 */ |
|
133 void ConstructL(); |
|
134 |
|
135 |
|
136 private: // data |
|
137 |
|
138 /** |
|
139 * Descriptor for wav file used for basic feedback. |
|
140 * Own. |
|
141 */ |
|
142 HBufC8* iBasicSample; |
|
143 |
|
144 /** |
|
145 * Descriptor for wav file used for sensitive feedback. |
|
146 * Own. |
|
147 */ |
|
148 HBufC8* iSensitiveSample; |
|
149 |
|
150 /** |
|
151 * Maximum raw volume value supported by audio hardware |
|
152 * interface. Stored to member variable to avoid MMFAudioClient:2 |
|
153 * panic. Possibly even increases performance, if ever so slightly. |
|
154 */ |
|
155 TInt iMaxRawVolume; |
|
156 |
|
157 /** |
|
158 * Audio channels. |
|
159 */ |
|
160 TUint iChannels; |
|
161 |
|
162 /** |
|
163 * Audio sample rate.. |
|
164 */ |
|
165 TUint iSampleRate; |
|
166 |
|
167 /** |
|
168 * Current state of this class |
|
169 */ |
|
170 TTactileAudioWavState iState; |
|
171 |
|
172 /** |
|
173 * Access to audio player utility |
|
174 * Own. |
|
175 */ |
|
176 CMdaAudioOutputStream* iAudioPlayer; |
|
177 |
|
178 /** |
|
179 * Name of the .wav -file to be used as sensitive effect |
|
180 * Own. |
|
181 */ |
|
182 HBufC* iSensitiveFileName; |
|
183 |
|
184 /** |
|
185 * Name of the .wav -file to be used as basic effect |
|
186 * Own. |
|
187 */ |
|
188 HBufC* iBasicFileName; |
|
189 |
|
190 /** |
|
191 * Current volume level |
|
192 */ |
|
193 TInt iCurrentVolume; |
|
194 |
|
195 /** |
|
196 * Original volume is saved here in preview playing. |
|
197 */ |
|
198 TInt iOriginalVolume; |
|
199 |
|
200 /** |
|
201 * Volume levels for different logical feedbacks. |
|
202 */ |
|
203 RArray<TInt> iVolumeLevels; |
|
204 |
|
205 /** |
|
206 * Access to settings. |
|
207 * Not own. |
|
208 */ |
|
209 CRepository& iRepository; |
|
210 |
|
211 /** |
|
212 * Utility for listening to changes in configurable parameters. |
|
213 * Own. |
|
214 */ |
|
215 CCenRepNotifyHandler* iCenRepNotifier; |
|
216 |
|
217 }; |
|
218 |
|
219 |
|
220 #endif // C_TACTILEAUDIOPLAYER_H |