summaryrefslogtreecommitdiffstats
path: root/modules/gdnative/videodecoder
diff options
context:
space:
mode:
authorAnish <anishbhobe@hotmail.com>2019-05-04 00:34:58 +0530
committerAnish <anishbhobe@hotmail.com>2019-05-04 00:34:58 +0530
commitf0757f31a44144b1d8c8a527d63f67645a4141fb (patch)
tree5f9bf17c5660ef72879f5b080c350153ba4a3815 /modules/gdnative/videodecoder
parentc2251eab51a45b73306863617b309e4666c87350 (diff)
downloadredot-engine-f0757f31a44144b1d8c8a527d63f67645a4141fb.tar.gz
Fixes VideostreamGDNative crash on audio_channel=0.
Added an if case to check if the mix_callback exists before running any of the audio code. Fixes: #28644
Diffstat (limited to 'modules/gdnative/videodecoder')
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index 9bb1186269..be131c5402 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -146,23 +146,25 @@ void VideoStreamPlaybackGDNative::update(float p_delta) {
ERR_FAIL_COND(interface == NULL);
interface->update(data_struct, p_delta);
- if (pcm_write_idx >= 0) {
- // Previous remains
- int mixed = mix_callback(mix_udata, pcm, samples_decoded);
- if (mixed == samples_decoded) {
- pcm_write_idx = -1;
- } else {
- samples_decoded -= mixed;
- pcm_write_idx += mixed;
+ if (mix_callback) {
+ if (pcm_write_idx >= 0) {
+ // Previous remains
+ int mixed = mix_callback(mix_udata, pcm, samples_decoded);
+ if (mixed == samples_decoded) {
+ pcm_write_idx = -1;
+ } else {
+ samples_decoded -= mixed;
+ pcm_write_idx += mixed;
+ }
}
- }
- if (pcm_write_idx < 0) {
- samples_decoded = interface->get_audioframe(data_struct, pcm, AUX_BUFFER_SIZE);
- pcm_write_idx = mix_callback(mix_udata, pcm, samples_decoded);
- if (pcm_write_idx == samples_decoded) {
- pcm_write_idx = -1;
- } else {
- samples_decoded -= pcm_write_idx;
+ if (pcm_write_idx < 0) {
+ samples_decoded = interface->get_audioframe(data_struct, pcm, AUX_BUFFER_SIZE);
+ pcm_write_idx = mix_callback(mix_udata, pcm, samples_decoded);
+ if (pcm_write_idx == samples_decoded) {
+ pcm_write_idx = -1;
+ } else {
+ samples_decoded -= pcm_write_idx;
+ }
}
}