tracerutils: allow casting parameters types
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>
Thu, 16 Feb 2023 12:44:50 +0000 (13:44 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 27 Jun 2023 23:24:51 +0000 (00:24 +0100)
It was impossible to have an u32 parameter such as
'max-buffer-size=(uint)5' because the parentheses were not properly
parsed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4941>

subprojects/gstreamer/gst/gsttracerutils.c

index 07f7490..ba9a826 100644 (file)
@@ -100,7 +100,21 @@ _priv_gst_tracing_init (void)
     while (t[i]) {
       // check t[i] for params
       if ((params = strchr (t[i], '('))) {
-        gchar *end = strchr (&params[1], ')');
+        // params can contain multiple '(' when using this kind of parameter: 'max-buffer-size=(uint)5'
+        guint n_par = 1, j;
+        gchar *end = NULL;
+
+        for (j = 1; params[j] != '\0'; j++) {
+          if (params[j] == '(')
+            n_par++;
+          else if (params[j] == ')') {
+            n_par--;
+            if (n_par == 0) {
+              end = &params[j];
+              break;
+            }
+          }
+        }
         *params = '\0';
         params++;
         if (end)