GetDataToPlay API more like RSR::Read
This commit is contained in:
@@ -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.
|
* 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;
|
int iNumRewindsThisCall = 0;
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ bool RageSound::GetDataToPlay( int16_t *pBuffer, int iFrames, int64_t &iStreamFr
|
|||||||
{
|
{
|
||||||
case RageSoundParams::M_STOP:
|
case RageSoundParams::M_STOP:
|
||||||
/* Not looping. Normally, we'll just stop here. */
|
/* Not looping. Normally, we'll just stop here. */
|
||||||
return false;
|
return RageSoundReader::END_OF_FILE;
|
||||||
|
|
||||||
case RageSoundParams::M_LOOP:
|
case RageSoundParams::M_LOOP:
|
||||||
/* Rewind and restart. */
|
/* 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)",
|
LOG->Warn( "Sound %s is busy looping. Sound stopped (start = %f, length = %f)",
|
||||||
GetLoadedFilePath().c_str(), m_Param.m_StartSecond, m_Param.m_LengthSeconds );
|
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 */
|
/* 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;
|
iFrames -= iGotFrames;
|
||||||
pBuffer += iGotFrames * channels;
|
pBuffer += iGotFrames * channels;
|
||||||
}
|
}
|
||||||
return true;
|
return iFramesStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indicate that a block of audio data has been written to the device. */
|
/* Indicate that a block of audio data has been written to the device. */
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class RageSoundBase
|
|||||||
public:
|
public:
|
||||||
virtual ~RageSoundBase() { }
|
virtual ~RageSoundBase() { }
|
||||||
virtual void SoundIsFinishedPlaying() = 0;
|
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 int GetSampleRate() const = 0;
|
||||||
virtual RageTimer GetStartTime() const { return RageZeroTimer; }
|
virtual RageTimer GetStartTime() const { return RageZeroTimer; }
|
||||||
virtual float GetAbsoluteVolume() const = 0;
|
virtual float GetAbsoluteVolume() const = 0;
|
||||||
@@ -201,7 +201,7 @@ public:
|
|||||||
* signals the stream to stop; once it's flushed, SoundStopped will be called.
|
* 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
|
* Until then, SOUNDMAN->GetPosition can still be called; the sound is still
|
||||||
* playing. */
|
* 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 );
|
void CommitPlayingPosition( int64_t iFrameno, int64_t iPosition, int iBytesRead );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageSoundManager.h"
|
#include "RageSoundManager.h"
|
||||||
#include "RageSoundMixBuffer.h"
|
#include "RageSoundMixBuffer.h"
|
||||||
|
#include "RageSoundReader.h"
|
||||||
|
|
||||||
static const int channels = 2;
|
static const int channels = 2;
|
||||||
static const int bytes_per_frame = channels*2; /* 16-bit */
|
static const int bytes_per_frame = channels*2; /* 16-bit */
|
||||||
@@ -233,7 +234,7 @@ void RageSound_Generic_Software::DecodeThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int iWrote = GetDataForSound( *pSound );
|
int iWrote = GetDataForSound( *pSound );
|
||||||
if( !iWrote )
|
if( iWrote == RageSoundReader::END_OF_FILE )
|
||||||
{
|
{
|
||||||
/* This sound is finishing. */
|
/* This sound is finishing. */
|
||||||
pSound->m_State = Sound::STOPPING;
|
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 );
|
// 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 );
|
int iWrote = GetDataForSound( s );
|
||||||
iFramesFilled += iWrote;
|
iFramesFilled += iWrote;
|
||||||
if( !iWrote )
|
if( iWrote < 0 )
|
||||||
{
|
{
|
||||||
// LOG->Trace("StartMixing: XXX hit EOF (%p)", s.m_pSound );
|
// LOG->Trace("StartMixing: XXX hit EOF (%p)", s.m_pSound );
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user