1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-18 11:39:31 +01:00

Fix chromaprinter unref buffer crash

This commit is contained in:
Jonas Kvinge 2019-04-22 00:42:03 +02:00
parent 3c6c9741ff
commit 984abc89a8

View File

@ -133,7 +133,6 @@ QString Chromaprinter::CreateFingerprint() {
// Wait until EOS or error
GstMessage *msg = gst_bus_timed_pop_filtered(bus, kTimeoutSecs * GST_SECOND, static_cast<GstMessageType>(GST_MESSAGE_EOS | GST_MESSAGE_ERROR));
if (msg != nullptr) {
if (msg->type == GST_MESSAGE_ERROR) {
// Report error
@ -220,12 +219,16 @@ GstFlowReturn Chromaprinter::NewBufferCallback(GstAppSink *app_sink, gpointer se
Chromaprinter *me = reinterpret_cast<Chromaprinter*>(self);
GstSample *sample = gst_app_sink_pull_sample(app_sink);
if (!sample) return GST_FLOW_ERROR;
GstBuffer *buffer = gst_sample_get_buffer(sample);
GstMapInfo map;
gst_buffer_map(buffer, &map, GST_MAP_READ);
me->buffer_.write(reinterpret_cast<const char*>(map.data), map.size);
gst_buffer_unmap(buffer, &map);
gst_buffer_unref(buffer);
if (buffer) {
GstMapInfo map;
if (gst_buffer_map(buffer, &map, GST_MAP_READ)) {
me->buffer_.write(reinterpret_cast<const char*>(map.data), map.size);
gst_buffer_unmap(buffer, &map);
}
}
gst_sample_unref(sample);
return GST_FLOW_OK;