From c96b26ff530311cd16589efaa1d8b21ec4556600 Mon Sep 17 00:00:00 2001 From: Jacek Manko Date: Thu, 1 Aug 2024 18:02:31 +0200 Subject: [PATCH] ONEM-36369: Replace gst_buffer_new_memdup() usage with gst_buffer_new_wrapped gst_buffer_new_memdup is only available in gst 1.20+ Copy the data and use gst_buffer_new_wrapped instead --- .../gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp b/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp index 8e555d8126602..efcf9ae036655 100644 --- a/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp +++ b/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp @@ -65,7 +65,13 @@ void RealtimeIncomingAudioSourceLibWebRTC::OnData(const void* audioData, int, in gst_audio_info_set_format(&info, format, sampleRate, numberOfChannels, NULL); auto bufferSize = GST_AUDIO_INFO_BPF(&info) * numberOfFrames; - auto buffer = adoptGRef(gst_buffer_new_memdup(const_cast(audioData), bufferSize)); + void* dataCopy = g_malloc(bufferSize); + if (!dataCopy) { + WTFLogAlways("Failed to allocate memory for WebRTC audio buffer!"); + return; + } + memcpy(dataCopy, audioData, bufferSize); + auto buffer = adoptGRef(gst_buffer_new_wrapped(static_cast(dataCopy), bufferSize)); gst_buffer_add_audio_meta(buffer.get(), &info, numberOfFrames, nullptr); auto caps = adoptGRef(gst_audio_info_to_caps(&info)); auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));