]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-processor: Add debug print helpers
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Sat, 27 Mar 2021 19:33:33 +0000 (12:33 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
Add a couple of helper functions to print debug messages
and the generated config.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/Makefile.am
topology/pre-processor.c
topology/pre-processor.h [new file with mode: 0644]

index 47f32f05a11216d6c0c12f945631e91f990d5e06..d7f7b09f6b50613da1f4f433ec7bab0da1dc560b 100644 (file)
@@ -10,7 +10,7 @@ endif
 
 alsatplg_SOURCES = topology.c pre-processor.c
 
-noinst_HEADERS = topology.h
+noinst_HEADERS = topology.h pre-processor.h
 
 AM_CPPFLAGS = \
          -Wall -I$(top_srcdir)/include
index 212adfe30e4abe578a3278ba6fa9acfba32117ea..5ddd4f908b831c427c2d9185bae81504d0e074d1 100644 (file)
@@ -17,6 +17,8 @@
   The full GNU General Public License is included in this distribution
   in the file called LICENSE.GPL.
 */
+
+#include <stdarg.h>
 #include <stdio.h>
 #include <stddef.h>
 #include <string.h>
 #include <alsa/conf.h>
 #include "gettext.h"
 #include "topology.h"
+#include "pre-processor.h"
+
+#ifdef TPLG_DEBUG
+void tplg_pp_debug(char *fmt, ...)
+{
+       char msg[DEBUG_MAX_LENGTH];
+       va_list va;
+
+       va_start(va, fmt);
+       vsnprintf(msg, DEBUG_MAX_LENGTH, fmt, va);
+       va_end(va);
+
+       fprintf(stdout, "%s\n", msg);
+}
+
+void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg)
+{
+       snd_config_save(cfg, tplg_pp->dbg_output);
+}
+#else
+void tplg_pp_debug(char *fmt, ...) {}
+void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg){}
+#endif
 
 static int pre_process_config(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg)
 {
diff --git a/topology/pre-processor.h b/topology/pre-processor.h
new file mode 100644 (file)
index 0000000..9a7b6f1
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PRE_PROCESSOR_H
+#define __PRE_PROCESSOR_H
+
+#include <stdarg.h>
+#include "topology.h"
+
+#define DEBUG_MAX_LENGTH       256
+
+/* debug helpers */
+void tplg_pp_debug(char *fmt, ...);
+void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg);
+#endif