summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-12-12 15:21:44 +0100
committerRémi Verschelde <rverschelde@gmail.com>2018-12-13 15:31:13 +0100
commit012dac9aadbfd69fa2b6233496e9383e27f0e8e2 (patch)
treee36dd835980c8ecd9f973deb9cd1d3a5e5be233b /modules/gdnative
parent7199b7b5dd1b324f6581c4a880951730daefbb60 (diff)
Fix includes and initialization for GDNative Videodecoder
Fixes warnings and a crash when running the destructor with an uninitialized pcm pointer.
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/videodecoder/SCsub3
-rw-r--r--modules/gdnative/videodecoder/register_types.cpp5
-rw-r--r--modules/gdnative/videodecoder/resource_importer_av_gdnative.cpp4
-rw-r--r--modules/gdnative/videodecoder/resource_importer_av_gdnative.h3
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp22
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h17
6 files changed, 32 insertions, 22 deletions
diff --git a/modules/gdnative/videodecoder/SCsub b/modules/gdnative/videodecoder/SCsub
index 51b0418d6b..8d9c1ff50e 100644
--- a/modules/gdnative/videodecoder/SCsub
+++ b/modules/gdnative/videodecoder/SCsub
@@ -1,8 +1,5 @@
#!/usr/bin/env python
-import os
-import methods
-
Import('env')
Import('env_modules')
diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp
index 64599365e5..70eea2e036 100644
--- a/modules/gdnative/videodecoder/register_types.cpp
+++ b/modules/gdnative/videodecoder/register_types.cpp
@@ -28,7 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "class_db.h"
+#include "register_types.h"
+
+#include "core/class_db.h"
#include "resource_importer_av_gdnative.h"
#include "video_stream_gdnative.h"
@@ -41,5 +43,6 @@ void register_videodecoder_types() {
#endif
ClassDB::register_class<VideoStreamGDNative>();
}
+
void unregister_videodecoder_types() {
}
diff --git a/modules/gdnative/videodecoder/resource_importer_av_gdnative.cpp b/modules/gdnative/videodecoder/resource_importer_av_gdnative.cpp
index ff9f6118fb..7fe8cc89d1 100644
--- a/modules/gdnative/videodecoder/resource_importer_av_gdnative.cpp
+++ b/modules/gdnative/videodecoder/resource_importer_av_gdnative.cpp
@@ -30,8 +30,8 @@
#include "resource_importer_av_gdnative.h"
-#include "io/resource_saver.h"
-#include "os/file_access.h"
+#include "core/io/resource_saver.h"
+#include "core/os/file_access.h"
#include "scene/resources/texture.h"
String ResourceImporterAVGDNative::get_importer_name() const {
diff --git a/modules/gdnative/videodecoder/resource_importer_av_gdnative.h b/modules/gdnative/videodecoder/resource_importer_av_gdnative.h
index 0ec96dc72c..9760ebbe64 100644
--- a/modules/gdnative/videodecoder/resource_importer_av_gdnative.h
+++ b/modules/gdnative/videodecoder/resource_importer_av_gdnative.h
@@ -31,9 +31,8 @@
#ifndef RESOURCE_IMPORTER_AV_GDNATIVE_H
#define RESOURCE_IMPORTER_AV_GDNATIVE_H
-#include "video_stream_gdnative.h"
-
#include "core/io/resource_import.h"
+#include "video_stream_gdnative.h"
class ResourceImporterAVGDNative : public ResourceImporter {
GDCLASS(ResourceImporterAVGDNative, ResourceImporter)
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index a959a4c8ae..ea847f9804 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -29,13 +29,16 @@
/*************************************************************************/
#include "video_stream_gdnative.h"
-#include <project_settings.h>
-#include <servers/audio_server.h>
+
+#include "core/project_settings.h"
+#include "servers/audio_server.h"
VideoDecoderServer *VideoDecoderServer::instance = NULL;
static VideoDecoderServer decoder_server;
+const int AUX_BUFFER_SIZE = 1024; // Buffer 1024 samples.
+
// NOTE: Callbacks for the GDNative libraries.
extern "C" {
godot_int GDAPI godot_videodecoder_file_read(void *ptr, uint8_t *buf, int buf_size) {
@@ -184,12 +187,20 @@ void VideoStreamPlaybackGDNative::update_texture() {
VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
texture(Ref<ImageTexture>(memnew(ImageTexture))),
- time(0),
+ playing(false),
+ paused(false),
mix_udata(NULL),
mix_callback(NULL),
num_channels(-1),
+ time(0),
mix_rate(0),
- playing(false) {}
+ delay_compensation(0),
+ pcm(NULL),
+ pcm_write_idx(0),
+ samples_decoded(0),
+ file(NULL),
+ interface(NULL),
+ data_struct(NULL) {}
VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
cleanup();
@@ -198,7 +209,8 @@ VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
void VideoStreamPlaybackGDNative::cleanup() {
if (data_struct)
interface->destructor(data_struct);
- memfree(pcm);
+ if (pcm)
+ memfree(pcm);
pcm = NULL;
time = 0;
num_channels = -1;
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index d203a5d04f..87ba9c8cc4 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -31,15 +31,15 @@
#ifndef VIDEO_STREAM_GDNATIVE_H
#define VIDEO_STREAM_GDNATIVE_H
-#include <modules/gdnative/gdnative.h>
-#include <os/file_access.h>
-#include <scene/resources/texture.h>
-#include <scene/resources/video_stream.h>
+#include "../gdnative.h"
+#include "core/os/file_access.h"
+#include "scene/resources/texture.h"
+#include "scene/resources/video_stream.h"
struct VideoDecoderGDNative {
+ const godot_videodecoder_interface_gdnative *interface;
String plugin_name;
Vector<String> supported_extensions;
- const godot_videodecoder_interface_gdnative *interface;
VideoDecoderGDNative() :
interface(NULL),
@@ -124,7 +124,6 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
int mix_rate;
double delay_compensation;
- const int AUX_BUFFER_SIZE = 1024; // Buffer 1024 samples.
float *pcm;
int pcm_write_idx;
int samples_decoded;
@@ -135,10 +134,10 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
protected:
String file_name;
- FileAccess *file = NULL;
+ FileAccess *file;
- const godot_videodecoder_interface_gdnative *interface = NULL;
- void *data_struct = NULL;
+ const godot_videodecoder_interface_gdnative *interface;
+ void *data_struct;
public:
VideoStreamPlaybackGDNative();