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