RageSoundReader::Read(char *) -> int16_t *. This was originally
char * based on the idea of supporting more than one sample type. I don't plan to do that (though I may change the sample type to float or int32).
This commit is contained in:
@@ -743,7 +743,7 @@ static void mono_to_stereo( char *dst, const char *src, unsigned len )
|
||||
}
|
||||
}
|
||||
|
||||
int RageSoundReader_MP3::Read( char *buf, int iFrames )
|
||||
int RageSoundReader_MP3::Read( int16_t *buf, int iFrames )
|
||||
{
|
||||
int iFramesWritten = 0;
|
||||
|
||||
@@ -752,11 +752,12 @@ int RageSoundReader_MP3::Read( char *buf, int iFrames )
|
||||
if( mad->outleft > 0 )
|
||||
{
|
||||
int iFramesToCopy = min( iFrames, int(mad->outleft / (sizeof(int16_t) * GetNumChannels())) );
|
||||
const int iBytesToCopy = iFramesToCopy * sizeof(int16_t) * GetNumChannels();
|
||||
const int iSamplesToCopy = iFramesToCopy * GetNumChannels();
|
||||
const int iBytesToCopy = iSamplesToCopy * sizeof(int16_t);
|
||||
|
||||
memcpy( buf, mad->outbuf + mad->outpos, iBytesToCopy );
|
||||
|
||||
buf += iBytesToCopy;
|
||||
buf += iSamplesToCopy;
|
||||
iFrames -= iFramesToCopy;
|
||||
iFramesWritten += iFramesToCopy;
|
||||
mad->outpos += iBytesToCopy;
|
||||
|
||||
Reference in New Issue
Block a user