|
1 /* |
|
2 * Copyright (c) 2006 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: The functions in this class implements the behavior that is |
|
15 * specific to the interface with DevSound. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "DevSoundAudioOutput.h" |
|
22 #include "DebugMacros.h" |
|
23 #include <mmfpaniccodes.h> |
|
24 #include <ConfigurationComponentsFactory.h> |
|
25 #include <AudioOutputControlUtility.h> |
|
26 |
|
27 // CONSTANTS |
|
28 const TUint KSampleRate8000Hz = 8000; |
|
29 const TUint KSampleRate11025Hz = 11025; |
|
30 const TUint KSampleRate12000Hz = 12000; |
|
31 const TUint KSampleRate16000Hz = 16000; |
|
32 const TUint KSampleRate22050Hz = 22050; |
|
33 const TUint KSampleRate24000Hz = 24000; |
|
34 const TUint KSampleRate32000Hz = 32000; |
|
35 const TUint KSampleRate44100Hz = 44100; |
|
36 const TUint KSampleRate48000Hz = 48000; |
|
37 const TUint KSampleRate64000Hz = 64000; |
|
38 const TUint KSampleRate88200Hz = 88200; |
|
39 const TUint KSampleRate96000Hz = 96000; |
|
40 |
|
41 const TUint KNumChannelsMono = 1; |
|
42 const TUint KNumChannelsStereo = 2; |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CDevSoundAudioOutput::CDevSoundAudioOutput |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CDevSoundAudioOutput::CDevSoundAudioOutput(CMMFDevSound& aMMFDevSound) |
|
51 : iMMFDevSound(aMMFDevSound), |
|
52 iLoopPlayEnabled(EFalse), |
|
53 iIgnoreBTBFDuringLoopPlay(EFalse), |
|
54 iUnSetLastBuffer(EFalse), |
|
55 iDSStopped(ETrue), |
|
56 iLastBufferSentToDevSound(EFalse) |
|
57 { |
|
58 iAdvancedAudioDecoder = NULL; |
|
59 iDataSourceAdapter = NULL; |
|
60 iFactory = NULL; |
|
61 iAudioOutputControlUtility = NULL; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CDevSoundAudioOutput::ConstructL |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CDevSoundAudioOutput::ConstructL( |
|
69 const TMMFPrioritySettings& aPrioritySettings, |
|
70 MAdvancedAudioOutputObserver& aObserver) |
|
71 { |
|
72 DP0(_L("CDevSoundAudioOutput::ConstructL")); |
|
73 |
|
74 iPrioritySettings = aPrioritySettings; |
|
75 iObserver = &aObserver; |
|
76 |
|
77 iState = EIdle; |
|
78 |
|
79 //This is done to maintain compatibility with the media server |
|
80 iMMFDevSound.SetVolume (iMMFDevSound.MaxVolume() - 1); |
|
81 |
|
82 //We need to set PrioritySettings |
|
83 iMMFDevSound.SetPrioritySettings(iPrioritySettings); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CDevSoundAudioOutput::NewL |
|
88 // Static function for creating an instance of the DevSound Audio Output |
|
89 // object. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C CDevSoundAudioOutput* CDevSoundAudioOutput::NewL( |
|
93 const TMMFPrioritySettings& aPrioritySettings, |
|
94 MAdvancedAudioOutputObserver& aObserver, |
|
95 CMMFDevSound& aMMFDevSound) |
|
96 { |
|
97 DP0(_L("CDevSoundAudioOutput::NewL")); |
|
98 CDevSoundAudioOutput* self = new (ELeave) CDevSoundAudioOutput(aMMFDevSound); |
|
99 CleanupStack::PushL(self); |
|
100 self->ConstructL(aPrioritySettings, aObserver); |
|
101 CleanupStack::Pop(self); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // Destructor |
|
106 EXPORT_C CDevSoundAudioOutput::~CDevSoundAudioOutput() |
|
107 { |
|
108 DP0(_L("CDevSoundAudioOutput::~CDevSoundAudioOutput")); |
|
109 |
|
110 iCodecConfigData.Close(); |
|
111 delete iAdvancedAudioDecoder; |
|
112 |
|
113 iMMFDevSound.Stop(); |
|
114 |
|
115 iDataSourceAdapter = NULL; |
|
116 if(iAudioOutputControlUtility) |
|
117 delete iAudioOutputControlUtility; |
|
118 if(iFactory) |
|
119 delete iFactory; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CDevSoundAudioOutput::PrimeL |
|
124 // Prepare to start playing, building configuration parameters and initializing DevSound. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CDevSoundAudioOutput::PrimeL() |
|
128 { |
|
129 DP0(_L("CDevSoundAudioOutput::PrimeL start")); |
|
130 if (!iAdvancedAudioDecoder) |
|
131 { |
|
132 // SetDecoder hasn't been called!!! |
|
133 User::Leave(KErrNotReady); |
|
134 } |
|
135 |
|
136 // Devsound will be initialized only once for the given data source. |
|
137 // The current datasource would need to be removed, which would delete this audiooutput, |
|
138 // and another datasource added, which will create this audiooutput with |
|
139 // iDevSoundInitialized clear, which would allow devsound to be initialized. |
|
140 // This check is to prevent devsound from being initialized again in the case where |
|
141 // the same file is played from the beginning and the datasink is reinitialized |
|
142 // after the header is read and this output is primed. |
|
143 // |
|
144 // If we want to initialize devsound again for the same source, we can remove |
|
145 // the condition of !iDevSoundInitialized, but we need to set it EFalse before calling |
|
146 // InitializeL. We would also need to make a check in our own DoPlayL function |
|
147 // to see if devsound is being initialized like we do in PlayL in the controller. |
|
148 |
|
149 // iDevSoundInitialized = EFalse; |
|
150 if (!iDevSoundInitialized) |
|
151 { |
|
152 DP0(_L("CDevSoundAudioOutput::PrimeL initializing DevSound")); |
|
153 if(iAdvancedAudioDecoder->IsHwAccelerated()) |
|
154 { |
|
155 iMMFDevSound.InitializeL(*this, iSourceFourCC, EMMFStatePlaying); |
|
156 } |
|
157 else |
|
158 { |
|
159 iMMFDevSound.InitializeL(*this, KMMFFourCCCodePCM16, EMMFStatePlaying); |
|
160 } |
|
161 } |
|
162 // iDevSoundInitialized = EFalse; |
|
163 DP0(_L("CDevSoundAudioOutput::PrimeL end")); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CDevSoundAudioOutput::PauseL |
|
168 // Send pause command to DevSound pause and set own state to paused |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C void CDevSoundAudioOutput::PauseL() |
|
172 { |
|
173 DP0(_L("CDevSoundAudioOutput::PauseL")); |
|
174 iState = EPaused; |
|
175 iMMFDevSound.Pause(); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CDevSoundAudioOutput::PlayL |
|
180 // Start playback process by configuring the codec and initialize play on DevSound. |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C void CDevSoundAudioOutput::PlayL( |
|
184 TAny* aBuffer, TInt aIndex) |
|
185 { |
|
186 DP0(_L("CDevSoundAudioOutput::PlayL")); |
|
187 |
|
188 if (iDevSoundInitialized) |
|
189 { |
|
190 // Set the flag to EFalse for processing the data for playback. |
|
191 iIgnoreBTBFDuringLoopPlay = EFalse; |
|
192 // start play only after we get the initialize complete |
|
193 DoPlayL(aBuffer,aIndex); |
|
194 } |
|
195 else |
|
196 { |
|
197 DP0(_L("CDevSoundAudioOutput::PlayL pending")); |
|
198 iState = EPlayPending; |
|
199 iBufferIndex = aIndex; |
|
200 iPlayPendingBuffer = aBuffer; |
|
201 } |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CDevSoundAudioOutput::PlayL |
|
206 // Start playback process by configuring the codec and initialize play on DevSound. |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CDevSoundAudioOutput::DoPlayL( |
|
210 TAny* aBuffer, TInt aIndex) |
|
211 { |
|
212 DP0(_L("CDevSoundAudioOutput::DoPlayL")); |
|
213 |
|
214 // Give the audio converter a handle to the source buffers |
|
215 iAdvancedAudioDecoder->SetSourceBuffers(reinterpret_cast<RPointerArray<CMMFDataBuffer>*>(aBuffer)); |
|
216 // Reset the converter |
|
217 iAdvancedAudioDecoder->ResetL(); |
|
218 // Configure the audio converter |
|
219 iAdvancedAudioDecoder->SetConfigL(iSourceSampleRate, iSourceChannels, iSWConvertSampleRate, |
|
220 iSWConvertChannels, iCodecConfigData, aIndex); |
|
221 |
|
222 // Configure DevSound |
|
223 // Can devsound capabilities change between pause and play? May not be necessary to |
|
224 // do this multiple times. |
|
225 iMMFDevSound.SetConfigL(iDevSoundConfig); |
|
226 DP1(_L("CDevSoundAudioOutput::DoPlayL config DS sample rate[%d]"), iDevSoundConfig.iRate ); |
|
227 iState = EPlaying; |
|
228 iDSStopped = EFalse; |
|
229 |
|
230 if ( (iDataSourceAdapter != NULL) && (iDataSourceAdapter->IsProtectedL()) ) |
|
231 { |
|
232 if (iAudioOutputControlUtility) |
|
233 iAudioOutputControlUtility->Configure(iMMFDevSound); //ignoring errors since rouitng changes are only suggestions to adaptation |
|
234 } |
|
235 |
|
236 iMMFDevSound.PlayInitL(); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CDevSoundAudioOutput::BuildConfigurationParametersL |
|
241 // Build a configuration profile based on DevSound capabilities |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CDevSoundAudioOutput::BuildConfigurationParametersL() |
|
245 { |
|
246 // Query DevSound capabilities and Try to use DevSound sample rate and |
|
247 // mono/stereo capability |
|
248 |
|
249 // Reset the following flag in case DevSound's capabilities have |
|
250 // changed since we were last here: |
|
251 iNeedsSWConversion = EFalse; |
|
252 iSWConvertSampleRate = iSourceSampleRate; |
|
253 TMMFCapabilities devSoundCaps = iMMFDevSound.Capabilities(); |
|
254 |
|
255 DP4(_L("CDevSoundAudioOutput::BuildConfigurationParametersL [%d] [%d] [%d] [%d]"), |
|
256 iSourceSampleRate, iSourceChannels, devSoundCaps.iRate, devSoundCaps.iChannels); |
|
257 |
|
258 // Default PCM16 |
|
259 iDevSoundConfig.iEncoding = EMMFSoundEncoding16BitPCM; |
|
260 // 1 = Monophonic and 2 == Stereo |
|
261 if (((iSourceChannels == 1) && (devSoundCaps.iChannels & EMMFMono)) || |
|
262 ((iSourceChannels == 2) && (devSoundCaps.iChannels & EMMFStereo))) |
|
263 { |
|
264 iDevSoundConfig.iChannels = iSourceChannels; |
|
265 } |
|
266 else //default or SW conversion, e.g. stereo on mono support |
|
267 { |
|
268 iDevSoundConfig.iChannels = EMMFMono; |
|
269 iNeedsSWConversion = ETrue; |
|
270 iSWConvertChannels = 1; |
|
271 } |
|
272 |
|
273 // Check for std sample rates. |
|
274 if ((iSourceSampleRate == 96000) && (devSoundCaps.iRate & EMMFSampleRate96000Hz)) |
|
275 iDevSoundConfig.iRate = EMMFSampleRate96000Hz; |
|
276 else if ((iSourceSampleRate == 88200) && (devSoundCaps.iRate & EMMFSampleRate88200Hz)) |
|
277 iDevSoundConfig.iRate = EMMFSampleRate88200Hz; |
|
278 else if ((iSourceSampleRate == 48000) && (devSoundCaps.iRate & EMMFSampleRate48000Hz)) |
|
279 iDevSoundConfig.iRate = EMMFSampleRate48000Hz; |
|
280 else if ((iSourceSampleRate == 44100) && (devSoundCaps.iRate & EMMFSampleRate44100Hz)) |
|
281 iDevSoundConfig.iRate = EMMFSampleRate44100Hz; |
|
282 else if ((iSourceSampleRate == 32000) && (devSoundCaps.iRate & EMMFSampleRate32000Hz)) |
|
283 iDevSoundConfig.iRate = EMMFSampleRate32000Hz; |
|
284 else if ((iSourceSampleRate == 24000) && (devSoundCaps.iRate & EMMFSampleRate24000Hz)) |
|
285 iDevSoundConfig.iRate = EMMFSampleRate24000Hz; |
|
286 else if ((iSourceSampleRate == 22050) && (devSoundCaps.iRate & EMMFSampleRate22050Hz)) |
|
287 iDevSoundConfig.iRate = EMMFSampleRate22050Hz; |
|
288 else if ((iSourceSampleRate == 16000) && (devSoundCaps.iRate & EMMFSampleRate16000Hz)) |
|
289 iDevSoundConfig.iRate = EMMFSampleRate16000Hz; |
|
290 else if ((iSourceSampleRate == 12000) && (devSoundCaps.iRate & EMMFSampleRate12000Hz)) |
|
291 iDevSoundConfig.iRate = EMMFSampleRate12000Hz; |
|
292 else if ((iSourceSampleRate == 11025) && (devSoundCaps.iRate & EMMFSampleRate11025Hz)) |
|
293 iDevSoundConfig.iRate = EMMFSampleRate11025Hz; |
|
294 else if ((iSourceSampleRate == 8000) && (devSoundCaps.iRate & EMMFSampleRate8000Hz)) |
|
295 iDevSoundConfig.iRate = EMMFSampleRate8000Hz; |
|
296 else // non standard sample rate |
|
297 { |
|
298 iNeedsSWConversion = ETrue; |
|
299 // we need to choose to the closest, and smaller standard sample rate |
|
300 // and eventually convert the audio samples to this standard sample rate |
|
301 // NB: this list must be in ascending order |
|
302 const TInt KNumSampleRates = 11; |
|
303 TUint supportedSR[KNumSampleRates][2] = {{8000, EMMFSampleRate8000Hz}, |
|
304 {11025, EMMFSampleRate11025Hz}, |
|
305 {12000, EMMFSampleRate12000Hz}, |
|
306 {16000, EMMFSampleRate16000Hz}, |
|
307 {22050, EMMFSampleRate22050Hz}, |
|
308 {24000, EMMFSampleRate24000Hz}, |
|
309 {32000, EMMFSampleRate32000Hz}, |
|
310 {44100, EMMFSampleRate44100Hz}, |
|
311 {48000, EMMFSampleRate48000Hz}, |
|
312 {88200, EMMFSampleRate88200Hz}, |
|
313 {96000, EMMFSampleRate96000Hz}}; |
|
314 |
|
315 // Only support down sampling |
|
316 if (iSourceSampleRate < supportedSR[0][0]) |
|
317 { |
|
318 User::Leave(KErrNotSupported); |
|
319 } |
|
320 |
|
321 TInt sampleRateIndex = KNumSampleRates - 1; |
|
322 |
|
323 // find the source sampleRateIndex |
|
324 for (; sampleRateIndex >= 0; sampleRateIndex--) |
|
325 { |
|
326 if(iSourceSampleRate >= supportedSR[sampleRateIndex][0]) |
|
327 { |
|
328 break; |
|
329 } |
|
330 } |
|
331 |
|
332 // find the highest sink sample rate below the source rate |
|
333 for (; sampleRateIndex >= 0; sampleRateIndex--) |
|
334 { |
|
335 if(devSoundCaps.iRate & supportedSR[sampleRateIndex][1]) |
|
336 { |
|
337 iSWConvertSampleRate = supportedSR[sampleRateIndex][0]; |
|
338 iDevSoundConfig.iRate = supportedSR[sampleRateIndex][1]; |
|
339 break; |
|
340 } |
|
341 } |
|
342 |
|
343 // if a suitable sink sample rate is not available |
|
344 if (sampleRateIndex < 0) |
|
345 { |
|
346 User::Leave(KErrNotSupported); |
|
347 } |
|
348 |
|
349 // set the channels as well |
|
350 iSWConvertChannels = iDevSoundConfig.iChannels; |
|
351 } // else // non standard sample rate |
|
352 |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CDevSoundAudioOutput::StopL |
|
357 // Send stop command to DevSound |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 EXPORT_C void CDevSoundAudioOutput::StopL(TBool aStopDevsound) |
|
361 { |
|
362 DP2(_L("CDevSoundAudioOutput::StopL state[%d] condition[%d]"), iState, aStopDevsound); |
|
363 |
|
364 if (iState != EIdle) |
|
365 { |
|
366 iAdvancedAudioDecoder->Stop(); // stop the decoder before devound |
|
367 if (aStopDevsound) |
|
368 { |
|
369 DP0(_L("CDevSoundAudioOutput::StopL calling iMMFDevSound.Stop()")); |
|
370 iDSStopped = ETrue; |
|
371 iMMFDevSound.Stop(); // devsound buffers become invalid here |
|
372 } |
|
373 iState = EIdle; |
|
374 } |
|
375 else |
|
376 { // EIdle state |
|
377 if (aStopDevsound || iLastBufferSentToDevSound) |
|
378 { // for play error / playcomplete if resume not supported and paused in loop play (devsound not stopped) |
|
379 DP0(_L("CDevSoundAudioOutput::StopL calling iMMFDevSound.Stop()")); |
|
380 iDSStopped = ETrue; |
|
381 iMMFDevSound.Stop(); // devsound buffers become invalid here |
|
382 } |
|
383 } |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CDevSoundAudioOutput::MaxVolumeL |
|
388 // Get maximum gain volume from DevSound |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 EXPORT_C TInt CDevSoundAudioOutput::MaxVolumeL() |
|
392 { |
|
393 return iMMFDevSound.MaxVolume(); |
|
394 } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CDevSoundAudioOutput::SetVolumeL |
|
398 // Sends given new volume value to DevSound |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 EXPORT_C void CDevSoundAudioOutput::SetVolumeL(TInt aVolume) |
|
402 { |
|
403 iMMFDevSound.SetVolume(aVolume); |
|
404 } |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CDevSoundAudioOutput::VolumeL |
|
408 // Get current volume value from DevSound |
|
409 // ----------------------------------------------------------------------------- |
|
410 // |
|
411 EXPORT_C TInt CDevSoundAudioOutput::VolumeL() |
|
412 { |
|
413 return iMMFDevSound.Volume(); |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CDevSoundAudioOutput::SetPrioritySettings |
|
418 // Send new priority settings to DevSound. Priorities are enumerated to |
|
419 // determine audio playback priority. Higher numbers mean high priority (can |
|
420 // interrupt lower priorities). |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 EXPORT_C void CDevSoundAudioOutput::SetPrioritySettingsL( |
|
424 const TMMFPrioritySettings& aPrioritySettings) |
|
425 { |
|
426 iPrioritySettings = aPrioritySettings; |
|
427 iMMFDevSound.SetPrioritySettings(iPrioritySettings); |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CDevSoundAudioOutput::CalculateAudioOutputPosition |
|
432 // Gets the current playback position in terms of microseconds. This time position |
|
433 // is from the time playback started or resumed and is reset after a stop or |
|
434 // pause. |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C TInt64 CDevSoundAudioOutput::CalculateAudioOutputPositionL() const |
|
438 { |
|
439 DP0(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition")); |
|
440 if (!iDevSoundInitialized) |
|
441 { // if devsound hasn't been initialized, we will get an error when calling Config() |
|
442 return 0; |
|
443 } |
|
444 TInt64 timePlayedInMicroSeconds = 0; |
|
445 |
|
446 if (iMMFDevSound.IsGetTimePlayedSupported()) |
|
447 { |
|
448 DP0(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition GetTimeplayed is supported by MMFDevSound")); |
|
449 TTimeIntervalMicroSeconds timePlayedInMS = 0; |
|
450 iMMFDevSound.GetTimePlayed(timePlayedInMS); |
|
451 timePlayedInMicroSeconds = timePlayedInMS.Int64(); |
|
452 } |
|
453 else |
|
454 { |
|
455 DP0(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition GetTimeplayed is not supported by MMFDevSound")); |
|
456 TInt64 samplesPlayed = iMMFDevSound.SamplesPlayed(); |
|
457 DP1(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition SamplesPlayed = %g"), I64REAL(samplesPlayed)); |
|
458 DP2(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition SamplesPlayed = [%x][%x]"), I64HIGH(samplesPlayed), I64LOW(samplesPlayed)); |
|
459 TMMFCapabilities devSoundConfig = iMMFDevSound.Config(); |
|
460 TInt samplingFreq = 0; |
|
461 DP4(_L("CDevSoundAudioOutput::CalculateAudioOutputPositionL [%d] [%d] [%d] [%d]"), |
|
462 iSourceSampleRate, iSourceChannels, devSoundConfig.iRate, devSoundConfig.iChannels); |
|
463 |
|
464 switch (devSoundConfig.iRate) |
|
465 { |
|
466 case EMMFSampleRate8000Hz: |
|
467 samplingFreq = 8000; |
|
468 break; |
|
469 case EMMFSampleRate11025Hz: |
|
470 samplingFreq = 11025; |
|
471 break; |
|
472 case EMMFSampleRate12000Hz: |
|
473 samplingFreq = 12000; |
|
474 break; |
|
475 case EMMFSampleRate16000Hz: |
|
476 samplingFreq = 16000; |
|
477 break; |
|
478 case EMMFSampleRate22050Hz: |
|
479 samplingFreq = 22050; |
|
480 break; |
|
481 case EMMFSampleRate24000Hz: |
|
482 samplingFreq = 24000; |
|
483 break; |
|
484 case EMMFSampleRate32000Hz: |
|
485 samplingFreq = 32000; |
|
486 break; |
|
487 case EMMFSampleRate44100Hz: |
|
488 samplingFreq = 44100; |
|
489 break; |
|
490 case EMMFSampleRate48000Hz: |
|
491 samplingFreq = 48000; |
|
492 break; |
|
493 case EMMFSampleRate88200Hz: |
|
494 samplingFreq = 88200; |
|
495 break; |
|
496 case EMMFSampleRate96000Hz: |
|
497 samplingFreq = 96000; |
|
498 break; |
|
499 default: |
|
500 DP0(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition DevSound Config Data Not Available")); |
|
501 //Panic(EMMFDataPathPanicBadState); |
|
502 return 0; |
|
503 } |
|
504 DP1(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition: SamplingFreq = %d"), samplingFreq); |
|
505 timePlayedInMicroSeconds = (samplesPlayed*1000000)/samplingFreq; |
|
506 } |
|
507 DP1(_L("CDevSoundAudioOutput::CalculateAudioOutputPosition: timePlayedInMicroSeconds = %g"), I64REAL(timePlayedInMicroSeconds)); |
|
508 |
|
509 return timePlayedInMicroSeconds; |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CDevSoundAudioOutput::ConfigRatesL |
|
514 // Get configured sampling rates from DevSound |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 EXPORT_C void CDevSoundAudioOutput::ConfigRatesL( |
|
518 RArray<TUint>& aRates) |
|
519 { |
|
520 ConvertFromDevSoundCapsToSampleRatesL(iMMFDevSound.Config(), aRates); |
|
521 } |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // CDevSoundAudioOutput::ConfigChannelsL |
|
525 // Get configured sampling rates from DevSound |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 EXPORT_C void CDevSoundAudioOutput::ConfigChannelsL( |
|
529 RArray<TUint>& aChannels) |
|
530 { |
|
531 ConvertFromDevSoundCapsToNumChannelsL(iMMFDevSound.Config(), aChannels); |
|
532 } |
|
533 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // CDevSoundAudioOutput::ConfigDataTypesL |
|
536 // Get configured data types (FourCC) from DevSound |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 EXPORT_C void CDevSoundAudioOutput::ConfigDataTypesL( |
|
540 RArray<TFourCC>& aDataTypes) |
|
541 { |
|
542 ConvertFromDevSoundCapsToDataTypesL(iMMFDevSound.Config(), aDataTypes); |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CDevSoundAudioOutput::CapabilitiesRatesL |
|
547 // CDevSoundAudioInput::CapabilitiesRatesL |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 EXPORT_C void CDevSoundAudioOutput::CapabilitiesRatesL( |
|
551 RArray<TUint>& aRates) |
|
552 { |
|
553 ConvertFromDevSoundCapsToSampleRatesL(iMMFDevSound.Capabilities(), aRates); |
|
554 } |
|
555 |
|
556 // ----------------------------------------------------------------------------- |
|
557 // CDevSoundAudioOutput::CapabilitiesChannelsL |
|
558 // Get DevSound capabilities for channels |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 EXPORT_C void CDevSoundAudioOutput::CapabilitiesChannelsL( |
|
562 RArray<TUint>& aChannels) |
|
563 { |
|
564 ConvertFromDevSoundCapsToNumChannelsL(iMMFDevSound.Capabilities(), aChannels); |
|
565 } |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // CDevSoundAudioOutput::CapabilitiesDataTypesL |
|
569 // Get DevSound capabilities for data types (FourCC) |
|
570 // ----------------------------------------------------------------------------- |
|
571 // |
|
572 EXPORT_C void CDevSoundAudioOutput::CapabilitiesDataTypesL( |
|
573 RArray<TFourCC>& aDataTypes) |
|
574 { |
|
575 ConvertFromDevSoundCapsToDataTypesL(iMMFDevSound.Capabilities(), aDataTypes); |
|
576 } |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // CDevSoundAudioOutput::SetVolumeRampL |
|
580 // Send new ramp duration to DevSound |
|
581 // ----------------------------------------------------------------------------- |
|
582 // |
|
583 EXPORT_C void CDevSoundAudioOutput::SetVolumeRampL( |
|
584 const TTimeIntervalMicroSeconds& aRampDuration) |
|
585 { |
|
586 iMMFDevSound.SetVolumeRamp(aRampDuration); |
|
587 } |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // CDevSoundAudioOutput::SetPlayBalanceL |
|
591 // Send new channel balance information (left and right channel) to DevSound |
|
592 // ----------------------------------------------------------------------------- |
|
593 // |
|
594 EXPORT_C void CDevSoundAudioOutput::SetPlayBalanceL( |
|
595 TInt aLeftPercentage, TInt aRightPercentage) |
|
596 { |
|
597 iMMFDevSound.SetPlayBalanceL(aLeftPercentage, aRightPercentage); |
|
598 } |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CDevSoundAudioOutput::GetPlayBalanceL |
|
602 // Get current playback channel balance information (for left and right channel) |
|
603 // from DevSound |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 EXPORT_C void CDevSoundAudioOutput::GetPlayBalanceL( |
|
607 TInt& aLeftPercentage, TInt& aRightPercentage) |
|
608 { |
|
609 iMMFDevSound.GetPlayBalanceL(aLeftPercentage, aRightPercentage); |
|
610 } |
|
611 |
|
612 // ----------------------------------------------------------------------------- |
|
613 // CDevSoundAudioOutput::ConfigureL |
|
614 // Saves configuration information to be used later to initialize DevSound and |
|
615 // configure the codec. |
|
616 // ----------------------------------------------------------------------------- |
|
617 // |
|
618 EXPORT_C void CDevSoundAudioOutput::ConfigureL( |
|
619 TUint aSampleRate, |
|
620 TUint aNumChannel, |
|
621 TFourCC aFourCC, |
|
622 const RArray<TInt>& aCodecConfigData) |
|
623 { |
|
624 DP0(_L("CDevSoundAudioOutput::ConfigureL")); |
|
625 iSourceSampleRate = aSampleRate; |
|
626 iSourceChannels = aNumChannel; |
|
627 iSourceFourCC = aFourCC; |
|
628 |
|
629 iCodecConfigData.Reset(); |
|
630 |
|
631 for (TInt i = 0; i < aCodecConfigData.Count(); i++) |
|
632 { |
|
633 //DP2(_L("Index %d [%d]"), i, aCodecConfigData[i]); |
|
634 User::LeaveIfError(iCodecConfigData.Append(aCodecConfigData[i])); |
|
635 } |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CDevSoundAudioOutput::SetDecoder |
|
640 // Sets the Decoder instance to be used by the audio output. |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 EXPORT_C void CDevSoundAudioOutput::SetDecoder( |
|
644 CAdvancedAudioDecoder* aDecoder) |
|
645 { |
|
646 DP0(_L("CDevSoundAudioOutput::SetDecoder")); |
|
647 |
|
648 // delete existing iAdvancedAudioDecoder if any |
|
649 if (iAdvancedAudioDecoder) |
|
650 { |
|
651 delete iAdvancedAudioDecoder; |
|
652 iAdvancedAudioDecoder = NULL; |
|
653 } |
|
654 |
|
655 iAdvancedAudioDecoder = aDecoder; |
|
656 |
|
657 iAdvancedAudioDecoder->SetDevSound(iMMFDevSound); |
|
658 iAdvancedAudioDecoder->SetObserver(*this); |
|
659 } |
|
660 |
|
661 EXPORT_C void CDevSoundAudioOutput::SetDataSourceAdapter(CDataSourceAdapter* aDataSourceAdapter) |
|
662 { |
|
663 DP0(_L("CDevSoundAudioOutput::SetDataSourceAdapter")); |
|
664 iDataSourceAdapter = aDataSourceAdapter; |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CDevSoundAudioOutput::Resume |
|
669 // |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 EXPORT_C void CDevSoundAudioOutput::Resume(TInt aBufferIndex) |
|
673 { |
|
674 DP2(_L("CDevSoundAudioOutput::Resume+++ iIgnoreBTBFDuringLoopPlay[%d] iState[%d]"), iIgnoreBTBFDuringLoopPlay, iState); |
|
675 if (aBufferIndex >= 0) |
|
676 { |
|
677 // get the buffer for decoding at this buffer index |
|
678 iAdvancedAudioDecoder->QueueThisBuffer(aBufferIndex); |
|
679 } |
|
680 // Reset the Decoder for resuming the codec processing during LoopPlay. |
|
681 // Decoder is disabled during every playback / pause operation in a LoopPlay |
|
682 if ((iLoopPlayEnabled) && (iState != EPlaying)) |
|
683 { |
|
684 // reset the decoder. it flushes the codec's in & out buffers and |
|
685 // enables the decoder for furhter processing when DoPlay / Resume is called |
|
686 iAdvancedAudioDecoder->ResetL(); |
|
687 } |
|
688 // Set the flag to false for resuming the playback (Processing the data in BufferToBeFilled) |
|
689 iIgnoreBTBFDuringLoopPlay = EFalse; |
|
690 // Change the state to EPlaying for resuming the playback |
|
691 iState = EPlaying; |
|
692 if (iSavedBufferPtr) |
|
693 { |
|
694 // Have the decoder fill the specified buffer with decoded audio. |
|
695 BufferToBeFilled(iSavedBufferPtr); |
|
696 } |
|
697 else |
|
698 { |
|
699 DP0(_L("CDevSoundAudioOutput::Resume ignored")); |
|
700 } |
|
701 DP2(_L("CDevSoundAudioOutput::Resume--- iIgnoreBTBFDuringLoopPlay[%d] iState[%d]"), iIgnoreBTBFDuringLoopPlay, iState); |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CDevSoundAudioOutput::InitializeComplete |
|
706 // Callback from DevSound to notify initialization has completed |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CDevSoundAudioOutput::InitializeComplete( |
|
710 TInt aError) |
|
711 { |
|
712 TInt err; |
|
713 DP2(_L("CDevSoundAudioOutput::InitializeComplete aError[%d] iState[%d]"), aError, iState); |
|
714 |
|
715 if(aError == KErrNone) |
|
716 { |
|
717 iDevSoundInitialized = ETrue; |
|
718 TRAP(err, BuildConfigurationParametersL()); |
|
719 if (err) |
|
720 { |
|
721 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError)); |
|
722 iState = EIdle; |
|
723 } |
|
724 |
|
725 if ( (iDataSourceAdapter != NULL) && (iDataSourceAdapter->IsProtectedL()) ) |
|
726 { |
|
727 TRAP(err,CConfigurationComponentsFactory::CreateFactoryL(iFactory)); |
|
728 |
|
729 if (err == KErrNone && iFactory) |
|
730 { |
|
731 TRAP(err,iFactory->CreateAudioOutputControlUtility(iAudioOutputControlUtility)); |
|
732 } |
|
733 |
|
734 if (err == KErrNone && iAudioOutputControlUtility) |
|
735 { |
|
736 TRAP(err,iDataSourceAdapter->SetAudioOutputControlUtil(iAudioOutputControlUtility)); |
|
737 } |
|
738 |
|
739 if (err) |
|
740 { |
|
741 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError)); |
|
742 iState = EIdle; |
|
743 } |
|
744 } |
|
745 |
|
746 if (iState == EPlayPending) |
|
747 { |
|
748 TRAP(err,DoPlayL(iPlayPendingBuffer,iBufferIndex)); |
|
749 if (err) |
|
750 { |
|
751 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError)); |
|
752 iState = EIdle; |
|
753 } |
|
754 } |
|
755 else |
|
756 { |
|
757 iState = EDevSoundReady; |
|
758 } |
|
759 } |
|
760 else |
|
761 { |
|
762 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError)); |
|
763 iState = EIdle; |
|
764 } |
|
765 } |
|
766 |
|
767 // ----------------------------------------------------------------------------- |
|
768 // CDevSoundAudioOutput::ToneFinished |
|
769 // ToneFinished called when a tone has finished or interrupted |
|
770 // aError == KErrNone means success |
|
771 // ----------------------------------------------------------------------------- |
|
772 // |
|
773 void CDevSoundAudioOutput::ToneFinished( |
|
774 TInt /*aError*/) |
|
775 { |
|
776 //we should never get a tone error in MMFAudioOutput! |
|
777 __ASSERT_DEBUG(EFalse, Panic(EMMFAudioOutputPanicToneFinishedNotSupported)); |
|
778 } |
|
779 |
|
780 // ----------------------------------------------------------------------------- |
|
781 // CDevSoundAudioOutput::BufferToBeFilled |
|
782 // Called when the specified buffer needs to be filled for playback. |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 void CDevSoundAudioOutput::BufferToBeFilled( |
|
786 CMMFBuffer* aBuffer) |
|
787 { |
|
788 DP1(_L("CDevSoundAudioOutput::BufferToBeFilled iIgnoreBTBFDuringLoopPlay[%d]"), iIgnoreBTBFDuringLoopPlay); |
|
789 iSavedBufferPtr = aBuffer; |
|
790 // if DevSound asks for another buffer after the LastBuffer has been sent, then we ignore those callbacks. |
|
791 if (!iIgnoreBTBFDuringLoopPlay) |
|
792 { |
|
793 // Have the decoder fill the specified buffer with decoded audio. |
|
794 TRAPD(err, iAdvancedAudioDecoder->FillBufferL(aBuffer)); |
|
795 DP1(_L("CDevSoundAudioOutput::BufferToBeFilled FillBufferL err[%d]"), err); |
|
796 if (err != KErrNone) |
|
797 { |
|
798 PlayError(err); |
|
799 } |
|
800 } |
|
801 else |
|
802 { |
|
803 DP0(_L("CDevSoundAudioOutput::BufferToBeFilled ignored")); |
|
804 } |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CDevSoundAudioOutput::PlayError |
|
809 // Callback error to indicate success or error during playback. |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 void CDevSoundAudioOutput::PlayError( |
|
813 TInt aError) |
|
814 { |
|
815 DP2(_L("CDevSoundAudioOutput::PlayError(%d) iState[%d]"), aError, iState); |
|
816 //iMMFDevSound->Stop(); doesn't need this probably since devsound should be stopped on |
|
817 // error or otherwise. Should test this and see if it can be removed. |
|
818 |
|
819 if (aError == KErrUnderflow && (iState == EIdle || iState == EPreIdle)) |
|
820 { |
|
821 iObserver->PlaybackComplete(); |
|
822 iAdvancedAudioDecoder->RenderEnable(); |
|
823 } |
|
824 else |
|
825 { |
|
826 if (aError == KErrCorrupt) |
|
827 { |
|
828 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, KErrDied)); |
|
829 } |
|
830 else |
|
831 { |
|
832 iObserver->SendEvent(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError)); |
|
833 } |
|
834 iState = EIdle; |
|
835 } |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // CDevSoundAudioOutput::BufferToBeEmptied |
|
840 // Callback from MDevSoundObserver |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 void CDevSoundAudioOutput::BufferToBeEmptied( |
|
844 CMMFBuffer* /*aBuffer*/) |
|
845 { |
|
846 __ASSERT_DEBUG(EFalse, Panic(EMMFAudioOutputPanicRecordErrorNotSupported)); |
|
847 } |
|
848 |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // CDevSoundAudioOutput::RecordError |
|
852 // Callback from DevSound when a complete buffer of audio data has been collected |
|
853 // (not applicable to playback) |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 void CDevSoundAudioOutput::RecordError( |
|
857 TInt /*aError*/) |
|
858 { |
|
859 //we should never get a recording error in MMFAudioOutput! |
|
860 __ASSERT_DEBUG(EFalse, Panic(EMMFAudioOutputPanicRecordErrorNotSupported)); |
|
861 } |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // CDevSoundAudioOutput::ConvertError |
|
865 // Called from DevSound when stopped due to error while coverting |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 void CDevSoundAudioOutput::ConvertError( |
|
869 TInt /*aError*/) |
|
870 { |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // CDevSoundAudioOutput::DeviceMessage |
|
875 // Callback from DevSound for message from hardware device (no messages in |
|
876 // current implementation of DevSound) |
|
877 // ----------------------------------------------------------------------------- |
|
878 // |
|
879 void CDevSoundAudioOutput::DeviceMessage( |
|
880 TUid /*aMessageType*/, |
|
881 const TDesC8& /*aMsg*/) |
|
882 { |
|
883 } |
|
884 |
|
885 // ----------------------------------------------------------------------------- |
|
886 // CDevSoundAudioOutput::SendEventToClient |
|
887 // Send given event to client |
|
888 // ----------------------------------------------------------------------------- |
|
889 // |
|
890 void CDevSoundAudioOutput::SendEventToClient( |
|
891 const TMMFEvent& aEvent) |
|
892 { |
|
893 iObserver->SendEvent(aEvent); |
|
894 } |
|
895 |
|
896 |
|
897 // ----------------------------------------------------------------------------- |
|
898 // CDevSoundAudioOutput::BufferFilled |
|
899 // Notification from Audio decoder that the specified buffer has been filled. |
|
900 // DevSound is requested to play the data. |
|
901 // ----------------------------------------------------------------------------- |
|
902 // |
|
903 void CDevSoundAudioOutput::BufferFilled( |
|
904 CMMFBuffer* aBuffer) |
|
905 { |
|
906 #ifdef _DEBUG |
|
907 TUint bytes = static_cast<CMMFDataBuffer*>(aBuffer)->Data().Length(); |
|
908 // iTestByteCount += bytes; |
|
909 DP2(_L("CDevSoundAudioOutput::BufferFilled length[%d] last[%d]"),bytes,aBuffer->LastBuffer()); |
|
910 #endif |
|
911 TBool sendCallback = EFalse; |
|
912 if (iState != EIdle) |
|
913 { |
|
914 if (aBuffer->LastBuffer()) |
|
915 { |
|
916 iState = EPreIdle; |
|
917 DP2(_L("CDevSoundAudioOutput::BufferFilled This is the LastBuffer. IsLoopPlayEnabled[%d] iUnSetLastBuffer[%d]"), iLoopPlayEnabled ,iUnSetLastBuffer); |
|
918 if (iUnSetLastBuffer) |
|
919 { |
|
920 // If Repeat is ON then set the LastBuffer flag to False |
|
921 DP0(_L("CDevSoundAudioOutput::BufferFilled This is the LastBuffer. LastBuffer is set to EFalse")); |
|
922 aBuffer->SetLastBuffer(EFalse); |
|
923 sendCallback = ETrue; |
|
924 iLastBufferSentToDevSound = EFalse; |
|
925 } |
|
926 else |
|
927 { |
|
928 DP0(_L("CDevSoundAudioOutput::BufferFilled LastBuffer is sent to MMFDevSound.... wait for PlayError callback ..")); |
|
929 iLastBufferSentToDevSound = ETrue; |
|
930 } |
|
931 } |
|
932 iSavedBufferPtr = NULL; |
|
933 // Request DevSound to play the buffer |
|
934 iMMFDevSound.PlayData(); |
|
935 if (sendCallback) |
|
936 { |
|
937 // Callback to CAdvancedAudioPlayController for handling the repeated play case |
|
938 DP0(_L("CDevSoundAudioOutput::BufferFilled Callback LastBufferSent to Observer")); |
|
939 iIgnoreBTBFDuringLoopPlay = ETrue; |
|
940 iObserver->LastBufferSent(); |
|
941 } |
|
942 DP0(_L("CDevSoundAudioOutput::BufferFilled End ")); |
|
943 } |
|
944 } |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CDevSoundAudioOutput::RefillBuffer |
|
948 // Notification from Audio Converter that the specified buffer needs to be |
|
949 // refilled. |
|
950 // ----------------------------------------------------------------------------- |
|
951 // |
|
952 void CDevSoundAudioOutput::RefillBuffer(CMMFBuffer* aEmptyBuffer) |
|
953 { |
|
954 // forward the request to the controller |
|
955 iObserver->RefillBuffer(aEmptyBuffer); // Async |
|
956 } |
|
957 /* |
|
958 // ----------------------------------------------------------------------------- |
|
959 // CDevSoundAudioOutput::RefillBuffer |
|
960 // Notification from Audio Converter that the specified buffer needs to be |
|
961 // refilled. |
|
962 // ----------------------------------------------------------------------------- |
|
963 // |
|
964 void CDevSoundAudioOutput::RefillBuffer(CMMFBuffer* aEmptyBuffer, TBool aDoSynchronousRead) |
|
965 { |
|
966 // forward the request to the controller |
|
967 iObserver->RefillBuffer(aEmptyBuffer, aDoSynchronousRead); |
|
968 } |
|
969 */ |
|
970 // ----------------------------------------------------------------------------- |
|
971 // CDevSoundAudioOutput::SendEvent |
|
972 // ----------------------------------------------------------------------------- |
|
973 // |
|
974 void CDevSoundAudioOutput::SendEvent( |
|
975 const TMMFEvent& aEvent) |
|
976 { |
|
977 iObserver->SendEvent(aEvent); |
|
978 } |
|
979 |
|
980 // ----------------------------------------------------------------------------- |
|
981 // CDevSoundAudioOutput::ConvertFromDevSoundCapsToSampleRatesL |
|
982 // Internal function to convert sampling rate from DevSound representation to |
|
983 // integer value |
|
984 // ----------------------------------------------------------------------------- |
|
985 // |
|
986 void CDevSoundAudioOutput::ConvertFromDevSoundCapsToSampleRatesL( |
|
987 const TMMFCapabilities& aDevSoundCaps, |
|
988 RArray<TUint>& aSampleRates) |
|
989 { |
|
990 if (aDevSoundCaps.iRate & EMMFSampleRate8000Hz) |
|
991 { |
|
992 User::LeaveIfError(aSampleRates.Append(KSampleRate8000Hz)); |
|
993 } |
|
994 if (aDevSoundCaps.iRate & EMMFSampleRate11025Hz) |
|
995 { |
|
996 User::LeaveIfError(aSampleRates.Append(KSampleRate11025Hz)); |
|
997 } |
|
998 if (aDevSoundCaps.iRate & EMMFSampleRate12000Hz) |
|
999 { |
|
1000 User::LeaveIfError(aSampleRates.Append(KSampleRate12000Hz)); |
|
1001 } |
|
1002 if (aDevSoundCaps.iRate & EMMFSampleRate16000Hz) |
|
1003 { |
|
1004 User::LeaveIfError(aSampleRates.Append(KSampleRate16000Hz)); |
|
1005 } |
|
1006 if (aDevSoundCaps.iRate & EMMFSampleRate22050Hz) |
|
1007 { |
|
1008 User::LeaveIfError(aSampleRates.Append(KSampleRate22050Hz)); |
|
1009 } |
|
1010 if (aDevSoundCaps.iRate & EMMFSampleRate24000Hz) |
|
1011 { |
|
1012 User::LeaveIfError(aSampleRates.Append(KSampleRate24000Hz)); |
|
1013 } |
|
1014 if (aDevSoundCaps.iRate & EMMFSampleRate32000Hz) |
|
1015 { |
|
1016 User::LeaveIfError(aSampleRates.Append(KSampleRate32000Hz)); |
|
1017 } |
|
1018 if (aDevSoundCaps.iRate & EMMFSampleRate44100Hz) |
|
1019 { |
|
1020 User::LeaveIfError(aSampleRates.Append(KSampleRate44100Hz)); |
|
1021 } |
|
1022 if (aDevSoundCaps.iRate & EMMFSampleRate48000Hz) |
|
1023 { |
|
1024 User::LeaveIfError(aSampleRates.Append(KSampleRate48000Hz)); |
|
1025 } |
|
1026 if (aDevSoundCaps.iRate & EMMFSampleRate64000Hz) |
|
1027 { |
|
1028 User::LeaveIfError(aSampleRates.Append(KSampleRate64000Hz)); |
|
1029 } |
|
1030 if (aDevSoundCaps.iRate & EMMFSampleRate88200Hz) |
|
1031 { |
|
1032 User::LeaveIfError(aSampleRates.Append(KSampleRate88200Hz)); |
|
1033 } |
|
1034 if (aDevSoundCaps.iRate & EMMFSampleRate96000Hz) |
|
1035 { |
|
1036 User::LeaveIfError(aSampleRates.Append(KSampleRate96000Hz)); |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // CDevSoundAudioOutput::ConvertFromDevSoundCapsToDataTypesL |
|
1042 // Internal function to convert data types from DevSound representation to |
|
1043 // FourCC |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // |
|
1046 void CDevSoundAudioOutput::ConvertFromDevSoundCapsToDataTypesL( |
|
1047 const TMMFCapabilities& aDevSoundCaps, |
|
1048 RArray<TFourCC>& aDataTypes) |
|
1049 { |
|
1050 if (aDevSoundCaps.iEncoding & EMMFSoundEncoding8BitPCM) |
|
1051 { |
|
1052 User::LeaveIfError(aDataTypes.Append(KMMFFourCCCodePCM8)); |
|
1053 } |
|
1054 if (aDevSoundCaps.iEncoding & EMMFSoundEncoding16BitPCM) |
|
1055 { |
|
1056 User::LeaveIfError(aDataTypes.Append(KMMFFourCCCodePCM16)); |
|
1057 } |
|
1058 if (aDevSoundCaps.iEncoding & EMMFSoundEncoding8BitALaw) |
|
1059 { |
|
1060 User::LeaveIfError(aDataTypes.Append(KMMFFourCCCodeALAW)); |
|
1061 } |
|
1062 if (aDevSoundCaps.iEncoding & EMMFSoundEncoding8BitMuLaw) |
|
1063 { |
|
1064 User::LeaveIfError(aDataTypes.Append(KMMFFourCCCodeMuLAW)); |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // CDevSoundAudioOutput::ConvertFromDevSoundCapsToNumChannelsL |
|
1070 // Internal function to convert number of channels from DevSound representation to |
|
1071 // integer value |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CDevSoundAudioOutput::ConvertFromDevSoundCapsToNumChannelsL( |
|
1075 const TMMFCapabilities& aDevSoundCaps, |
|
1076 RArray<TUint>& aNumChannels) |
|
1077 { |
|
1078 if (aDevSoundCaps.iChannels & EMMFMono) |
|
1079 { |
|
1080 User::LeaveIfError(aNumChannels.Append(KNumChannelsMono)); |
|
1081 } |
|
1082 if (aDevSoundCaps.iChannels & EMMFStereo) |
|
1083 { |
|
1084 User::LeaveIfError(aNumChannels.Append(KNumChannelsStereo)); |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // CDevSoundAudioOutput::Panic |
|
1090 // Raise user panic with appropriate panic code |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // |
|
1093 void CDevSoundAudioOutput::Panic( |
|
1094 TInt aPanicCode) const |
|
1095 { |
|
1096 _LIT(KDevSoundAudioOutputPanicCategory, "DevSoundAudioOutput"); |
|
1097 User::Panic(KDevSoundAudioOutputPanicCategory, aPanicCode); |
|
1098 } |
|
1099 |
|
1100 EXPORT_C void CDevSoundAudioOutput::IsLoopPlayEnabled(const TBool aLoopPlayEnabled) |
|
1101 { |
|
1102 DP1(_L("CDevSoundAudioOutput::IsLoopPlayEnabled LoopPlayEnabled[%d]"), aLoopPlayEnabled); |
|
1103 iLoopPlayEnabled = aLoopPlayEnabled; |
|
1104 } |
|
1105 |
|
1106 EXPORT_C void CDevSoundAudioOutput::UnSetLastBuffer(const TBool aUnSetLastBuffer) |
|
1107 { |
|
1108 DP1(_L("CDevSoundAudioOutput::UnSetLastBuffer UnSetLastBuffer[%d]"), aUnSetLastBuffer); |
|
1109 iUnSetLastBuffer = aUnSetLastBuffer; |
|
1110 } |
|
1111 |
|
1112 EXPORT_C TBool CDevSoundAudioOutput::IsDSStopped() |
|
1113 { |
|
1114 return iDSStopped; |
|
1115 } |
|
1116 |
|
1117 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1118 |
|
1119 // End of file |