RageSoundReader::Read(buf, unsigned bytes) -> (buf, int frames);

return value in frames, not bytes
This commit is contained in:
Glenn Maynard
2006-12-10 03:56:36 +00:00
parent 7bcb489288
commit 25e67dd4dc
23 changed files with 112 additions and 117 deletions
+5 -8
View File
@@ -9,31 +9,28 @@ RageSoundReader_Pan::RageSoundReader_Pan( RageSoundReader *pSource ):
}
int RageSoundReader_Pan::Read( char *pBuf, unsigned iLen )
int RageSoundReader_Pan::Read( char *pBuf, int iFrames )
{
/* If the source is mono, it'll be converted to stereo; read half as many frames,
* so we have space. */
if( m_pSource->GetNumChannels() == 1 )
iLen /= 2;
iFrames /= 2;
int iRet = m_pSource->Read( pBuf, iLen );
int iSamples = iRet / sizeof(uint16_t);
iFrames = m_pSource->Read( pBuf, iFrames );
int iSamples = iFrames * m_pSource->GetNumChannels();
int16_t *pSampleBuf = (int16_t *) pBuf;
if( m_pSource->GetNumChannels() == 1 )
{
RageSoundUtil::ConvertMonoToStereoInPlace( pSampleBuf, iSamples );
iRet *= 2;
iSamples *= 2;
}
int iFrames = iSamples / GetNumChannels();
/* This block goes from iStreamFrame to iStreamFrame+iGotFrames. */
if( GetNumChannels() == 2 && m_fPan != 0.0 )
RageSoundUtil::Pan( pSampleBuf, iFrames, m_fPan );
return iRet;
return iFrames;
}
unsigned RageSoundReader_Pan::GetNumChannels() const