mmfenh/advancedaudiocontroller/audiocontrollerpluginsvariant/AdvancedAudioController/Src/AdvancedAudioPlayController.cpp
branchRCL_3
changeset 20 0ac9a5310753
parent 19 095bea5f582e
equal deleted inserted replaced
19:095bea5f582e 20:0ac9a5310753
   121         }
   121         }
   122 
   122 
   123 	delete iDataSourceAdapter;
   123 	delete iDataSourceAdapter;
   124 	delete iWait;
   124 	delete iWait;
   125 	delete iBlockSetPos;
   125 	delete iBlockSetPos;
   126 	delete iBlockPrime;
       
   127       
       
   128 	iSharedBuffers.ResetAndDestroy();
   126 	iSharedBuffers.ResetAndDestroy();
   129 	iSharedBuffers.Close();
   127 	iSharedBuffers.Close();
   130     DP0(_L("CAdvancedAudioPlayController::~CAdvancedAudioPlayController end"));
   128     DP0(_L("CAdvancedAudioPlayController::~CAdvancedAudioPlayController end"));
   131     }
   129     }
   132 
   130 
   679         if (iBlockSetPos->IsStarted())
   677         if (iBlockSetPos->IsStarted())
   680             {
   678             {
   681             iBlockSetPos->AsyncStop();
   679             iBlockSetPos->AsyncStop();
   682             }
   680             }
   683         }
   681         }
   684     if(iBlockPrime)
   682 
   685        {
       
   686        if(iBlockPrime->IsStarted())
       
   687        	   {
       
   688             iBlockPrime->AsyncStop();
       
   689            }
       
   690        }
       
   691     iRequestState = EPaused;
   683     iRequestState = EPaused;
   692     TRAP(err, DoPauseL(ETrue)); // this is a preemption pause
   684     TRAP(err, DoPauseL(ETrue)); // this is a preemption pause
   693 	// In case of pre-emption we should only Pause ... but not Stop.
   685 	// In case of pre-emption we should only Pause ... but not Stop.
   694     SendEventToClient(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError));
   686     SendEventToClient(TMMFEvent(KMMFEventCategoryPlaybackComplete, aError));
   695     SendEventToClient(TMMFEvent(KStreamControlEventStateChangedPaused, aError));
   687     SendEventToClient(TMMFEvent(KStreamControlEventStateChangedPaused, aError));
  1637         if (iBlockSetPos->IsStarted())
  1629         if (iBlockSetPos->IsStarted())
  1638             {
  1630             {
  1639             iBlockSetPos->AsyncStop();
  1631             iBlockSetPos->AsyncStop();
  1640             }
  1632             }
  1641         }
  1633         }
  1642     if(iBlockPrime)
  1634    
  1643         {
       
  1644         if(iBlockPrime->IsStarted())
       
  1645          iBlockPrime->AsyncStop();
       
  1646         }
       
  1647     iPlayingForDuration = EFalse;
  1635     iPlayingForDuration = EFalse;
  1648     iBlockDuration = EFalse;
  1636     iBlockDuration = EFalse;
  1649     iPlayingForPauseSeek = EFalse;
  1637     iPlayingForPauseSeek = EFalse;
  1650     iPlayingForInitPos = EFalse;
  1638     iPlayingForInitPos = EFalse;
  1651     iPausingForSetPos = EFalse;
  1639     iPausingForSetPos = EFalse;
  1730 		{
  1718 		{
  1731 		case EStopped:
  1719 		case EStopped:
  1732 		case EInitializing:
  1720 		case EInitializing:
  1733             if (position != 0)
  1721             if (position != 0)
  1734     	   		{ // if we are priming, we will already be ready to play from 0.
  1722     	   		{ // if we are priming, we will already be ready to play from 0.
  1735 				     DP2(_L("CAdvancedAudioPlayController::SetPositionL, saving pos iReadHeader[%d] iState[%d]"),iReadHeader,iState);
  1723 				DP2(_L("CAdvancedAudioPlayController::SetPositionL, saving pos iReadHeader[%d] iState[%d]"),iReadHeader,iState);
  1736              iInitPosition = position;
  1724                 iInitPosition = position;
  1737        			}
  1725        			}
  1738 			  DP0(_L("CAdvancedAudioPlayController::SetPositionL, can ignore"));
  1726 			DP0(_L("CAdvancedAudioPlayController::SetPositionL, can ignore"));
  1739 			  DP0(_L("CAdvancedAudioController::PrimeL() blocking"));
  1727 			break;
  1740         iBlockPrime= new (ELeave) CActiveSchedulerWait();
       
  1741         iBlockPrime->Start();
       
  1742         DP0(_L("CAdvancedAudioController::PrimeL() continuing"));
       
  1743         delete iBlockPrime;
       
  1744         iBlockPrime= NULL;
       
  1745 			
       
  1746 		case EInitialized:
  1728 		case EInitialized:
  1747 		case EPaused:
  1729 		case EPaused:
  1748 		    iSavedSetPosition = position;
  1730 		    iSavedSetPosition = position;
  1749             DoSetPositionL(position);
  1731             DoSetPositionL(position);
  1750    			if (iPlaySeeking)
  1732    			if (iPlaySeeking)
  1915 				    if (iSourceUnreadable)
  1897 				    if (iSourceUnreadable)
  1916 				        {
  1898 				        {
  1917 				        return;
  1899 				        return;
  1918 				        }
  1900 				        }
  1919 					iState = EInitialized;
  1901 					iState = EInitialized;
  1920 					if(iBlockPrime)
       
  1921 					    {
       
  1922 					    if(iBlockPrime->IsStarted())
       
  1923 					    	{
       
  1924 					      iBlockPrime->AsyncStop();
       
  1925 					      }
       
  1926 					    }
       
  1927 					
       
  1928 					// when playwindow is active for a non-seekable source during loop play
  1902 					// when playwindow is active for a non-seekable source during loop play
  1929 					// we must seek to the playwindow start position and then start the playback
  1903 					// we must seek to the playwindow start position and then start the playback
  1930 					if (iPlayWindowStartPosition > 0) // do we need additional checks as loop play / non-seekable source ??
  1904 					if (iPlayWindowStartPosition > 0) // do we need additional checks as loop play / non-seekable source ??
  1931 					    iInitPosition = iPlayWindowStartPosition;
  1905 					    iInitPosition = iPlayWindowStartPosition;
  1932     				GoToInitPositionL(); // see if we need to seek to somewhere
  1906     				GoToInitPositionL(); // see if we need to seek to somewhere