Fix includes and initialization for GDNative Videodecoder
Fixes warnings and a crash when running the destructor with an uninitialized pcm pointer.
This commit is contained in:
parent
7199b7b5dd
commit
012dac9aad
@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import methods
|
||||
|
||||
Import('env')
|
||||
Import('env_modules')
|
||||
|
||||
|
@ -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() {
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user