GetDataToPlay API more like RSR::Read

This commit is contained in:
Glenn Maynard
2006-12-22 21:24:19 +00:00
parent 1b18090e90
commit 24624a5c92
3 changed files with 9 additions and 8 deletions
+4 -4
View File
@@ -366,7 +366,7 @@ int RageSound::GetData( char *pBuffer, int iFrames )
*
* If no data is returned (we're at the end of the stream), return false.
*/
bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFrame, int &iFramesStored )
int RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFrame, int &iFramesStored )
{
int iNumRewindsThisCall = 0;
@@ -390,7 +390,7 @@ bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFr
{
case RageSoundParams::M_STOP:
/* Not looping. Normally, we'll just stop here. */
return false;
return RageSoundReader::END_OF_FILE;
case RageSoundParams::M_LOOP:
/* Rewind and restart. */
@@ -405,7 +405,7 @@ bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFr
LOG->Warn( "Sound %s is busy looping. Sound stopped (start = %f, length = %f)",
GetLoadedFilePath().c_str(), m_Param.m_StartSecond, m_Param.m_LengthSeconds );
return false;
return RageSoundReader::END_OF_FILE;
}
/* Rewind and start over. XXX: this will take an exclusive lock */
@@ -425,7 +425,7 @@ bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFr
iFrames -= iGotFrames;
pBuffer += iGotFrames * channels;
}
return true;
return iFramesStored;
}
/* Indicate that a block of audio data has been written to the device. */
+2 -2
View File
@@ -16,7 +16,7 @@ class RageSoundBase
public:
virtual ~RageSoundBase() { }
virtual void SoundIsFinishedPlaying() = 0;
virtual bool GetDataToPlay( int16_t *buffer, int size, int64_t &iStreamFrame, int &got_bytes ) = 0;
virtual int GetDataToPlay( int16_t *buffer, int size, int64_t &iStreamFrame, int &got_bytes ) = 0;
virtual int GetSampleRate() const = 0;
virtual RageTimer GetStartTime() const { return RageZeroTimer; }
virtual float GetAbsoluteVolume() const = 0;
@@ -201,7 +201,7 @@ public:
* signals the stream to stop; once it's flushed, SoundStopped will be called.
* Until then, SOUNDMAN->GetPosition can still be called; the sound is still
* playing. */
bool GetDataToPlay( int16_t *pBuffer, int iSize, int64_t &iStreamFrame, int &iBytesRead );
int GetDataToPlay( int16_t *pBuffer, int iSize, int64_t &iStreamFrame, int &iBytesRead );
void CommitPlayingPosition( int64_t iFrameno, int64_t iPosition, int iBytesRead );
};
@@ -6,6 +6,7 @@
#include "RageUtil.h"
#include "RageSoundManager.h"
#include "RageSoundMixBuffer.h"
#include "RageSoundReader.h"
static const int channels = 2;
static const int bytes_per_frame = channels*2; /* 16-bit */
@@ -233,7 +234,7 @@ void RageSound_Generic_Software::DecodeThread()
}
int iWrote = GetDataForSound( *pSound );
if( !iWrote )
if( iWrote == RageSoundReader::END_OF_FILE )
{
/* This sound is finishing. */
pSound->m_State = Sound::STOPPING;
@@ -375,7 +376,7 @@ void RageSound_Generic_Software::StartMixing( RageSoundBase *pSound )
// LOG->Trace("StartMixing: (#%i) buffering %i (%i writable) (%p)", i, (int) frames_to_buffer, s.buffer.num_writable(), s.m_pSound );
int iWrote = GetDataForSound( s );
iFramesFilled += iWrote;
if( !iWrote )
if( iWrote < 0 )
{
// LOG->Trace("StartMixing: XXX hit EOF (%p)", s.m_pSound );
break;