1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

Merge pull request #32199 from starryalley/fix_seek

Fix VideostreamGDNative seek
This commit is contained in:
Rémi Verschelde
2019-09-25 13:01:50 +02:00
committed by GitHub
2 changed files with 14 additions and 1 deletions

View File

@@ -168,8 +168,12 @@ void VideoStreamPlaybackGDNative::update(float p_delta) {
}
}
while (interface->get_playback_position(data_struct) < time && playing) {
if (seek_backward) {
update_texture();
seek_backward = false;
}
while (interface->get_playback_position(data_struct) < time && playing) {
update_texture();
}
}
@@ -197,6 +201,7 @@ VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
mix_callback(NULL),
num_channels(-1),
time(0),
seek_backward(false),
mix_rate(0),
delay_compensation(0),
pcm(NULL),
@@ -261,6 +266,13 @@ void VideoStreamPlaybackGDNative::stop() {
void VideoStreamPlaybackGDNative::seek(float p_time) {
ERR_FAIL_COND(interface == NULL);
interface->seek(data_struct, p_time);
if (p_time < time)
seek_backward = true;
time = p_time;
// reset audio buffers
memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float));
pcm_write_idx = -1;
samples_decoded = 0;
}
void VideoStreamPlaybackGDNative::set_paused(bool p_paused) {

View File

@@ -121,6 +121,7 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
int num_channels;
float time;
bool seek_backward;
int mix_rate;
double delay_compensation;