cleanup
This commit is contained in:
@@ -812,13 +812,13 @@ bool RageSound::SetPositionFrames( int iFrames )
|
||||
* at 0.5x, and we're seeking to the 10th frame, we would have actually
|
||||
* played 20 frames, and it's the number of real speaker frames that
|
||||
* "m_iDecodePosition" represents. */
|
||||
const int iScaledFrames = int( iFrames / GetPlaybackRate() );
|
||||
const int iScaledFrames = int( iFrames / GetPlaybackRate() );
|
||||
|
||||
/* If we're already there, don't do anything. */
|
||||
if( m_iDecodePosition == iScaledFrames )
|
||||
return true;
|
||||
/* If we're already there, don't do anything. */
|
||||
if( m_iDecodePosition == iScaledFrames )
|
||||
return true;
|
||||
|
||||
m_iStoppedPosition = m_iDecodePosition = iScaledFrames;
|
||||
m_iStoppedPosition = m_iDecodePosition = iScaledFrames;
|
||||
}
|
||||
|
||||
/* The position we're going to seek the input stream to. We have
|
||||
|
||||
@@ -503,20 +503,20 @@ RageSoundReader_Resample_Good::RageSoundReader_Resample_Good()
|
||||
void RageSoundReader_Resample_Good::Reset()
|
||||
{
|
||||
for( size_t iChannel = 0; iChannel < m_pSource->GetNumChannels(); ++iChannel )
|
||||
resamplers[iChannel]->Reset();
|
||||
m_apResamplers[iChannel]->Reset();
|
||||
}
|
||||
|
||||
|
||||
/* Call this if the sample factor changes. */
|
||||
void RageSoundReader_Resample_Good::ReopenResampler()
|
||||
{
|
||||
for( size_t iChannel = 0; iChannel < resamplers.size(); ++iChannel )
|
||||
delete resamplers[iChannel];
|
||||
resamplers.clear();
|
||||
for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel )
|
||||
delete m_apResamplers[iChannel];
|
||||
m_apResamplers.clear();
|
||||
for( size_t iChannel = 0; iChannel < m_pSource->GetNumChannels(); ++iChannel )
|
||||
{
|
||||
RageSoundResampler_Polyphase *p = new RageSoundResampler_Polyphase( m_pSource->GetSampleRate(), m_iSampleRate );
|
||||
resamplers.push_back( p );
|
||||
m_apResamplers.push_back( p );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,8 +529,8 @@ void RageSoundReader_Resample_Good::Open( SoundReader *pSource )
|
||||
|
||||
RageSoundReader_Resample_Good::~RageSoundReader_Resample_Good()
|
||||
{
|
||||
for( size_t iChannel = 0; iChannel < resamplers.size(); ++iChannel )
|
||||
delete resamplers[iChannel];
|
||||
for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel )
|
||||
delete m_apResamplers[iChannel];
|
||||
delete m_pSource;
|
||||
}
|
||||
|
||||
@@ -550,30 +550,30 @@ int RageSoundReader_Resample_Good::GetLength_Fast() const
|
||||
return m_pSource->GetLength_Fast();
|
||||
}
|
||||
|
||||
int RageSoundReader_Resample_Good::SetPosition_Accurate(int ms)
|
||||
int RageSoundReader_Resample_Good::SetPosition_Accurate( int iMS )
|
||||
{
|
||||
Reset();
|
||||
return m_pSource->SetPosition_Accurate(ms);
|
||||
return m_pSource->SetPosition_Accurate( iMS );
|
||||
}
|
||||
|
||||
int RageSoundReader_Resample_Good::SetPosition_Fast(int ms)
|
||||
int RageSoundReader_Resample_Good::SetPosition_Fast( int iMS )
|
||||
{
|
||||
Reset();
|
||||
return m_pSource->SetPosition_Fast(ms);
|
||||
return m_pSource->SetPosition_Fast( iMS );
|
||||
}
|
||||
|
||||
int RageSoundReader_Resample_Good::Read( char *bufp, unsigned len )
|
||||
int RageSoundReader_Resample_Good::Read( char *pBuf_, unsigned iLen )
|
||||
{
|
||||
int iChannels = resamplers.size();
|
||||
int iChannels = m_apResamplers.size();
|
||||
int iBytesPerFrame = sizeof(int16_t) * iChannels;
|
||||
|
||||
int iFrames = len / iBytesPerFrame; /* bytes -> frames */
|
||||
int16_t *pBuf = (int16_t *) bufp;
|
||||
int iFrames = iLen / iBytesPerFrame; /* bytes -> frames */
|
||||
int16_t *pBuf = (int16_t *) pBuf_;
|
||||
|
||||
int iFramesRead = 0;
|
||||
|
||||
{
|
||||
int iFramesNeeded = resamplers[0]->NumInputsForOutputSamples(iFrames);
|
||||
int iFramesNeeded = m_apResamplers[0]->NumInputsForOutputSamples(iFrames);
|
||||
int iBytesNeeded = iFramesNeeded * sizeof(int16_t) * iChannels;
|
||||
int16_t *pTmpBuf = (int16_t *) alloca( iBytesNeeded );
|
||||
ASSERT( pTmpBuf );
|
||||
@@ -602,7 +602,7 @@ int RageSoundReader_Resample_Good::Read( char *bufp, unsigned len )
|
||||
*(pBufOut++) = (float) pBufIn[i];
|
||||
}
|
||||
|
||||
int iGotFrames = resamplers[iChannel]->Run( pFloatBuf, iFramesIn, pFloatOut, iFrames );
|
||||
int iGotFrames = m_apResamplers[iChannel]->Run( pFloatBuf, iFramesIn, pFloatOut, iFrames );
|
||||
ASSERT( iGotFrames <= iFrames );
|
||||
|
||||
int16_t *pBufOut = pBuf + iChannel;
|
||||
@@ -624,8 +624,8 @@ RageSoundReader_Resample_Good *RageSoundReader_Resample_Good::Copy() const
|
||||
SoundReader *pSource = m_pSource->Copy();
|
||||
RageSoundReader_Resample_Good *ret = new RageSoundReader_Resample_Good;
|
||||
|
||||
for( size_t i = 0; i < resamplers.size(); ++i )
|
||||
ret->resamplers.push_back( new RageSoundResampler_Polyphase(*resamplers[i]) );
|
||||
for( size_t i = 0; i < m_apResamplers.size(); ++i )
|
||||
ret->m_apResamplers.push_back( new RageSoundResampler_Polyphase(*m_apResamplers[i]) );
|
||||
ret->m_pSource = pSource;
|
||||
ret->m_iSampleRate = m_iSampleRate;
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ class RageSoundReader_Resample_Good: public RageSoundReader_Resample
|
||||
{
|
||||
public:
|
||||
/* We own source. */
|
||||
void Open(SoundReader *source);
|
||||
void Open( SoundReader *pSource );
|
||||
int GetLength() const;
|
||||
int GetLength_Fast() const;
|
||||
int SetPosition_Accurate(int ms);
|
||||
int SetPosition_Fast(int ms);
|
||||
int Read(char *buf, unsigned len);
|
||||
int SetPosition_Accurate( int iMS );
|
||||
int SetPosition_Fast( int iMS );
|
||||
int Read( char *pBuf, unsigned iLen );
|
||||
RageSoundReader_Resample_Good();
|
||||
virtual ~RageSoundReader_Resample_Good();
|
||||
RageSoundReader_Resample_Good *Copy() const;
|
||||
|
||||
/* Change the actual sample rate of a sound. */
|
||||
void SetSampleRate( int hz );
|
||||
void SetHighQuality( bool hq ) { }
|
||||
void SetSampleRate( int iHZ );
|
||||
void SetHighQuality( bool bHQ ) { }
|
||||
|
||||
int GetSampleRate() const { return m_iSampleRate; }
|
||||
unsigned GetNumChannels() const { return m_pSource->GetNumChannels(); }
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
void Reset();
|
||||
void ReopenResampler();
|
||||
|
||||
vector<RageSoundResampler_Polyphase *> resamplers; /* one per channel */
|
||||
vector<RageSoundResampler_Polyphase *> m_apResamplers; /* one per channel */
|
||||
|
||||
SoundReader *m_pSource;
|
||||
int m_iSampleRate;
|
||||
|
||||
Reference in New Issue
Block a user