mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
plugin: Ensure allocation using the same importer
Instead of locking mutex twice and praying that importer will not change in between, just ref it to ensure that
This commit is contained in:
@@ -426,16 +426,12 @@ static gboolean
|
|||||||
gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
||||||
{
|
{
|
||||||
GstClapperSink *self = GST_CLAPPER_SINK_CAST (bsink);
|
GstClapperSink *self = GST_CLAPPER_SINK_CAST (bsink);
|
||||||
|
GstClapperImporter *importer = NULL;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
guint size, min_buffers;
|
guint size, min_buffers;
|
||||||
gboolean need_pool;
|
gboolean need_pool;
|
||||||
|
|
||||||
if (!self->importer) {
|
|
||||||
GST_DEBUG_OBJECT (self, "No importer to propose allocation");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_query_parse_allocation (query, &caps, &need_pool);
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
||||||
|
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
@@ -448,6 +444,16 @@ gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_CLAPPER_SINK_LOCK (self);
|
||||||
|
if (self->importer)
|
||||||
|
importer = gst_object_ref (self->importer);
|
||||||
|
GST_CLAPPER_SINK_UNLOCK (self);
|
||||||
|
|
||||||
|
if (!importer) {
|
||||||
|
GST_DEBUG_OBJECT (self, "No importer to propose allocation");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Normal size of a frame */
|
/* Normal size of a frame */
|
||||||
size = GST_VIDEO_INFO_SIZE (&info);
|
size = GST_VIDEO_INFO_SIZE (&info);
|
||||||
|
|
||||||
@@ -459,10 +465,7 @@ gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
|||||||
GstStructure *config = NULL;
|
GstStructure *config = NULL;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Need to create buffer pool");
|
GST_DEBUG_OBJECT (self, "Need to create buffer pool");
|
||||||
|
pool = gst_clapper_importer_create_pool (importer, &config);
|
||||||
GST_CLAPPER_SINK_LOCK (self);
|
|
||||||
pool = gst_clapper_importer_create_pool (self->importer, &config);
|
|
||||||
GST_CLAPPER_SINK_UNLOCK (self);
|
|
||||||
|
|
||||||
if (pool) {
|
if (pool) {
|
||||||
/* If we did not get config, use default one */
|
/* If we did not get config, use default one */
|
||||||
@@ -473,6 +476,7 @@ gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
|||||||
|
|
||||||
if (!gst_buffer_pool_set_config (pool, config)) {
|
if (!gst_buffer_pool_set_config (pool, config)) {
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
gst_object_unref (importer);
|
||||||
|
|
||||||
GST_ERROR_OBJECT (self, "Failed to set config");
|
GST_ERROR_OBJECT (self, "Failed to set config");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -486,9 +490,8 @@ gst_clapper_sink_propose_allocation (GstBaseSink *bsink, GstQuery *query)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_CLAPPER_SINK_LOCK (self);
|
gst_clapper_importer_add_allocation_metas (importer, query);
|
||||||
gst_clapper_importer_add_allocation_metas (self->importer, query);
|
gst_object_unref (importer);
|
||||||
GST_CLAPPER_SINK_UNLOCK (self);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user