Fixes #45025 - Protects _last_mix_time and _last_frame_time with the AudioDriver lock() and unlock() methods
(cherry picked from commit 17ac012728
)
This commit is contained in:
parent
58f038d1fa
commit
2ed700d2da
2 changed files with 14 additions and 9 deletions
|
@ -71,15 +71,20 @@ void AudioDriver::update_mix_time(int p_frames) {
|
||||||
_last_mix_time = OS::get_singleton()->get_ticks_usec();
|
_last_mix_time = OS::get_singleton()->get_ticks_usec();
|
||||||
}
|
}
|
||||||
|
|
||||||
double AudioDriver::get_time_since_last_mix() const {
|
double AudioDriver::get_time_since_last_mix() {
|
||||||
|
lock();
|
||||||
return (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
|
uint64_t last_mix_time = _last_mix_time;
|
||||||
|
unlock();
|
||||||
|
return (OS::get_singleton()->get_ticks_usec() - last_mix_time) / 1000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double AudioDriver::get_time_to_next_mix() const {
|
double AudioDriver::get_time_to_next_mix() {
|
||||||
|
lock();
|
||||||
double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
|
uint64_t last_mix_time = _last_mix_time;
|
||||||
double mix_buffer = _last_mix_frames / (double)get_mix_rate();
|
uint64_t last_mix_frames = _last_mix_frames;
|
||||||
|
unlock();
|
||||||
|
double total = (OS::get_singleton()->get_ticks_usec() - last_mix_time) / 1000000.0;
|
||||||
|
double mix_buffer = last_mix_frames / (double)get_mix_rate();
|
||||||
return mix_buffer - total;
|
return mix_buffer - total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double get_time_since_last_mix() const; //useful for video -> audio sync
|
double get_time_since_last_mix(); //useful for video -> audio sync
|
||||||
double get_time_to_next_mix() const;
|
double get_time_to_next_mix();
|
||||||
|
|
||||||
enum SpeakerMode {
|
enum SpeakerMode {
|
||||||
SPEAKER_MODE_STEREO,
|
SPEAKER_MODE_STEREO,
|
||||||
|
|
Loading…
Reference in a new issue