Skip to content

Commit 546910a

Browse files
committed
Merge branch 'fix/multiscaler-oom-on-renegotation' into main
2 parents 3989104 + 6c87a1e commit 546910a

File tree

5 files changed

+33
-69
lines changed

5 files changed

+33
-69
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Plugin Details:
6767
Name tiovx
6868
Description GStreamer plugin for TIOVX
6969
Filename /usr/lib/gstreamer-1.0/libgsttiovx.so
70-
Version 0.2.1
70+
Version 0.2.2
7171
License Proprietary
7272
Source module GstTIOVX
7373
Binary package GstTIOVX source release

gst-libs/gst/tiovx/gsttiovxpad.c

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (GstTIOVXPad, gst_tiovx_pad,
104104

105105
/* prototypes */
106106
static void gst_tiovx_pad_finalize (GObject * object);
107-
static gboolean gst_tiovx_pad_configure_pool (GstTIOVXPad * self,
108-
GstCaps * caps, GstVideoInfo * info);
109107
static void gst_tiovx_pad_set_property (GObject * object, guint prop_id,
110108
const GValue * value, GParamSpec * pspec);
111109
static void gst_tiovx_pad_get_property (GObject * object, guint prop_id,
@@ -208,6 +206,7 @@ gst_tiovx_pad_peer_query_allocation (GstTIOVXPad * self, GstCaps * caps)
208206
gint npool = 0;
209207
gboolean ret = FALSE;
210208
GstPad *peer = NULL;
209+
GstBufferPool *pool = NULL;
211210

212211
g_return_val_if_fail (self, FALSE);
213212
g_return_val_if_fail (caps, FALSE);
@@ -224,41 +223,43 @@ gst_tiovx_pad_peer_query_allocation (GstTIOVXPad * self, GstCaps * caps)
224223
}
225224
gst_object_unref (peer);
226225

227-
/* Always remove the current pool, we will either create a new one or get it from downstream */
228-
if (NULL != priv->buffer_pool) {
229-
gst_object_unref (priv->buffer_pool);
230-
priv->buffer_pool = NULL;
231-
}
232-
233226
/* Look for the first TIOVX buffer if present */
234227
for (npool = 0; npool < gst_query_get_n_allocation_pools (query); ++npool) {
235-
GstBufferPool *pool;
236-
237228
gst_query_parse_nth_allocation_pool (query, npool, &pool, NULL, NULL, NULL);
238229

239230
if (GST_TIOVX_IS_BUFFER_POOL (pool)) {
240-
priv->buffer_pool = pool;
241231
break;
242232
} else {
243233
gst_object_unref (pool);
234+
pool = NULL;
244235
}
245236
}
246237

247-
if (NULL == priv->buffer_pool) {
248-
GstVideoInfo info;
238+
if (NULL == pool) {
239+
gsize size = 0;
249240

250-
priv->buffer_pool = g_object_new (GST_TIOVX_TYPE_BUFFER_POOL, NULL);
251-
252-
ret = gst_tiovx_pad_configure_pool (self, caps, &info);
241+
size = gst_tiovx_get_size_from_exemplar (&priv->exemplar, caps);
242+
if (0 >= size) {
243+
GST_ERROR_OBJECT (self, "Failed to get size from exemplar");
244+
goto unref_query;
245+
}
253246

247+
ret =
248+
gst_tiovx_add_new_pool (GST_CAT_DEFAULT, query, priv->pool_size,
249+
&priv->exemplar, size, &pool);
254250
if (!ret) {
255251
GST_ERROR_OBJECT (self, "Unable to configure pool");
256-
gst_object_unref (priv->buffer_pool);
257-
priv->buffer_pool = NULL;
258252
goto unref_query;
259253
}
260254
}
261255

256+
/* Unref the old stored pool */
257+
if (NULL != priv->buffer_pool) {
258+
gst_object_unref (priv->buffer_pool);
259+
}
260+
/* Assign the new pool to the internal value */
261+
priv->buffer_pool = pool;
262+
262263
ret = TRUE;
263264

264265
unref_query:
@@ -272,8 +273,8 @@ gst_tiovx_pad_process_allocation_query (GstTIOVXPad * self, GstQuery * query)
272273
{
273274
GstTIOVXPadPrivate *priv = NULL;
274275
GstCaps *caps = NULL;
275-
GstVideoInfo info;
276276
gboolean ret = FALSE;
277+
gsize size = 0;
277278

278279
priv = gst_tiovx_pad_get_instance_private (self);
279280

@@ -299,20 +300,21 @@ gst_tiovx_pad_process_allocation_query (GstTIOVXPad * self, GstQuery * query)
299300
goto out;
300301
}
301302

302-
priv->buffer_pool = g_object_new (GST_TIOVX_TYPE_BUFFER_POOL, NULL);
303+
size = gst_tiovx_get_size_from_exemplar (&priv->exemplar, caps);
304+
if (0 >= size) {
305+
GST_ERROR_OBJECT (self, "Failed to get size from input");
306+
ret = FALSE;
307+
goto out;
308+
}
303309

304-
ret = gst_tiovx_pad_configure_pool (self, caps, &info);
310+
ret =
311+
gst_tiovx_add_new_pool (GST_CAT_DEFAULT, query, priv->pool_size,
312+
&priv->exemplar, size, &priv->buffer_pool);
305313
if (!ret) {
306314
GST_ERROR_OBJECT (self, "Unable to configure pool");
307-
gst_object_unref (priv->buffer_pool);
308-
priv->buffer_pool = NULL;
309315
goto out;
310316
}
311317

312-
gst_query_add_allocation_pool (query,
313-
GST_BUFFER_POOL (priv->buffer_pool), GST_VIDEO_INFO_SIZE (&info),
314-
priv->pool_size, priv->pool_size);
315-
316318
ret = TRUE;
317319

318320
out:
@@ -433,44 +435,6 @@ gst_tiovx_pad_acquire_buffer (GstTIOVXPad * self, GstBuffer ** buffer,
433435
return flow_return;
434436
}
435437

436-
static gboolean
437-
gst_tiovx_pad_configure_pool (GstTIOVXPad * self, GstCaps * caps,
438-
GstVideoInfo * info)
439-
{
440-
GstTIOVXPadPrivate *priv = NULL;
441-
GstStructure *config = NULL;
442-
gboolean ret = FALSE;
443-
444-
g_return_val_if_fail (self, ret);
445-
g_return_val_if_fail (caps, ret);
446-
g_return_val_if_fail (info, ret);
447-
448-
priv = gst_tiovx_pad_get_instance_private (self);
449-
450-
if (!gst_video_info_from_caps (info, caps)) {
451-
GST_ERROR_OBJECT (self, "Unable to get video info from caps");
452-
return FALSE;
453-
}
454-
455-
config = gst_buffer_pool_get_config (GST_BUFFER_POOL (priv->buffer_pool));
456-
457-
gst_tiovx_buffer_pool_config_set_exemplar (config, priv->exemplar);
458-
gst_buffer_pool_config_set_params (config, caps, GST_VIDEO_INFO_SIZE (info),
459-
priv->pool_size, priv->pool_size);
460-
461-
if (!gst_buffer_pool_set_config (GST_BUFFER_POOL (priv->buffer_pool), config)) {
462-
GST_ERROR_OBJECT (self, "Unable to set pool configuration");
463-
goto out;
464-
}
465-
466-
gst_buffer_pool_set_active (GST_BUFFER_POOL (priv->buffer_pool), TRUE);
467-
468-
ret = TRUE;
469-
470-
out:
471-
return ret;
472-
}
473-
474438
static void
475439
gst_tiovx_pad_finalize (GObject * object)
476440
{

gst-libs/gst/tiovx/gsttiovxsimo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ gst_tiovx_simo_stop (GstTIOVXSimo * self)
544544
guint num_pads = 0;
545545
guint i = 0;
546546

547-
GST_DEBUG_OBJECT (self, "gst_ti_ovx_simo_modules_deinit");
547+
GST_DEBUG_OBJECT (self, "gst_tiovx_simo_modules_deinit");
548548

549549
g_return_val_if_fail (self, FALSE);
550550

@@ -602,7 +602,6 @@ gst_tiovx_simo_finalize (GObject * gobject)
602602

603603
self = GST_TIOVX_SIMO (gobject);
604604

605-
606605
priv = gst_tiovx_simo_get_instance_private (self);
607606

608607
GST_LOG_OBJECT (self, "finalize");

gst-libs/gst/tiovx/gsttiovxutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ gst_tiovx_add_new_pool (GstDebugCategory * category, GstQuery * query,
367367
if (!gst_tiovx_configure_pool (category, pool, exemplar, caps, size,
368368
num_buffers)) {
369369
GST_CAT_ERROR (category, "Unable to configure pool");
370+
gst_object_unref (pool);
370371
return FALSE;
371372
}
372373

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('GstTIOVX', ['c'],
2-
version : '0.2.1',
2+
version : '0.2.2',
33
meson_version : '>= 0.50',)
44

55
project_name = meson.project_name()

0 commit comments

Comments
 (0)