diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.cpp b/code/nel/src/sound/driver/openal/sound_driver_al.cpp index f6ec2e537..e94755c63 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.cpp +++ b/code/nel/src/sound/driver/openal/sound_driver_al.cpp @@ -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 */) { } }; diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.h b/code/nel/src/sound/driver/openal/sound_driver_al.h index a781d3216..50bffa379 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.h +++ b/code/nel/src/sound/driver/openal/sound_driver_al.h @@ -19,7 +19,8 @@ #include -namespace NLSOUND { +namespace NLSOUND +{ class CBufferAL; class CListenerAL; class CSourceAL; diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index d565e0438..6ff531d56 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -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. diff --git a/code/nel/src/sound/driver/openal/source_al.h b/code/nel/src/sound/driver/openal/source_al.h index 6fcfa288d..b5611b997 100644 --- a/code/nel/src/sound/driver/openal/source_al.h +++ b/code/nel/src/sound/driver/openal/source_al.h @@ -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);