mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 12:50:53 +00:00
Changed: #1030 Implemented getTime() in OpenAL driver
This commit is contained in:
parent
504ce10745
commit
334f579446
4 changed files with 17 additions and 7 deletions
|
@ -26,8 +26,8 @@
|
|||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace NLSOUND {
|
||||
|
||||
namespace NLSOUND
|
||||
{
|
||||
|
||||
// Currently, the OpenAL headers are different between Windows and Linux versions !
|
||||
// AL_INVALID_XXXX are part of the spec, though.
|
||||
|
@ -80,7 +80,8 @@ void alTestWarning(const char *src)
|
|||
|
||||
#ifndef NL_STATIC
|
||||
|
||||
class CSoundDriverALNelLibrary : public NLMISC::INelLibrary {
|
||||
class CSoundDriverALNelLibrary : public NLMISC::INelLibrary
|
||||
{
|
||||
void onLibraryLoaded(bool /* firstTime */) { }
|
||||
void onLibraryUnloaded(bool /* lastTime */) { }
|
||||
};
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
#include <nel/sound/driver/sound_driver.h>
|
||||
|
||||
namespace NLSOUND {
|
||||
namespace NLSOUND
|
||||
{
|
||||
class CBufferAL;
|
||||
class CListenerAL;
|
||||
class CSourceAL;
|
||||
|
|
|
@ -33,6 +33,7 @@ CSourceAL::CSourceAL(CSoundDriverAL *soundDriver):ISource(), _SoundDriver(NULL),
|
|||
{
|
||||
_IsPlaying = false;
|
||||
_IsPaused = false;
|
||||
_StartTime = 0;
|
||||
|
||||
_Type = SourceSound;
|
||||
_Buffer = NULL;
|
||||
|
@ -253,6 +254,8 @@ bool CSourceAL::play()
|
|||
_IsPaused = false;
|
||||
alSourcePlay(_Source);
|
||||
_IsPlaying = alGetError() == AL_NO_ERROR;
|
||||
if (_IsPlaying)
|
||||
_StartTime = CTime::getLocalTime();
|
||||
return _IsPlaying;
|
||||
}
|
||||
else
|
||||
|
@ -261,6 +264,7 @@ bool CSourceAL::play()
|
|||
_IsPaused = false;
|
||||
alSourcePlay(_Source);
|
||||
_IsPlaying = true;
|
||||
_StartTime = CTime::getLocalTime();
|
||||
return true;
|
||||
// Streaming mode
|
||||
//nlwarning("AL: Cannot play null buffer; streaming not implemented" );
|
||||
|
@ -271,6 +275,8 @@ bool CSourceAL::play()
|
|||
/// Stop playing
|
||||
void CSourceAL::stop()
|
||||
{
|
||||
_StartTime = 0;
|
||||
|
||||
if ( _Buffer != NULL )
|
||||
{
|
||||
// Static playing mode
|
||||
|
@ -376,8 +382,9 @@ bool CSourceAL::isPaused() const
|
|||
/// Returns the number of milliseconds the source has been playing
|
||||
uint32 CSourceAL::getTime()
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
if (!_StartTime) return 0;
|
||||
|
||||
return (uint32)(CTime::getLocalTime() - _StartTime);
|
||||
}
|
||||
|
||||
/// Set the position vector.
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
/// Playing status
|
||||
bool _IsPlaying;
|
||||
bool _IsPaused;
|
||||
NLMISC::TTime _StartTime;
|
||||
NLMISC::CVector _Pos;
|
||||
float _Gain;
|
||||
double _Alpha;
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
void release();
|
||||
|
||||
/// Return the OpenAL source name
|
||||
inline ALuint getSource() const { return _Source; }
|
||||
ALuint getSource() const { return _Source; }
|
||||
|
||||
/// Set type of the source
|
||||
void setType(TSourceType type);
|
||||
|
|
Loading…
Reference in a new issue