GetNextStreamFrame implementations
This commit is contained in:
@@ -998,6 +998,14 @@ int RageSoundReader_MP3::SetPosition_Fast( int ms )
|
|||||||
return SetPosition_estimate( ms );
|
return SetPosition_estimate( ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: untested
|
||||||
|
int RageSoundReader_MP3::GetNextStreamFrame() const
|
||||||
|
{
|
||||||
|
mad_timer_t now( mad->Timer );
|
||||||
|
mad_timer_multiply( &now, mad->Frame.header.samplerate );
|
||||||
|
return now.seconds;
|
||||||
|
}
|
||||||
|
|
||||||
int RageSoundReader_MP3::GetLengthInternal( bool fast )
|
int RageSoundReader_MP3::GetLengthInternal( bool fast )
|
||||||
{
|
{
|
||||||
if( mad->has_xing && mad->length != -1 )
|
if( mad->has_xing && mad->length != -1 )
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
int SetPosition_Fast(int ms);
|
int SetPosition_Fast(int ms);
|
||||||
int Read(char *buf, unsigned len);
|
int Read(char *buf, unsigned len);
|
||||||
int GetSampleRate() const { return SampleRate; }
|
int GetSampleRate() const { return SampleRate; }
|
||||||
|
int GetNextStreamFrame() const;
|
||||||
|
|
||||||
RageSoundReader_MP3();
|
RageSoundReader_MP3();
|
||||||
~RageSoundReader_MP3();
|
~RageSoundReader_MP3();
|
||||||
|
|||||||
@@ -255,6 +255,14 @@ int RageSoundReader_Vorbisfile::GetSampleRate() const
|
|||||||
return vi->rate;
|
return vi->rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RageSoundReader_Vorbisfile::GetNextStreamFrame() const
|
||||||
|
{
|
||||||
|
ASSERT(vf);
|
||||||
|
|
||||||
|
int iFrame = ov_pcm_tell( vf );
|
||||||
|
return iFrame;
|
||||||
|
}
|
||||||
|
|
||||||
RageSoundReader_Vorbisfile::RageSoundReader_Vorbisfile()
|
RageSoundReader_Vorbisfile::RageSoundReader_Vorbisfile()
|
||||||
{
|
{
|
||||||
vf = NULL;
|
vf = NULL;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
int Read(char *buf, unsigned len);
|
int Read(char *buf, unsigned len);
|
||||||
int GetSampleRate() const;
|
int GetSampleRate() const;
|
||||||
unsigned GetNumChannels() const { return channels; }
|
unsigned GetNumChannels() const { return channels; }
|
||||||
|
int GetNextStreamFrame() const;
|
||||||
RageSoundReader_Vorbisfile();
|
RageSoundReader_Vorbisfile();
|
||||||
~RageSoundReader_Vorbisfile();
|
~RageSoundReader_Vorbisfile();
|
||||||
RageSoundReader_Vorbisfile *Copy() const;
|
RageSoundReader_Vorbisfile *Copy() const;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ struct WavReader
|
|||||||
virtual int GetLength() const = 0;
|
virtual int GetLength() const = 0;
|
||||||
virtual bool Init() = 0;
|
virtual bool Init() = 0;
|
||||||
virtual int SetPosition( int iMS ) = 0;
|
virtual int SetPosition( int iMS ) = 0;
|
||||||
|
virtual int GetNextStreamFrame() const = 0;
|
||||||
RString GetError() const { return m_sError; }
|
RString GetError() const { return m_sError; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -115,6 +116,14 @@ struct WavReaderPCM: public WavReader
|
|||||||
m_File.Seek( iByte+m_WavData.m_iDataChunkPos );
|
m_File.Seek( iByte+m_WavData.m_iDataChunkPos );
|
||||||
return int((int64_t(iByte) * 1000) / iBytesPerSec);
|
return int((int64_t(iByte) * 1000) / iBytesPerSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: untested
|
||||||
|
int GetNextStreamFrame() const
|
||||||
|
{
|
||||||
|
int iByte = m_File.Tell() - m_WavData.m_iDataChunkPos;
|
||||||
|
int iFrame = iByte / (m_WavData.m_iChannels * m_WavData.m_iBitsPerSample / 8);
|
||||||
|
return iFrame;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WavReaderADPCM: public WavReader
|
struct WavReaderADPCM: public WavReader
|
||||||
@@ -352,6 +361,20 @@ public:
|
|||||||
|
|
||||||
return iMS;
|
return iMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: untested
|
||||||
|
int GetNextStreamFrame() const
|
||||||
|
{
|
||||||
|
int iByte = m_File.Tell() - m_WavData.m_iDataChunkPos;
|
||||||
|
int iBlock = iByte / m_WavData.m_iBlockAlign;
|
||||||
|
int iFrame = iBlock * m_iFramesPerBlock;
|
||||||
|
|
||||||
|
int iBufferRemainingBytes = m_iBufferAvail - m_iBufferUsed;
|
||||||
|
int iBufferRemainingFrames = iBufferRemainingBytes / (m_WavData.m_iChannels * sizeof(int16_t));
|
||||||
|
iFrame -= iBufferRemainingFrames;
|
||||||
|
|
||||||
|
return iFrame;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RString ReadString( RageFile &f, int iSize, RString &sError )
|
RString ReadString( RageFile &f, int iSize, RString &sError )
|
||||||
@@ -500,6 +523,12 @@ int RageSoundReader_WAV::SetPosition( int ms )
|
|||||||
return m_pImpl->SetPosition( ms );
|
return m_pImpl->SetPosition( ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RageSoundReader_WAV::GetNextStreamFrame() const
|
||||||
|
{
|
||||||
|
ASSERT( m_pImpl != NULL );
|
||||||
|
return m_pImpl->GetNextStreamFrame();
|
||||||
|
}
|
||||||
|
|
||||||
int RageSoundReader_WAV::Read( char *buf, unsigned len )
|
int RageSoundReader_WAV::Read( char *buf, unsigned len )
|
||||||
{
|
{
|
||||||
ASSERT( m_pImpl != NULL );
|
ASSERT( m_pImpl != NULL );
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
int Read( char *buf, unsigned len );
|
int Read( char *buf, unsigned len );
|
||||||
int GetSampleRate() const { return m_WavData.m_iSampleRate; }
|
int GetSampleRate() const { return m_WavData.m_iSampleRate; }
|
||||||
unsigned GetNumChannels() const { return m_WavData.m_iChannels; }
|
unsigned GetNumChannels() const { return m_WavData.m_iChannels; }
|
||||||
|
int GetNextStreamFrame() const;
|
||||||
RageSoundReader_WAV();
|
RageSoundReader_WAV();
|
||||||
~RageSoundReader_WAV();
|
~RageSoundReader_WAV();
|
||||||
RageSoundReader_WAV( const RageSoundReader_WAV & ); /* not defined; don't use */
|
RageSoundReader_WAV( const RageSoundReader_WAV & ); /* not defined; don't use */
|
||||||
|
|||||||
Reference in New Issue
Block a user