From de43231475a542588cc93d9c4ffcd57094da53f6 Mon Sep 17 00:00:00 2001 From: melpon Date: Mon, 4 Nov 2024 04:59:41 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=81=8C=E5=91=BC=E3=81=B0=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E5=89=8D=E3=81=AB=20tp=5Ftraverse=20=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora_sdk_ext.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/sora_sdk_ext.cpp b/src/sora_sdk_ext.cpp index 41237dc..b08b029 100644 --- a/src/sora_sdk_ext.cpp +++ b/src/sora_sdk_ext.cpp @@ -30,6 +30,10 @@ using namespace nb::literals; * やっておかないと終了時にリークエラーが発生する。 */ int audio_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + // インスタンスを取得する SoraAudioSinkImpl* audio_sink = nb::inst_ptr(self); @@ -51,6 +55,10 @@ int audio_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { } int audio_sink_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraAudioSinkImpl* audio_sink = nb::inst_ptr(self); audio_sink->on_format_ = nullptr; audio_sink->on_data_ = nullptr; @@ -67,6 +75,10 @@ PyType_Slot audio_sink_slots[] = { {0, nullptr}}; int audio_stream_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraAudioStreamSinkImpl* audio_sink = nb::inst_ptr(self); @@ -79,6 +91,10 @@ int audio_stream_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { } int audio_stream_sink_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraAudioStreamSinkImpl* audio_sink = nb::inst_ptr(self); audio_sink->on_frame_ = nullptr; @@ -91,6 +107,10 @@ PyType_Slot audio_stream_sink_slots[] = { {0, nullptr}}; int video_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraVideoSinkImpl* video_sink = nb::inst_ptr(self); if (video_sink->on_frame_) { @@ -102,6 +122,10 @@ int video_sink_tp_traverse(PyObject* self, visitproc visit, void* arg) { } int video_sink_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraVideoSinkImpl* video_sink = nb::inst_ptr(self); video_sink->on_frame_ = nullptr; return 0; @@ -115,6 +139,10 @@ PyType_Slot video_sink_slots[] = { int audio_frame_transformer_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraAudioFrameTransformer* audio_frame_transformer = nb::inst_ptr(self); @@ -127,6 +155,10 @@ int audio_frame_transformer_tp_traverse(PyObject* self, } int audio_frame_transformer_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraAudioFrameTransformer* audio_frame_transformer = nb::inst_ptr(self); audio_frame_transformer->on_transform_ = nullptr; @@ -141,6 +173,10 @@ PyType_Slot audio_frame_transformer_slots[] = { int video_frame_transformer_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraVideoFrameTransformer* video_frame_transformer = nb::inst_ptr(self); @@ -153,6 +189,10 @@ int video_frame_transformer_tp_traverse(PyObject* self, } int video_frame_transformer_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraVideoFrameTransformer* video_frame_transformer = nb::inst_ptr(self); video_frame_transformer->on_transform_ = nullptr; @@ -165,6 +205,10 @@ PyType_Slot video_frame_transformer_slots[] = { {0, nullptr}}; int connection_tp_traverse(PyObject* self, visitproc visit, void* arg) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraConnection* conn = nb::inst_ptr(self); if (conn->on_set_offer_) { @@ -221,6 +265,10 @@ int connection_tp_traverse(PyObject* self, visitproc visit, void* arg) { } int connection_tp_clear(PyObject* self) { + if (!nb::inst_ready(self)) { + return 0; + } + SoraConnection* conn = nb::inst_ptr(self); conn->on_set_offer_ = nullptr; conn->on_ws_close_ = nullptr;