Make GetLength and GetLength_Fast really const
This commit is contained in:
@@ -904,12 +904,8 @@ int RageSoundReader_MP3::SetPosition_Fast( int ms )
|
|||||||
return SetPosition_estimate( ms );
|
return SetPosition_estimate( ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: This should be const, but there doesn't appear to be a way to copy MAD's
|
|
||||||
* internal structures, so we can scan length without moving the stream around. */
|
|
||||||
int RageSoundReader_MP3::GetLengthInternal( bool fast )
|
int RageSoundReader_MP3::GetLengthInternal( bool fast )
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
if( mad->has_xing && mad->length != -1 )
|
if( mad->has_xing && mad->length != -1 )
|
||||||
return mad->length; /* should be accurate */
|
return mad->length; /* should be accurate */
|
||||||
|
|
||||||
@@ -947,10 +943,19 @@ int RageSoundReader_MP3::GetLengthInternal( bool fast )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Count milliseconds. */
|
/* Count milliseconds. */
|
||||||
ret = mad_timer_count( mad->Timer, MAD_UNITS_MILLISECONDS );
|
return mad_timer_count( mad->Timer, MAD_UNITS_MILLISECONDS );
|
||||||
|
}
|
||||||
|
|
||||||
MADLIB_rewind();
|
int RageSoundReader_MP3::GetLengthConst( bool fast ) const
|
||||||
return ret;
|
{
|
||||||
|
RageSoundReader_MP3 *cpy = new RageSoundReader_MP3;
|
||||||
|
SoundReader_FileReader::OpenResult ret = cpy->Open( filename );
|
||||||
|
ASSERT( ret == OPEN_OK );
|
||||||
|
|
||||||
|
int length = cpy->GetLengthInternal( fast );
|
||||||
|
|
||||||
|
delete cpy;
|
||||||
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundReader *RageSoundReader_MP3::Copy() const
|
SoundReader *RageSoundReader_MP3::Copy() const
|
||||||
|
|||||||
@@ -29,12 +29,13 @@ public:
|
|||||||
int seek_stream_to_byte( int byte );
|
int seek_stream_to_byte( int byte );
|
||||||
int handle_first_frame();
|
int handle_first_frame();
|
||||||
int GetLengthInternal( bool fast );
|
int GetLengthInternal( bool fast );
|
||||||
|
int GetLengthConst( bool fast ) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OpenResult Open(CString filename);
|
OpenResult Open(CString filename);
|
||||||
void Close();
|
void Close();
|
||||||
int GetLength() const { return ((RageSoundReader_MP3*)this)->GetLengthInternal(false); }
|
int GetLength() const { return GetLengthConst(false); }
|
||||||
int GetLength_Fast() const { return ((RageSoundReader_MP3*)this)->GetLengthInternal(true); }
|
int GetLength_Fast() const { return GetLengthConst(true); }
|
||||||
int SetPosition_Accurate(int ms);
|
int SetPosition_Accurate(int ms);
|
||||||
int SetPosition_Fast(int ms);
|
int SetPosition_Fast(int ms);
|
||||||
int Read(char *buf, unsigned len);
|
int Read(char *buf, unsigned len);
|
||||||
|
|||||||
Reference in New Issue
Block a user