| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-06-11 17:44:39 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-06-11 17:45:31 UTC |
| parent | bb041ddde053bd5e2f1c87924b72b81f465a3a56 |
| snikket/jingle/PeerConnection.cpp.hx | +12 | -2 |
diff --git a/snikket/jingle/PeerConnection.cpp.hx b/snikket/jingle/PeerConnection.cpp.hx index 03b7c4f..a49649d 100644 --- a/snikket/jingle/PeerConnection.cpp.hx +++ b/snikket/jingle/PeerConnection.cpp.hx @@ -499,14 +499,22 @@ class MediaStreamTrack { for (i in 0...msg.size()) { s16[i] = ULAW_DECODE[cast msg.at(i)]; } - if (pcmCallback != null) pcmCallback(s16.toData(), rtp.clockRate, channels); + if (pcmCallback != null) { + cpp.vm.Gc.enterGCFreeZone(); + pcmCallback(s16.toData(), rtp.clockRate, channels); + cpp.vm.Gc.exitGCFreeZone(); + } } else if (format == "opus") { final s16 = new haxe.ds.Vector(5760).toData(); // 5760 is the max size needed for 48khz if (untyped __cpp__("!opus")) opus = OpusDecoder.create(rtp.clockRate, channels, null); // assume only one opus clockRate+channels for this track // TODO: Pass data of NULL to mean lost packet. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms. final decoded = OpusDecoder.decode(opus, cast msg.data(), msg.size(), cpp.Pointer.ofArray(s16), Std.int(s16.length / channels), false); s16.resize(decoded * channels); - if (pcmCallback != null) pcmCallback(s16, rtp.clockRate, channels); + if (pcmCallback != null) { + cpp.vm.Gc.enterGCFreeZone(); + pcmCallback(s16, rtp.clockRate, channels); + cpp.vm.Gc.exitGCFreeZone(); + } } else { trace("Ignoring audio frame with format", format); } @@ -534,7 +542,9 @@ class MediaStreamTrack { waitForQ = true; mutex.release(); } else { + cpp.vm.Gc.enterGCFreeZone(); readyForPCMCallback(); + cpp.vm.Gc.exitGCFreeZone(); } }); }