984 EXPORT_C void CAdvancedAudioPlayController::RemoveDataSinkL( |
984 EXPORT_C void CAdvancedAudioPlayController::RemoveDataSinkL( |
985 MDataSink& aDataSink) |
985 MDataSink& aDataSink) |
986 { |
986 { |
987 DP0(_L("CAdvancedAudioPlayController::RemoveDataSinkL")); |
987 DP0(_L("CAdvancedAudioPlayController::RemoveDataSinkL")); |
988 |
988 |
989 if (!iDataSink) |
989 if (iDataSink != &aDataSink) |
|
990 { |
|
991 User::Leave(KErrArgument); |
|
992 } |
|
993 |
|
994 if ((iState != EStopped) && (iState != EInitialized)) |
990 { |
995 { |
991 User::Leave(KErrNotReady); |
996 User::Leave(KErrNotReady); |
992 } |
997 } |
993 |
998 |
994 if (iDataSink != &aDataSink) |
999 if (iDataSink) |
995 { |
1000 { |
996 User::Leave(KErrArgument); |
1001 iDataSink->SinkStopL(); // should always stop source before logoff |
997 } |
1002 iDataSink->SinkThreadLogoff(); |
998 |
1003 } |
999 if ((iState != EStopped) && (iState != EInitialized)) |
|
1000 { |
|
1001 User::Leave(KErrNotReady); |
|
1002 } |
|
1003 |
|
1004 iDataSink->SinkStopL(); // should always stop source before logoff |
|
1005 iDataSink->SinkThreadLogoff(); |
|
1006 |
1004 |
1007 // dereference Decoder from Utility before deleting AudioOutput (which took ownership of decoder) |
1005 // dereference Decoder from Utility before deleting AudioOutput (which took ownership of decoder) |
1008 if (iAudioUtility) |
1006 if (iAudioUtility) |
1009 { |
1007 { |
1010 iAudioUtility->DeReferenceDecoder(); |
1008 iAudioUtility->DeReferenceDecoder(); |
1011 } |
1009 } |
1012 |
1010 |
1013 delete iAudioOutput; |
1011 delete iAudioOutput; |
1014 iAudioOutput = NULL; |
1012 iAudioOutput = NULL; |
1015 iDataSink = NULL; |
1013 iDataSink = NULL; |
1016 iDecoderExists = EFalse; |
1014 iDecoderExists = EFalse; |
1017 } |
1015 } |
1018 |
1016 |
1019 // ----------------------------------------------------------------------------- |
1017 // ----------------------------------------------------------------------------- |
1347 */ |
1350 */ |
1348 if ((iPlayingForInitPos || iPlayingForPauseSeek || iPausingForSetPos) && aPreemption) |
1351 if ((iPlayingForInitPos || iPlayingForPauseSeek || iPausingForSetPos) && aPreemption) |
1349 {// we got preempted during a seek |
1352 {// we got preempted during a seek |
1350 // we're already seeking to a position. When we get there we'll come here again, but handle it below |
1353 // we're already seeking to a position. When we get there we'll come here again, but handle it below |
1351 DP0(_L("CAdvancedAudioPlayController::DoPauseL got a preemption during seek")); |
1354 DP0(_L("CAdvancedAudioPlayController::DoPauseL got a preemption during seek")); |
|
1355 |
|
1356 // if we are seeking, we need to flush the devsound buffers regardless of loop play |
|
1357 DP0(_L("CAdvancedAudioPlayController::DoPauseL AudioOutput->StopL()")); |
|
1358 iAudioOutput->StopL(); |
|
1359 |
|
1360 if (iPlayingForInitPos) |
|
1361 { |
|
1362 iState = EInitialized; |
|
1363 } |
|
1364 else |
|
1365 { |
|
1366 iState = EPaused; |
|
1367 } |
|
1368 iPlayingForPauseSeek = EFalse; |
|
1369 iPlayingForInitPos = EFalse; |
1352 return; |
1370 return; |
1353 } |
1371 } |
1354 |
1372 |
1355 /* |
1373 /* |
1356 * Internal Pause case: Pausing during an internal seeking and not pre-emption case. |
1374 * Internal Pause case: Pausing during an internal seeking and not pre-emption case. |
1905 DP0(_L("CAdvancedAudioPlayController::BufferFilledL calling DoPlayL Devsound is stopped iState=EInitialized")); |
1923 DP0(_L("CAdvancedAudioPlayController::BufferFilledL calling DoPlayL Devsound is stopped iState=EInitialized")); |
1906 DoPlayL(); |
1924 DoPlayL(); |
1907 } |
1925 } |
1908 else |
1926 else |
1909 { |
1927 { |
1910 // This is needed for non-seekable sources as DoRepeat() calls DoInitialize in this case |
1928 // This is needed for non-seekable sources as DoRepeatL() calls DoInitialize in this case |
1911 // this resets the source to read from 0 and sets the iState to EInitializing. |
1929 // this resets the source to read from 0 and sets the iState to EInitializing. |
1912 // BufferFilled will not read the header again, change state to EInitialized and seek to the iInitPosition. |
1930 // BufferFilled will not read the header again, change state to EInitialized and seek to the iInitPosition. |
1913 // The next BufferFilled will come here, where we will continue playback from byte position 0 |
1931 // The next BufferFilled will come here, where we will continue playback from byte position 0 |
1914 // that is now in the buffers. |
1932 // that is now in the buffers. |
1915 DP0(_L("CAdvancedAudioPlayController::BufferFilledL Resuming the playback iState=EInitialized")); |
1933 DP0(_L("CAdvancedAudioPlayController::BufferFilledL Resuming the playback iState=EInitialized")); |
2407 #endif |
2425 #endif |
2408 */ |
2426 */ |
2409 DP0(_L("CAdvancedAudioPlayController::LastBufferSent End")); |
2427 DP0(_L("CAdvancedAudioPlayController::LastBufferSent End")); |
2410 } |
2428 } |
2411 |
2429 |
2412 void CAdvancedAudioPlayController::DoRepeat() |
2430 void CAdvancedAudioPlayController::DoRepeatL() |
2413 { |
2431 { |
2414 DP0(_L("CAdvancedAudioPlayController::DoRepeat Begin")); |
2432 DP0(_L("CAdvancedAudioPlayController::DoRepeatL Begin")); |
2415 // save the current position, this will be used to calculate the position in loop play when |
2433 // save the current position, this will be used to calculate the position in loop play when |
2416 // client calls for PositionL() or Pause() operations |
2434 // client calls for PositionL() or Pause() operations |
2417 // TODO: need to check this position when loop play is going on in a play window |
2435 // TODO: need to check this position when loop play is going on in a play window |
2418 iSavedTimePositionInMicroSecs = iAudioOutput->CalculateAudioOutputPositionL(); |
2436 iSavedTimePositionInMicroSecs = iAudioOutput->CalculateAudioOutputPositionL(); |
2419 DP1(_L("CAdvancedAudioPlayController::DoRepeat iSavedTimePositionInMicroSecs[%u]"), iSavedTimePositionInMicroSecs); |
2437 DP1(_L("CAdvancedAudioPlayController::DoRepeatL iSavedTimePositionInMicroSecs[%u]"), iSavedTimePositionInMicroSecs); |
2420 |
2438 |
2421 if ((!iRepeatForever) && (iCurrentRepeatCount < iRepeatCount)) |
2439 if ((!iRepeatForever) && (iCurrentRepeatCount < iRepeatCount)) |
2422 { |
2440 { |
2423 iCurrentRepeatCount++; |
2441 iCurrentRepeatCount++; |
2424 } |
2442 } |
2425 DP1(_L("CAdvancedAudioPlayController::DoRepeat Number of times played till now = %d"), iCurrentRepeatCount); |
2443 DP1(_L("CAdvancedAudioPlayController::DoRepeatL Number of times played till now = %d"), iCurrentRepeatCount); |
2426 |
2444 |
2427 if (iSourceIsTimeSeekable || iSourceIsPosSeekable) |
2445 if (iSourceIsTimeSeekable || iSourceIsPosSeekable) |
2428 { // For seekable source |
2446 { // For seekable source |
2429 // if there is a playwindow set then use that, otherwise go back to 0 time |
2447 // if there is a playwindow set then use that, otherwise go back to 0 time |
2430 // if ((iPlayWindowStartPosition != 0) || (iPlayWindowEndPosition != 0)) |
2448 // if ((iPlayWindowStartPosition != 0) || (iPlayWindowEndPosition != 0)) |
2431 // SetPlayWindow(iPlayWindowStartPosition, iPlayWindowEndPosition); |
2449 // SetPlayWindow(iPlayWindowStartPosition, iPlayWindowEndPosition); |
2432 if (iPlayWindowStartPosition > 0) |
2450 if (iPlayWindowStartPosition > 0) |
2433 { |
2451 { |
2434 DP1(_L("CAdvancedAudioPlayController::DoRepeat SetPositionL[%d]ms"), I64LOW(iPlayWindowStartPosition.Int64()/1000)); |
2452 DP1(_L("CAdvancedAudioPlayController::DoRepeatL SetPositionL[%d]ms"), I64LOW(iPlayWindowStartPosition.Int64()/1000)); |
2435 SetPositionL(iPlayWindowStartPosition); |
2453 SetPositionL(iPlayWindowStartPosition); |
2436 } |
2454 } |
2437 else |
2455 else |
2438 { |
2456 { |
2439 DP0(_L("CAdvancedAudioPlayController::DoRepeat SetPositionL(0)")); |
2457 DP0(_L("CAdvancedAudioPlayController::DoRepeatL SetPositionL(0)")); |
2440 SetPositionL(0); |
2458 SetPositionL(0); |
2441 } |
2459 } |
2442 // Register for PlayWindow end position as the FrameTable has set its playwindowendpostime to zero |
2460 // Register for PlayWindow end position as the FrameTable has set its playwindowendpostime to zero |
2443 if (iPlayWindowEndPosition > 0) |
2461 if (iPlayWindowEndPosition > 0) |
2444 { |
2462 { |
2445 DP1(_L("CAdvancedAudioPlayController::DoRepeat iAudioUtility->SetPlayWindowEndTimeMs(%d)"), I64LOW(iPlayWindowEndPosition.Int64()/1000)); |
2463 DP1(_L("CAdvancedAudioPlayController::DoRepeatL iAudioUtility->SetPlayWindowEndTimeMs(%d)"), I64LOW(iPlayWindowEndPosition.Int64()/1000)); |
2446 iAudioUtility->SetPlayWindowEndTimeMs(iPlayWindowEndPosition.Int64() / 1000); |
2464 iAudioUtility->SetPlayWindowEndTimeMs(iPlayWindowEndPosition.Int64() / 1000); |
2447 } |
2465 } |
2448 } |
2466 } |
2449 else |
2467 else |
2450 { // For non-seekable source |
2468 { // For non-seekable source |
2451 // Stop and start playback |
2469 // Stop and start playback |
2452 DP0(_L("CAdvancedAudioPlayController::DoRepeat Non-Seekable source.")); |
2470 DP0(_L("CAdvancedAudioPlayController::DoRepeatL Non-Seekable source.")); |
2453 iAudioOutput->StopL(EFalse); |
2471 iAudioOutput->StopL(EFalse); |
2454 iDataSourceAdapter->SourceStopL(); // clear the buffers in the source before seeking and priming it |
2472 iDataSourceAdapter->SourceStopL(); // clear the buffers in the source before seeking and priming it |
2455 DoInitializeL(); |
2473 DoInitializeL(); |
2456 // set the read header flag to true so that the header is read before the playback is resumed |
2474 // set the read header flag to true so that the header is read before the playback is resumed |
2457 // and the current position is adjusted to be placed after the header. |
2475 // and the current position is adjusted to be placed after the header. |
2458 iReadHeader = ETrue; |
2476 iReadHeader = ETrue; |
2459 } |
2477 } |
2460 DP0(_L("CAdvancedAudioPlayController::DoRepeat End") ); |
2478 DP0(_L("CAdvancedAudioPlayController::DoRepeatL End") ); |
2461 } |
2479 } |
2462 |
2480 |
2463 EXPORT_C void CAdvancedAudioPlayController::TrailingSilenceTimerComplete() |
2481 EXPORT_C void CAdvancedAudioPlayController::TrailingSilenceTimerComplete() |
2464 { |
2482 { |
2465 DP0(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete ")); |
2483 DP0(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete ")); |
2466 DoRepeat(); |
2484 |
|
2485 TRAPD(err,DoRepeatL()); //Fix for Bug ECWG-84WE9J |
|
2486 DP1(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete: DoRepeatL [%d]"), err); |
|
2487 if(err) |
|
2488 { |
|
2489 SendEventToClient(TMMFEvent(KMMFEventCategoryPlaybackComplete,err)); |
|
2490 } |
2467 } |
2491 } |
2468 |
2492 |
2469 EXPORT_C TInt CAdvancedAudioPlayController::GetCodecConfigData(RArray<TInt>& aCodecConfigData) |
2493 EXPORT_C TInt CAdvancedAudioPlayController::GetCodecConfigData(RArray<TInt>& aCodecConfigData) |
2470 { |
2494 { |
2471 TInt stat = KErrNone; |
2495 TInt stat = KErrNone; |