mmfenh/advancedaudiocontroller/audiocontrollerpluginsvariant/AdvancedAudioController/Src/AdvancedAudioPlayController.cpp
branchRCL_3
changeset 12 2eb3b066cc7d
parent 11 3570217d8c21
child 13 bea5e7625e42
equal deleted inserted replaced
11:3570217d8c21 12:2eb3b066cc7d
  1908                         DP0(_L("CAdvancedAudioPlayController::BufferFilledL calling DoPlayL Devsound is stopped iState=EInitialized"));
  1908                         DP0(_L("CAdvancedAudioPlayController::BufferFilledL calling DoPlayL Devsound is stopped iState=EInitialized"));
  1909                         DoPlayL();
  1909                         DoPlayL();
  1910                         }
  1910                         }
  1911                     else
  1911                     else
  1912                         {
  1912                         {
  1913                         // This is needed for non-seekable sources as DoRepeat() calls DoInitialize in this case
  1913                         // This is needed for non-seekable sources as DoRepeatL() calls DoInitialize in this case
  1914                         // this resets the source to read from 0 and sets the iState to EInitializing.
  1914                         // this resets the source to read from 0 and sets the iState to EInitializing.
  1915                         // BufferFilled will not read the header again, change state to EInitialized and seek to the iInitPosition.
  1915                         // BufferFilled will not read the header again, change state to EInitialized and seek to the iInitPosition.
  1916                         // The next BufferFilled will come here, where we will continue playback from byte position 0
  1916                         // The next BufferFilled will come here, where we will continue playback from byte position 0
  1917                         // that is now in the buffers.
  1917                         // that is now in the buffers.
  1918                         DP0(_L("CAdvancedAudioPlayController::BufferFilledL Resuming the playback iState=EInitialized"));
  1918                         DP0(_L("CAdvancedAudioPlayController::BufferFilledL Resuming the playback iState=EInitialized"));
  2410       #endif
  2410       #endif
  2411      */
  2411      */
  2412     DP0(_L("CAdvancedAudioPlayController::LastBufferSent End"));
  2412     DP0(_L("CAdvancedAudioPlayController::LastBufferSent End"));
  2413     }
  2413     }
  2414 
  2414 
  2415 void CAdvancedAudioPlayController::DoRepeat()
  2415 void CAdvancedAudioPlayController::DoRepeatL()
  2416     {
  2416     {
  2417     DP0(_L("CAdvancedAudioPlayController::DoRepeat Begin"));
  2417     DP0(_L("CAdvancedAudioPlayController::DoRepeatL Begin"));
  2418     // save the current position, this will be used to calculate the position in loop play when
  2418     // save the current position, this will be used to calculate the position in loop play when
  2419     // client calls for PositionL() or Pause() operations
  2419     // client calls for PositionL() or Pause() operations
  2420     // TODO:  need to check this position when loop play is going on in a play window
  2420     // TODO:  need to check this position when loop play is going on in a play window
  2421     iSavedTimePositionInMicroSecs = iAudioOutput->CalculateAudioOutputPositionL();
  2421     iSavedTimePositionInMicroSecs = iAudioOutput->CalculateAudioOutputPositionL();
  2422     DP1(_L("CAdvancedAudioPlayController::DoRepeat iSavedTimePositionInMicroSecs[%u]"), iSavedTimePositionInMicroSecs);
  2422     DP1(_L("CAdvancedAudioPlayController::DoRepeatL iSavedTimePositionInMicroSecs[%u]"), iSavedTimePositionInMicroSecs);
  2423     
  2423     
  2424     if ((!iRepeatForever) && (iCurrentRepeatCount < iRepeatCount))
  2424     if ((!iRepeatForever) && (iCurrentRepeatCount < iRepeatCount))
  2425         {
  2425         {
  2426         iCurrentRepeatCount++;
  2426         iCurrentRepeatCount++;
  2427         }
  2427         }
  2428     DP1(_L("CAdvancedAudioPlayController::DoRepeat Number of times played till now = %d"), iCurrentRepeatCount);
  2428     DP1(_L("CAdvancedAudioPlayController::DoRepeatL Number of times played till now = %d"), iCurrentRepeatCount);
  2429     
  2429     
  2430     if (iSourceIsTimeSeekable || iSourceIsPosSeekable)
  2430     if (iSourceIsTimeSeekable || iSourceIsPosSeekable)
  2431         { // For seekable source
  2431         { // For seekable source
  2432         // if there is a playwindow set then use that, otherwise go back to 0 time
  2432         // if there is a playwindow set then use that, otherwise go back to 0 time
  2433         // if ((iPlayWindowStartPosition != 0) || (iPlayWindowEndPosition != 0))
  2433         // if ((iPlayWindowStartPosition != 0) || (iPlayWindowEndPosition != 0))
  2434         // SetPlayWindow(iPlayWindowStartPosition, iPlayWindowEndPosition);
  2434         // SetPlayWindow(iPlayWindowStartPosition, iPlayWindowEndPosition);
  2435         if (iPlayWindowStartPosition > 0)
  2435         if (iPlayWindowStartPosition > 0)
  2436             {
  2436             {
  2437             DP1(_L("CAdvancedAudioPlayController::DoRepeat SetPositionL[%d]ms"), I64LOW(iPlayWindowStartPosition.Int64()/1000));
  2437             DP1(_L("CAdvancedAudioPlayController::DoRepeatL SetPositionL[%d]ms"), I64LOW(iPlayWindowStartPosition.Int64()/1000));
  2438             SetPositionL(iPlayWindowStartPosition);
  2438             SetPositionL(iPlayWindowStartPosition);
  2439             }
  2439             }
  2440         else
  2440         else
  2441             {
  2441             {
  2442             DP0(_L("CAdvancedAudioPlayController::DoRepeat SetPositionL(0)"));
  2442             DP0(_L("CAdvancedAudioPlayController::DoRepeatL SetPositionL(0)"));
  2443             SetPositionL(0);
  2443             SetPositionL(0);
  2444             }
  2444             }
  2445         // Register for PlayWindow end position as the FrameTable has set its playwindowendpostime to zero
  2445         // Register for PlayWindow end position as the FrameTable has set its playwindowendpostime to zero
  2446         if (iPlayWindowEndPosition > 0)
  2446         if (iPlayWindowEndPosition > 0)
  2447             {
  2447             {
  2448             DP1(_L("CAdvancedAudioPlayController::DoRepeat iAudioUtility->SetPlayWindowEndTimeMs(%d)"), I64LOW(iPlayWindowEndPosition.Int64()/1000));
  2448             DP1(_L("CAdvancedAudioPlayController::DoRepeatL iAudioUtility->SetPlayWindowEndTimeMs(%d)"), I64LOW(iPlayWindowEndPosition.Int64()/1000));
  2449             iAudioUtility->SetPlayWindowEndTimeMs(iPlayWindowEndPosition.Int64() / 1000);
  2449             iAudioUtility->SetPlayWindowEndTimeMs(iPlayWindowEndPosition.Int64() / 1000);
  2450             }
  2450             }
  2451         }
  2451         }
  2452     else
  2452     else
  2453         { // For non-seekable source
  2453         { // For non-seekable source
  2454         // Stop and start playback
  2454         // Stop and start playback
  2455         DP0(_L("CAdvancedAudioPlayController::DoRepeat Non-Seekable source."));
  2455         DP0(_L("CAdvancedAudioPlayController::DoRepeatL Non-Seekable source."));
  2456         iAudioOutput->StopL(EFalse);
  2456         iAudioOutput->StopL(EFalse);
  2457         iDataSourceAdapter->SourceStopL(); // clear the buffers in the source before seeking and priming it
  2457         iDataSourceAdapter->SourceStopL(); // clear the buffers in the source before seeking and priming it
  2458         DoInitializeL();
  2458         DoInitializeL();
  2459         // set the read header flag to true so that the header is read before the playback is resumed
  2459         // set the read header flag to true so that the header is read before the playback is resumed
  2460         // and the current position is adjusted to be placed after the header.
  2460         // and the current position is adjusted to be placed after the header.
  2461         iReadHeader = ETrue;
  2461         iReadHeader = ETrue;
  2462         }
  2462         }
  2463     DP0(_L("CAdvancedAudioPlayController::DoRepeat End") );
  2463     DP0(_L("CAdvancedAudioPlayController::DoRepeatL End") );
  2464     }
  2464     }
  2465 
  2465 
  2466 EXPORT_C void CAdvancedAudioPlayController::TrailingSilenceTimerComplete()
  2466 EXPORT_C void CAdvancedAudioPlayController::TrailingSilenceTimerComplete()
  2467     {
  2467     {
  2468     DP0(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete "));
  2468     DP0(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete "));
  2469     DoRepeat();
  2469    
       
  2470     TRAPD(err,DoRepeatL()); //Fix for Bug ECWG-84WE9J
       
  2471     DP1(_L("CAdvancedAudioPlayController::TrailingSilenceTimerComplete: DoRepeatL [%d]"), err);
       
  2472     if(err)
       
  2473         {
       
  2474          SendEventToClient(TMMFEvent(KMMFEventCategoryPlaybackComplete,err));
       
  2475         }
  2470     }
  2476     }
  2471 
  2477 
  2472 EXPORT_C TInt CAdvancedAudioPlayController::GetCodecConfigData(RArray<TInt>& aCodecConfigData)
  2478 EXPORT_C TInt CAdvancedAudioPlayController::GetCodecConfigData(RArray<TInt>& aCodecConfigData)
  2473     {
  2479     {
  2474     TInt stat = KErrNone;
  2480     TInt stat = KErrNone;