RageSoundReader::Read() returns sound data which may be at a

different rate than the source it's reading from; one second
of returned data may correspond to two seconds in the source
material.

GetStreamToSourceRatio returns the ratio of returned data in
the next Read() call to source data.  This is propagated
upwards in the filter tree, so rate changes by a speed changer
in the middle of the tree will be reflected in the final
GetStreamToSourceRatio().

This means that whenever the ratio changes, Read() stops
returning data; it returns whatever it has, so the caller
has an opportunity to call GetStreamToSourceRatio again
and notice the change.

These semantics can be annoying to implement in some
cases, where only the processing of Read() may notice
a ratio change.  Read() may want to return 0, to say
"something changed, call GetStreamToSourceRatio again",
but 0 means EOF.

Add RageSoundReader::END_OF_FILE.  0 is now no
longer a special case; it means "there's more data, I
just didn't return any this time".  This is functionally
equivalent to errno EINTR.
This commit is contained in:
Glenn Maynard
2006-12-10 07:08:17 +00:00
parent 2f1782d892
commit 0b529a4960
11 changed files with 91 additions and 46 deletions
@@ -126,6 +126,8 @@ int RageSoundReader_Preload::Read( char *pBuffer, int iFrames )
const int iFramesAvail = iSizeFrames - m_iPosition;
iFrames = min( iFrames, iFramesAvail );
if( iFrames == 0 )
return END_OF_FILE;
memcpy( pBuffer, m_Buffer->data() + (m_iPosition * samplesize), iFrames * samplesize );
m_iPosition += iFrames;