diff options
Diffstat (limited to 'modules/gdnative')
-rw-r--r-- | modules/gdnative/pluginscript/pluginscript_script.cpp | 4 | ||||
-rw-r--r-- | modules/gdnative/videodecoder/video_stream_gdnative.cpp | 14 | ||||
-rw-r--r-- | modules/gdnative/videodecoder/video_stream_gdnative.h | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 94d38e1be1..f7c961d38b 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -401,9 +401,7 @@ Error PluginScript::load_source_code(const String &p_path) { PoolVector<uint8_t> sourcef; Error err; FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); - if (err) { - ERR_FAIL_COND_V(err, err); - } + ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'."); int len = f->get_len(); sourcef.resize(len + 1); diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index 212ff51b80..f3c34fd5e0 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -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) { diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index b9f1c8e4da..9aed1fd2a0 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -121,6 +121,7 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback { int num_channels; float time; + bool seek_backward; int mix_rate; double delay_compensation; |