@ -188,6 +188,7 @@ public:
virtual void stop ( ) ;
virtual void stop ( ) ;
virtual bool isPlaying ( ) ;
virtual bool isPlaying ( ) ;
virtual double getTimeOffset ( ) ;
virtual double getTimeOffset ( ) ;
virtual double getStreamDelay ( ) const ;
virtual void applyUpdates ( ) ;
virtual void applyUpdates ( ) ;
void play ( ) ;
void play ( ) ;
@ -395,6 +396,26 @@ double OpenAL_SoundStream::getTimeOffset()
return t ;
return t ;
}
}
double OpenAL_SoundStream : : getStreamDelay ( ) const
{
ALint state = AL_STOPPED ;
double d = 0.0 ;
ALint offset ;
alGetSourcei ( mSource , AL_SAMPLE_OFFSET , & offset ) ;
alGetSourcei ( mSource , AL_SOURCE_STATE , & state ) ;
if ( state = = AL_PLAYING | | state = = AL_PAUSED )
{
ALint queued ;
alGetSourcei ( mSource , AL_BUFFERS_QUEUED , & queued ) ;
ALint inqueue = mBufferSize / mFrameSize * queued - offset ;
d = ( double ) inqueue / ( double ) mSampleRate ;
}
throwALerror ( ) ;
return d ;
}
void OpenAL_SoundStream : : updateAll ( bool local )
void OpenAL_SoundStream : : updateAll ( bool local )
{
{
alSourcef ( mSource , AL_REFERENCE_DISTANCE , mMinDistance ) ;
alSourcef ( mSource , AL_REFERENCE_DISTANCE , mMinDistance ) ;