audio: sound.set_time() should take effect immediately

Fixes #770
This commit is contained in:
rdb 2019-11-03 11:17:37 +01:00
parent 847ebf667f
commit bbb334abea
2 changed files with 10 additions and 7 deletions

View File

@ -47,11 +47,9 @@ PUBLISHED:
* concept) to the seek position within a file. The value starts at 0.0 (the
* default) and ends at the value given by the length() method.
*
* The current time position will not change while the sound is playing; you
* must call play() again to effect the change. To play the same sound from
* a time offset a second time, explicitly set the time position again. When
* looping, the second and later loops will start from the beginning of the
* sound.
* In the past, this call did nothing if the sound was currently playing, and
* it was necessary to call play() to effect the change. This is no longer
* the case; the time change takes effect immediately.
*
* If a sound is playing, calling get_time() repeatedly will return different
* results over time. e.g.

View File

@ -564,13 +564,18 @@ push_fresh_buffers() {
}
/**
* The next time you call play, the sound will start from the specified
* offset.
* Sets the offset within the sound. If the sound is currently playing, its
* position is updated immediately.
*/
void OpenALAudioSound::
set_time(PN_stdfloat time) {
ReMutexHolder holder(OpenALAudioManager::_lock);
_start_time = time;
if (is_playing()) {
// Ensure that the position is updated immediately.
play();
}
}
/**