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