diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 09b394c32..d5d6877a2 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -88,7 +88,7 @@ SFXManager::SFXManager() // The sound manager initialises OpenAL m_initialized = music_manager->initialized(); m_master_gain = UserConfigParams::m_sfx_volume; - m_last_update_time = -1.0f; + m_last_update_time = -1; // Init position, since it can be used before positionListener is called. // No need to use lock here, since the thread will be created later. m_listener_position.getData() = Vec3(0, 0, 0); @@ -477,10 +477,10 @@ void* SFXManager::mainLoop(void *obj) { // Wait some time to let other threads run, then queue an // update event to keep music playing. - double t = StkTime::getRealTime(); + uint64_t t = StkTime::getRealTimeMs(); StkTime::sleep(1); - t = StkTime::getRealTime() - t; - me->queue(SFX_UPDATE, (SFXBase*)NULL, float(t)); + t = StkTime::getRealTimeMs() - t; + me->queue(SFX_UPDATE, (SFXBase*)NULL, float(t / 1000.0)); } me->m_sfx_commands.lock(); PROFILER_POP_CPU_MARKER(); @@ -834,15 +834,15 @@ void SFXManager::reallyUpdateNow(SFXCommand *current) if (!UserConfigParams::m_enable_sound) return; - if (m_last_update_time < 0.0) + if (m_last_update_time < 0) { // first time - m_last_update_time = StkTime::getRealTime(); + m_last_update_time = StkTime::getRealTimeMs(); } - double previous_update_time = m_last_update_time; - m_last_update_time = StkTime::getRealTime(); - float dt = float(m_last_update_time - previous_update_time); + uint64_t previous_update_time = m_last_update_time; + m_last_update_time = StkTime::getRealTimeMs(); + float dt = float(m_last_update_time - previous_update_time) / 1000.0f; assert(current->m_command==SFX_UPDATE); if (music_manager->getCurrentMusic()) diff --git a/src/audio/sfx_manager.hpp b/src/audio/sfx_manager.hpp index 5c8722c57..a577c3d91 100644 --- a/src/audio/sfx_manager.hpp +++ b/src/audio/sfx_manager.hpp @@ -218,7 +218,7 @@ private: /** Thread id of the thread running in this object. */ Synchronised m_thread_id; - double m_last_update_time; + uint64_t m_last_update_time; /** A conditional variable to wake up the main loop. */ pthread_cond_t m_cond_request; diff --git a/src/input/multitouch_device.cpp b/src/input/multitouch_device.cpp index 54a5c8c67..18b4b3996 100644 --- a/src/input/multitouch_device.cpp +++ b/src/input/multitouch_device.cpp @@ -173,7 +173,7 @@ void MultitouchDevice::reset() } m_orientation = 0.0f; - m_gyro_time = 0.0; + m_gyro_time = 0; } // reset // ---------------------------------------------------------------------------- @@ -498,9 +498,10 @@ void MultitouchDevice::updateOrientationFromGyroscope(float z) { const float GYRO_SPEED_THRESHOLD = 0.005f; - double now = StkTime::getRealTime(); - float timedelta = now - m_gyro_time; + uint64_t now = StkTime::getRealTimeMs(); + uint64_t delta = now - m_gyro_time; m_gyro_time = now; + float timedelta = (float)delta / 1000.f; if (timedelta > 0.5f) { timedelta = 0.1f; diff --git a/src/input/multitouch_device.hpp b/src/input/multitouch_device.hpp index b92064b01..b62d1e087 100644 --- a/src/input/multitouch_device.hpp +++ b/src/input/multitouch_device.hpp @@ -23,6 +23,7 @@ #include #include "input/input_device.hpp" +#include "utils/types.hpp" #include "IEventReceiver.h" #ifdef ANDROID @@ -90,7 +91,7 @@ private: float m_sensitivity_y; float m_orientation; - double m_gyro_time; + uint64_t m_gyro_time; #ifdef ANDROID /** Pointer to the Android irrlicht device */