Return 1 from SetPosition(n) on success, 0 on seek past EOF, not
"the position seeked to". This fixes a special case: SetPosition(n) returning 0 was EOF except when SetPosition(0). The returned value on success was always n, anyway; we never seek to a different position and return success.
This commit is contained in:
@@ -152,7 +152,7 @@ class RageSoundReader_Silence: public RageSoundReader
|
||||
public:
|
||||
int GetLength() const { return 0; }
|
||||
int GetLength_Fast() const { return 0; }
|
||||
int SetPosition( int iFrame ) { return 0; }
|
||||
int SetPosition( int iFrame ) { return 1; }
|
||||
int Read( char *buf, int iFrames ) { return 0; }
|
||||
RageSoundReader *Copy() const { return new RageSoundReader_Silence; }
|
||||
int GetSampleRate() const { return 44100; }
|
||||
@@ -754,10 +754,9 @@ bool RageSound::SetPositionFrames( int iFrames )
|
||||
m_iStoppedSourceFrame = iFrames;
|
||||
}
|
||||
|
||||
if( iRet == 0 && iFrames != 0 )
|
||||
if( iRet == 0 )
|
||||
{
|
||||
/* We were told to seek somewhere, and we got 0 instead, which means
|
||||
* we passed EOF. This could be a truncated file or invalid data. */
|
||||
/* Seeked past EOF. */
|
||||
LOG->Warn( "SetPositionFrames: %i samples is beyond EOF in %s",
|
||||
iFrames, GetLoadedFilePath().c_str() );
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ int RageSoundReader_Chain::SetPosition( int iFrame )
|
||||
RageSoundReader *pReader = pSound->pSound;
|
||||
|
||||
int iOffsetFrames = iFrame - iOffsetFrame;
|
||||
if( iOffsetFrames > 0 && pReader->SetPosition(iOffsetFrames) == 0 )
|
||||
if( pReader->SetPosition(iOffsetFrames) == 0 )
|
||||
{
|
||||
/* We're past the end of this sound. */
|
||||
ReleaseSound( pSound );
|
||||
|
||||
@@ -854,13 +854,13 @@ int RageSoundReader_MP3::SetPosition_toc( int iFrame, bool Xing )
|
||||
mad_timer_set( &desired, 0, iFrame, SampleRate );
|
||||
|
||||
if( mad->tocmap.empty() )
|
||||
return iFrame; /* don't have any info */
|
||||
return 1; /* don't have any info */
|
||||
|
||||
/* Find the last entry <= iFrame that we actually have an entry for;
|
||||
* this will get us as close as possible. */
|
||||
madlib_t::tocmap_t::iterator it = mad->tocmap.upper_bound( desired );
|
||||
if( it == mad->tocmap.begin() )
|
||||
return iFrame; /* don't have any info */
|
||||
return 1; /* don't have any info */
|
||||
--it;
|
||||
|
||||
mad->Timer = it->first;
|
||||
@@ -882,7 +882,7 @@ int RageSoundReader_MP3::SetPosition_toc( int iFrame, bool Xing )
|
||||
synth_output();
|
||||
}
|
||||
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RageSoundReader_MP3::SetPosition_hard( int iFrame )
|
||||
@@ -894,7 +894,7 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame )
|
||||
|
||||
/* If we're already exactly at the requested position, OK. */
|
||||
if( mad_timer_compare(mad->Timer, desired) == 0 )
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
/* We always come in here with data synthed. Be careful not to synth the
|
||||
* same frame twice. */
|
||||
@@ -939,7 +939,7 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame )
|
||||
* we're currently always using AUDIO_S16SYS. */
|
||||
mad->outpos = samples * 2 * this->Channels;
|
||||
mad->outleft -= samples * 2 * this->Channels;
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Otherwise, if the desired time will be in the *next* decode, then synth
|
||||
@@ -1003,7 +1003,7 @@ int RageSoundReader_MP3::SetPosition_estimate( int iFrame )
|
||||
int ms = (get_this_frame_byte(mad) - mad->header_bytes) / (mad->bitrate / 8 / 1000);
|
||||
mad_timer_set(&mad->Timer, 0, ms, 1000);
|
||||
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RageSoundReader_MP3::SetPosition( int iFrame )
|
||||
@@ -1024,7 +1024,7 @@ int RageSoundReader_MP3::SetPosition( int iFrame )
|
||||
if( !iFrame )
|
||||
{
|
||||
MADLIB_rewind();
|
||||
return 0; /* ok */
|
||||
return 1; /* ok */
|
||||
}
|
||||
|
||||
/* We can do a fast jump in VBR with Xing with more accuracy than without Xing. */
|
||||
|
||||
@@ -679,9 +679,7 @@ int RageSoundReader_Resample_Good::SetPosition( int iFrame )
|
||||
{
|
||||
Reset();
|
||||
iFrame = (int) SCALE( iFrame, 0, (int64_t) m_iSampleRate, 0, (int64_t) m_pSource->GetSampleRate() );
|
||||
iFrame = m_pSource->SetPosition( iFrame );
|
||||
iFrame = (int) SCALE( iFrame, 0, (int64_t) m_pSource->GetSampleRate(), 0, (int64_t) m_iSampleRate );
|
||||
return iFrame;
|
||||
return m_pSource->SetPosition( iFrame );
|
||||
}
|
||||
|
||||
int RageSoundReader_Resample_Good::Read( char *pBuf_, int iFrames )
|
||||
|
||||
@@ -157,7 +157,7 @@ int RageSoundReader_Vorbisfile::SetPosition( int iFrame )
|
||||
}
|
||||
read_offset = (int) ov_pcm_tell(vf);
|
||||
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RageSoundReader_Vorbisfile::Read( char *buf, int iFrames )
|
||||
|
||||
@@ -116,7 +116,7 @@ struct WavReaderPCM: public WavReader
|
||||
}
|
||||
|
||||
m_File.Seek( iByte+m_WavData.m_iDataChunkPos );
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return iFrame;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
|
||||
Reference in New Issue
Block a user