Skip to content

Commit

Permalink
ONEM-36369: Replace gst_buffer_new_memdup() usage with gst_buffer_new…
Browse files Browse the repository at this point in the history
…_wrapped

gst_buffer_new_memdup is only available in gst 1.20+
Copy the data and use gst_buffer_new_wrapped instead
  • Loading branch information
jacek-manko-red authored and suresh-khurdiya-infosys committed Dec 10, 2024
1 parent d15a167 commit c96b26f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<gpointer>(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<guint8*>(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));
Expand Down

0 comments on commit c96b26f

Please sign in to comment.