Merge pull request #6338 from jonaski/chromaprinter

Fix gst_buffer_unref assertion with chromaprinter
This commit is contained in:
John Maguire 2019-04-27 17:39:21 +01:00 committed by GitHub
commit 96c7374689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -204,12 +204,16 @@ GstFlowReturn Chromaprinter::NewBufferCallback(GstAppSink* app_sink,
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;
}