From 44d62a9f4b6ac892b1fb9b8998be4162409952e3 Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 23 Aug 2021 14:53:27 -0300 Subject: Implement NativeExtension pointer arguments * Allows calling into native extensions directly with a pointer * Makes it easier to implement some APIs more efficiently * Appears with a "*" in the documentation for the argument. * Implementing the pointer handling is entirely up to the implementation, although the extension API provides some hint. * AudioStream has been implemented as an example, allowing to create NativeExtension based AudioStreams. --- scene/audio/audio_stream_player.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scene/audio') diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 298d75b668..9383355292 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -202,8 +202,12 @@ void AudioStreamPlayer::set_stream(Ref p_stream) { } if (p_stream.is_valid()) { - stream = p_stream; stream_playback = p_stream->instance_playback(); + if (stream_playback.is_valid()) { + stream = p_stream; + } else { + stream.unref(); + } } AudioServer::get_singleton()->unlock(); -- cgit v1.2.3