use RetriedRead
This commit is contained in:
@@ -284,16 +284,9 @@ int RageSound::GetData( char *pBuffer, int iFrames )
|
|||||||
/* Read data from our source. */
|
/* Read data from our source. */
|
||||||
ASSERT( m_pSource );
|
ASSERT( m_pSource );
|
||||||
|
|
||||||
fRate = m_pSource->GetStreamToSourceRatio();
|
int iNewSourceFrame;
|
||||||
int iNewSourceFrame = m_pSource->GetNextSourceFrame();
|
iGotFrames = m_pSource->RetriedRead( pBuffer, iFrames, &iNewSourceFrame, &fRate );
|
||||||
|
|
||||||
/* m_pSource->Read() may return 0, which means "try again immediately". As
|
|
||||||
* a failsafe, only try this a finite number of times. Use a high number,
|
|
||||||
* because in principle each filter in the stack may cause this. */
|
|
||||||
int iTries = 100;
|
|
||||||
while( iGotFrames == 0 && --iTries )
|
|
||||||
{
|
|
||||||
iGotFrames = m_pSource->Read( pBuffer, iFrames );
|
|
||||||
if( iGotFrames == RageSoundReader::ERROR )
|
if( iGotFrames == RageSoundReader::ERROR )
|
||||||
{
|
{
|
||||||
Fail( m_pSource->GetError() );
|
Fail( m_pSource->GetError() );
|
||||||
@@ -303,21 +296,7 @@ int RageSound::GetData( char *pBuffer, int iFrames )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( iGotFrames == RageSoundReader::END_OF_FILE )
|
if( iGotFrames == RageSoundReader::END_OF_FILE )
|
||||||
{
|
|
||||||
iGotFrames = 0;
|
iGotFrames = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_M( iGotFrames >= 0, ssprintf("%i", iGotFrames) ); // unhandled error condition
|
|
||||||
}
|
|
||||||
|
|
||||||
if( iTries == 0 )
|
|
||||||
{
|
|
||||||
Fail( "Read() busy looping" );
|
|
||||||
|
|
||||||
/* Pretend we got EOF. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we didn't get any data, don't update iSourceFrame, so we just keep
|
/* If we didn't get any data, don't update iSourceFrame, so we just keep
|
||||||
* extrapolating if we're in M_CONTINUE. */
|
* extrapolating if we're in M_CONTINUE. */
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ int RageSoundReader_Chain::Read( char *pBuffer, int iFrames )
|
|||||||
int iFramesRead = 0;
|
int iFramesRead = 0;
|
||||||
while( iFramesRead < iFrames )
|
while( iFramesRead < iFrames )
|
||||||
{
|
{
|
||||||
int iGotFrames = pSound->Read( (char *) Buffer, iFrames - iFramesRead );
|
int iGotFrames = pSound->RetriedRead( (char *) Buffer, iFrames - iFramesRead );
|
||||||
if( iGotFrames < 0 )
|
if( iGotFrames < 0 )
|
||||||
{
|
{
|
||||||
iFramesRead = iGotFrames;
|
iFramesRead = iGotFrames;
|
||||||
|
|||||||
Reference in New Issue
Block a user