From e26891a61b35ceeebd990de581077350b00281ca Mon Sep 17 00:00:00 2001 From: "Huang, Yidong" Date: Mon, 29 Jun 2026 14:27:59 +0800 Subject: [PATCH 1/5] agm: tinyalsa plugin skip close on borrowed fds The tinyalsa AGM plugin closes data and position buffer fds during pcm close handling. After the recent framework path updates, those fds are managed by AGM service side ownership and can be reused or released there. Keeping local close() calls in the plugin can cause double close issues once AGM cleanup runs. Remove explicit close() of data and position buffer fds while retaining existing unmap and memory free behavior. Signed-off-by: ffrancis --- plugins/tinyalsa/src/agm_pcm_plugin.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/tinyalsa/src/agm_pcm_plugin.c b/plugins/tinyalsa/src/agm_pcm_plugin.c index 7025a807..6d945c13 100644 --- a/plugins/tinyalsa/src/agm_pcm_plugin.c +++ b/plugins/tinyalsa/src/agm_pcm_plugin.c @@ -719,10 +719,6 @@ static int agm_pcm_close(struct pcm_plugin *plugin) priv->mmap_status = false; } if (priv->buf_info) { - if (priv->buf_info->data_buf_fd != -1) - close(priv->buf_info->data_buf_fd); - if (priv->buf_info->pos_buf_fd != -1) - close(priv->buf_info->pos_buf_fd); free(priv->buf_info); } free(plugin->priv); From 3ba441382287f62b2bc48f01fc0669049228d41d Mon Sep 17 00:00:00 2001 From: Shijie Lin Date: Tue, 7 Jul 2026 16:26:08 +0800 Subject: [PATCH 2/5] agm: fix duplicated record at non-48kHz ULL MMAP rates Lower period_bytes.min from 96 to 16 bytes to support ULL MMAP capture rates down to 8 kHz and avoid incorrectly clamping sub-48 kHz streams. The 96-byte floor forced a period mismatch between the DSP producer and client consumer, causing previously delivered PCM data to be re-presented and resulting in duplicated capture audio. The actual period size is still derived from the HAL buffer configuration, so existing 48 kHz and other working use cases remain unaffected. Signed-off-by: ffrancis --- plugins/tinyalsa/src/agm_pcm_plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tinyalsa/src/agm_pcm_plugin.c b/plugins/tinyalsa/src/agm_pcm_plugin.c index 6d945c13..8f2f37dc 100644 --- a/plugins/tinyalsa/src/agm_pcm_plugin.c +++ b/plugins/tinyalsa/src/agm_pcm_plugin.c @@ -133,7 +133,7 @@ struct pcm_plugin_hw_constraints agm_pcm_constrs = { .max = 8, }, .period_bytes = { - .min = 96, + .min = 16, .max = 122880, }, }; From f167443ecfd74d6105b408378be3cdf4ebe727ea Mon Sep 17 00:00:00 2001 From: Shijie Lin Date: Mon, 10 Aug 2026 16:51:13 +0800 Subject: [PATCH 3/5] agm: fix UAF in ClientInfo::onDeath death-recipient cookie registerCallback linked to death with the ClientInfo* itself as cookie. Since one client can have multiple death links sharing that cookie, a second/duplicate obituary could dereference the cookie after the first one already freed the object via removeClient, causing a use-after-free crash. Encode the client's pid instead of the ClientInfo* as the death recipient cookie. onDeath decodes the pid and calls the already idempotent removeClient(pid), so it never touches memory that a prior obituary may have freed. Signed-off-by: ffrancis --- ipc/aidl/server/AgmServerWrapper.cpp | 18 +++++++++--------- ipc/aidl/server/AgmServerWrapper.h | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ipc/aidl/server/AgmServerWrapper.cpp b/ipc/aidl/server/AgmServerWrapper.cpp index cb9b656e..7a6100cf 100644 --- a/ipc/aidl/server/AgmServerWrapper.cpp +++ b/ipc/aidl/server/AgmServerWrapper.cpp @@ -92,14 +92,13 @@ void ClientInfo::setAgmServerWrapper(AgmServerWrapper *wrapper) { sAgmServerWrapper = wrapper; } +// cookie carries the dying client's pid, never a ClientInfo* - onDeath must +// not touch an object an earlier, duplicate obituary for the same client +// may already have freed. void ClientInfo::onDeath(void *cookie) { - ClientInfo *client = static_cast(cookie); - ALOGI("Client died (pid): %llu", client->getPid()); - client->onDeath(); -} - -void ClientInfo::onDeath() { - sAgmServerWrapper->removeClient(mPid); + int pid = static_cast(reinterpret_cast(cookie)); + ALOGI("Client died (pid): %d", pid); + sAgmServerWrapper->removeClient(pid); } void ClientInfo::registerCallback(const std::shared_ptr &callback, @@ -111,8 +110,9 @@ void ClientInfo::registerCallback(const std::shared_ptr &callback, agm_session_register_cb(in_sessionId, &ClientInfo::onCallback, (enum event_type)in_eventType, (void *)callback.get()); - auto linkRet = AIBinder_linkToDeath(callback->asBinder().get(), mDeathRecipient.get(), - this /* cookie */); + auto linkRet = AIBinder_linkToDeath( + callback->asBinder().get(), mDeathRecipient.get(), + reinterpret_cast(static_cast(mPid)) /* cookie */); if (linkRet != STATUS_OK) { ALOGV("%s, linkToDeath failed pid %d", __func__, mPid); } else { diff --git a/ipc/aidl/server/AgmServerWrapper.h b/ipc/aidl/server/AgmServerWrapper.h index 9873ce2a..ab3fccb7 100644 --- a/ipc/aidl/server/AgmServerWrapper.h +++ b/ipc/aidl/server/AgmServerWrapper.h @@ -135,7 +135,6 @@ class ClientInfo : public ISessionOps { int removeSharedMemoryFdPairs(uint32_t sessionId, int dupFd) override; static void onDeath(void *cookie); - void onDeath(); static void onCallback(uint32_t sessionId, struct agm_event_cb_params *eventParams, void *clientData); From 586a8a12e2c6ae19926794b49761764d83c886a5 Mon Sep 17 00:00:00 2001 From: Prince Raichura Date: Tue, 11 Aug 2026 13:34:22 +0530 Subject: [PATCH 4/5] agm: service: fix param_list truncation in ACDB tunnel tag-data path graph_get_tckv_data_from_acdb() builds param_list as a list of 32-bit words [module_instance_id, num_params, param_id] that is handed to gsl_get/set_*_data_from_acdb(). The GCC 14.2 typecast cleanup ("agm: service: fix typecasting issues for GCC 14.2") changed its declaration from uint32_t* to uint8_t*, which truncates each 32-bit field to its low byte. The ACDB query is then built with a corrupt module_instance_id (e.g. 0x0026016e instead of 0x416e), ACDB reports "module instance not found", and the call fails with -68. This breaks GEF (Generic Effects Framework) effect reads over the ACDB tunnel: the catf equalizer test aborts with an uncaught HALTestSUTException (pal_gef_rw_param failed, returned -68). Restore param_list to uint32_t* so the fields are written full-width. The (uint8_t *)param_list casts already present at the gsl_*_from_acdb call sites keep the GCC 14.2 typecast fix intact. Tested on hamoa_la (COMPUTE.LA.1.0): the CATF QAL test pcm_playback_pcm_offload_equalizer_acdb_on_2ch_16bit_48khz_on_spkr.xml now returns Result=pass; previously it crashed with SIGABRT. Compilation verified with GCC 14.2 via the upstream AudioReach PR for the same change (GitHub CI build matrix green): https://github.com/AudioReach/audioreach-graphmgr/pull/129 Signed-off-by: ffrancis --- service/src/graph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/graph.c b/service/src/graph.c index 31401ddb..4b036de2 100644 --- a/service/src/graph.c +++ b/service/src/graph.c @@ -2176,7 +2176,7 @@ int graph_get_tckv_data_from_acdb( uint32_t *ptr = NULL; size_t query_payload_size = *payload_size; struct apm_module_param_data_t *param = (apm_module_param_data_t *)payload; - uint8_t *param_list; + uint32_t *param_list; if (!payload) { return -EINVAL; From 7e674e7683e48bc8aff62a8ae341229922a474ce Mon Sep 17 00:00:00 2001 From: yuchpan Date: Mon, 11 May 2026 20:59:14 +0800 Subject: [PATCH 5/5] agm: improve configuration flexibility and usability Update the build configuration, including the use of USE_GLIB and USE_G_STR_FUNC to control glib usage, USE_SYSLOG for syslog, and CUTILS_SUPPORTED for cutils. Add support for configuring period_size and n_periods parameters in agmplay. Signed-off-by: ffrancis --- configure.ac | 26 ++++++++++++++++------ ipc/DBus/agm_client/Makefile.am | 19 ++++++++++++----- ipc/DBus/agm_server/Makefile.am | 20 ++++++++++++++--- ipc/SwBinders/agm_client/Makefile.am | 18 ++++++++++------ ipc/SwBinders/agm_server/Makefile.am | 31 ++++++++++++++++++--------- plugins/alsalib/Makefile.am | 8 ++++++- plugins/tinyalsa/Makefile.am | 19 ++++++++++++++--- plugins/tinyalsa/test/Makefile.am | 17 ++++++++++----- plugins/tinyalsa/test/agmcap.c | 9 ++++---- plugins/tinyalsa/test/agmplay.c | 32 +++++++++++++++++++--------- service/Makefile.am | 11 +++++++++- service/src/agm.c | 2 ++ snd_parser/Makefile.am | 2 +- 13 files changed, 159 insertions(+), 55 deletions(-) diff --git a/configure.ac b/configure.ac index 323f639a..6dcba12f 100644 --- a/configure.ac +++ b/configure.ac @@ -41,9 +41,12 @@ AC_ARG_WITH([use_default_acdb_path], [with_use_default_acdb_path=no]) AM_CONDITIONAL([USE_DEFAULT_ACDB_PATH], [test "x${with_use_default_acdb_path}" = "xyes"]) -AC_ARG_WITH([glib], - AC_HELP_STRING([--with-glib], - [enable glib, Build against glib. Use this when building for HLOS systems which use glib])) +AC_ARG_WITH([card-def-native], + AS_HELP_STRING([--with-card-def-native=PATH], + [path to native card-defs xml (default /etc/card-defs-native.xml)]), + [card_def_native=$withval], + [card_def_native="/etc/card-defs-native.xml"]) +AC_SUBST([CARD_DEF_FILE_NATIVE], [$card_def_native]) # Optional ALSALIB build support AC_ARG_ENABLE([alsalib], @@ -52,6 +55,16 @@ AC_ARG_ENABLE([alsalib], [enable_alsalib=no]) AM_CONDITIONAL([BUILD_ALSALIB], [test "x$enable_alsalib" = "xyes"]) +AC_ARG_WITH([cutils], + AS_HELP_STRING([Use cutils (default is no)]), + [with_cutils=$withval], + [with_cutils=no]) +AM_CONDITIONAL([CUTILS_SUPPORTED], [test "x${with_cutils}" = "xyes"]) + +AC_ARG_WITH([glib], + AC_HELP_STRING([--with-glib], + [enable glib, Build against glib. Use this when building for HLOS systems which use glib])) + if (test "x${with_glib}" = "xyes"); then PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes, AC_MSG_ERROR(GThread >= 2.16 is required)) @@ -66,6 +79,10 @@ fi AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes") +AC_CHECK_FUNCS([strlcpy]) +AM_CONDITIONAL(USE_G_STR_FUNC, + [test "x${with_glib}" = "xyes" && ! test "x$ac_cv_func_strlcpy" = "xyes"]) + AC_ARG_WITH([no_ipc], AS_HELP_STRING([--with-no-ipc],[disable ipc communication to AGM (default is no)]), [with_no_ipc=$withval], @@ -89,9 +106,6 @@ fi AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) -AC_CHECK_FUNCS([strlcpy]) -AM_CONDITIONAL(USE_G_STR_FUNC, ! test "x$ac_cv_func_strlcpy" = "xyes") - AC_CONFIG_FILES( Makefile service/Makefile diff --git a/ipc/DBus/agm_client/Makefile.am b/ipc/DBus/agm_client/Makefile.am index 08086b11..d2aa969c 100644 --- a/ipc/DBus/agm_client/Makefile.am +++ b/ipc/DBus/agm_client/Makefile.am @@ -1,11 +1,20 @@ lib_LTLIBRARIES = libagmclient.la -libagmclient_la_CPPFLAGS = -I $(top_srcdir)/service/inc/public -DAGM_USE_SYSLOG +libagmclient_la_CPPFLAGS = -I $(top_srcdir)/service/inc/public libagmclient_la_CPPFLAGS += -I $(top_srcdir)/service/inc/public/agm +libagmclient_ladir = $(libdir) +libagmclient_la_LDFLAGS = -ldl -lrt -shared -version-number @LT_VERSION_NUMBER@ +libagmclient_la_SOURCES = src/agm_client_wrapper_dbus.cpp +libagmclient_la_LIBADD = + +if USE_SYSLOG +libagmclient_la_CPPFLAGS += -DAGM_USE_SYSLOG +endif + +if USE_GLIB libagmclient_la_CPPFLAGS += $(GLIB_CFLAGS) +libagmclient_la_LIBADD += $(GLIB_LIBS) -lgobject-2.0 -lgio-2.0 +endif + if USE_G_STR_FUNC libagmclient_la_CPPFLAGS += -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat endif -libagmclient_ladir = $(libdir) -libagmclient_la_LDFLAGS = -ldl -lrt -shared -version-number @LT_VERSION_NUMBER@ -libagmclient_la_SOURCES = src/agm_client_wrapper_dbus.cpp -libagmclient_la_LDFLAGS += $(GLIB_LIBS) -lgobject-2.0 -lgio-2.0 diff --git a/ipc/DBus/agm_server/Makefile.am b/ipc/DBus/agm_server/Makefile.am index 62a6ea40..466f0ec1 100644 --- a/ipc/DBus/agm_server/Makefile.am +++ b/ipc/DBus/agm_server/Makefile.am @@ -11,13 +11,27 @@ AM_CPPFLAGS += -D__unused=__attribute__\(\(__unused__\)\) lib_LTLIBRARIES = libagmserverwrapper.la libagmserverwrapper_la_SOURCES = ./src/agm-dbus-utils.cpp ./src/agm_server_wrapper_dbus.cpp -libagmserverwrapper_la_CPPFLAGS = $(AM_CPPFLAGS) $(DBUS_CFLAGS) $(GLIB_CFLAGS) -DAGM_USE_SYSLOG +libagmserverwrapper_la_CPPFLAGS = $(AM_CPPFLAGS) $(DBUS_CFLAGS) libagmserverwrapper_la_LIBADD = -lagm -L$(top_builddir)/service/.libs libagmserverwrapper_la_LDFLAGS = -ldl -lpthread -lar-osal -shared -avoid-version $(DBUS_LIBS) bin_PROGRAMS = agm_server agm_server_SOURCES = ./src/agm-server-daemon.cpp -agm_server_CPPFLAGS = $(AM_CPPFLAGS) $(GLIB_CFLAGS) -DAGM_USE_SYSLOG -Wno-write-strings -agm_server_LDADD = libagmserverwrapper.la $(GLIB_LIBS) +agm_server_CPPFLAGS = $(AM_CPPFLAGS) -Wno-write-strings +agm_server_LDADD = libagmserverwrapper.la agm_server_LDFLAGS = -ldl -shared -avoid-version + +if USE_G_STR_FUNC +AM_CPPFLAGS += -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat +endif + +if USE_SYSLOG +AM_CPPFLAGS += -DAGM_USE_SYSLOG +endif + +if USE_GLIB +AM_CPPFLAGS += $(GLIB_CFLAGS) +libagmserverwrapper_la_LIBADD += $(GLIB_LIBS) +agm_server_LDADD += $(GLIB_LIBS) +endif diff --git a/ipc/SwBinders/agm_client/Makefile.am b/ipc/SwBinders/agm_client/Makefile.am index 621cb7af..02c11f81 100644 --- a/ipc/SwBinders/agm_client/Makefile.am +++ b/ipc/SwBinders/agm_client/Makefile.am @@ -1,9 +1,15 @@ - -AM_CPPFLAGS := -I $(top_srcdir) -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/agm/ +AM_CPPFLAGS = -I $(srcdir) \ + -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/agm/ \ + -I $(top_srcdir)/ipc/SwBinders/agm_server/inc/ \ + -I $(top_srcdir)/service/inc/public/ AM_CPPFLAGS += -DDYNAMIC_LOG_ENABLED lib_LTLIBRARIES = libagmclientwrapper.la libagmclientwrapper_ladir = $(libdir) -libagmclientwrapper_la_SOURCES = src/agm_client_wrapper.cpp -libagmclientwrapper_la_CPPFLAGS := $(AM_CPPFLAGS) -libagmclientwrapper_la_LDFLAGS = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils -lrt -libagmclientwrapper_la_LIBADD = -lagmproxy -laudio_log_utils +libagmclientwrapper_la_SOURCES = src/agm_client_wrapper.cpp +libagmclientwrapper_la_CPPFLAGS = $(AM_CPPFLAGS) +libagmclientwrapper_la_LDFLAGS = -ldl -lbinder -shared -avoid-version -lutils -lrt +libagmclientwrapper_la_LIBADD = -L$(top_builddir)/ipc/SwBinders/agm_server/.libs -lagmproxy -laudio_log_utils + +if CUTILS_SUPPORTED +libagmclientwrapper_la_LIBADD += -lcutils -llog +endif diff --git a/ipc/SwBinders/agm_server/Makefile.am b/ipc/SwBinders/agm_server/Makefile.am index 98a4f917..69a20a15 100644 --- a/ipc/SwBinders/agm_server/Makefile.am +++ b/ipc/SwBinders/agm_server/Makefile.am @@ -17,21 +17,32 @@ library_include_HEADERS = $(h_sources) library_includedir = $(includedir)/qti-agm-service/ lib_LTLIBRARIES = libagmserverwrapper.la -libagmserverwrapper_la_SOURCES = ${top_srcdir}/src/agm_death_notifier.cpp ${top_srcdir}/src/agm_server_wrapper.cpp ${top_srcdir}/src/agm_callback.cpp +libagmserverwrapper_la_SOURCES = ${srcdir}/src/agm_death_notifier.cpp ${srcdir}/src/agm_server_wrapper.cpp ${srcdir}/src/agm_callback.cpp -libagmserverwrapper_la_CPPFLAGS := $(AM_CPPFLAGS) -libagmserverwrapper_la_LIBADD = -lagm -laudio_log_utils -libagmserverwrapper_la_LDFLAGS = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils -lpthread +libagmserverwrapper_la_CPPFLAGS = $(AM_CPPFLAGS) +libagmserverwrapper_la_LDFLAGS = -ldl -lbinder -shared -avoid-version -lutils -lpthread lib_LTLIBRARIES += libagmproxy.la -libagmproxy_la_SOURCES = ${top_srcdir}/src/ipc_proxy_server.cpp -libagmproxy_la_CPPFLAGS := $(AM_CPPFLAGS) +libagmproxy_la_SOURCES = ${srcdir}/src/ipc_proxy_server.cpp +libagmproxy_la_CPPFLAGS = $(AM_CPPFLAGS) libagmproxy_la_LIBADD = libagmserverwrapper.la -libagmproxy_la_LDFLAGS = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils -lpthread +libagmproxy_la_LDFLAGS = -ldl -lbinder -shared -avoid-version -lutils -lpthread bin_PROGRAMS := agm_server agm_server_SOURCES := ${top_srcdir}/src/agm_server_daemon.cpp -agm_server_la_CPPFLAGS := $(AM_CPPFLAGS) -agm_server_LDADD := libagmproxy.la -laudio_log_utils -agm_server_la_LDFLAGS = -lcutils -llog -ldl -lbinder -shared -avoid-version -lutils +agm_server_CPPFLAGS = $(AM_CPPFLAGS) +agm_server_LDADD = libagmproxy.la -laudio_log_utils +libagmserverwrapper_la_LIBADD = -L$(top_builddir)/service/.libs -lagm -laudio_log_utils +agm_server_LDFLAGS = -ldl -lbinder -shared -avoid-version -lutils + +if CUTILS_SUPPORTED +AM_CPPFLAGS += -DAGM_USE_CUTILS +libagmserverwrapper_la_LIBADD += -lcutils -llog +libagmproxy_la_LIBADD += -lcutils -llog +agm_server_LDADD += -lcutils -llog +endif + +if USE_SYSLOG +AM_CPPFLAGS += -DAGM_USE_SYSLOG +endif diff --git a/plugins/alsalib/Makefile.am b/plugins/alsalib/Makefile.am index e301afc3..24ccb4f1 100644 --- a/plugins/alsalib/Makefile.am +++ b/plugins/alsalib/Makefile.am @@ -7,7 +7,9 @@ library_includedir = $(includedir) AM_CFLAGS = -Wno-unused-parameter AM_CFLAGS += -I $(top_srcdir)/include -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include AM_CFLAGS += -I $(top_srcdir)/service/inc/public -I $(top_srcdir)/snd_parser/inc +if USE_GLIB AM_CFLAGS += $(GLIB_CFLAGS) +endif AM_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -D__LINUX__ AM_CFLAGS += -I $(top_srcdir)/../../snd_parser/inc @@ -19,7 +21,6 @@ if USE_G_STR_FUNC AM_CFLAGS += -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat endif - if BUILD_ALSALIB alsaplugindir = $(libdir)/alsa-lib @@ -54,4 +55,9 @@ libasound_module_ctl_agm_la_LDFLAGS += -L$(top_builddir)/ipc/DBus/agm_client/.li libasound_module_ctl_agm_la_LIBADD = -lasound -lsndcardparser -lagmclient endif +if USE_GLIB +libasound_module_pcm_agm_la_LIBADD += $(GLIB_LIBS) +libasound_module_ctl_agm_la_LIBADD += $(GLIB_LIBS) +endif + endif diff --git a/plugins/tinyalsa/Makefile.am b/plugins/tinyalsa/Makefile.am index 7dc2a4cb..db9a4c83 100644 --- a/plugins/tinyalsa/Makefile.am +++ b/plugins/tinyalsa/Makefile.am @@ -6,11 +6,16 @@ library_includedir = $(includedir) AM_CFLAGS = -Wno-unused-parameter AM_CFLAGS += -I $(top_srcdir)/service/inc/public -I $(top_srcdir)/snd_parser/inc + +if USE_GLIB AM_CFLAGS += $(GLIB_CFLAGS) -include glib.h +endif + if USE_G_STR_FUNC AM_CFLAGS += -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat endif -AM_CFLAGS += -DAGM_USE_SYSLOG + +if !MEMLOGGER_SUPPORTED AM_CFLAGS += @KVH2XML_CFLAGS@ AM_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\) AM_CFLAGS += -Wl,-z,defs @@ -48,8 +53,8 @@ lib_LTLIBRARIES += libagm_mixer_plugin.la libagm_mixer_plugin_la_SOURCES = src/agm_mixer_plugin.c libagm_mixer_plugin_la_CFLAGS = $(AM_CFLAGS) libagm_mixer_plugin_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -libagm_mixer_plugin_la_LDFLAGS = -shared -version-number @LT_VERSION_NUMBER@ -L$(top_builddir)/snd_parser/.libs -libagm_mixer_plugin_la_LIBADD = -ltinyalsa -lsndcardparser $(GLIB_LIBS) +libagm_mixer_plugin_la_LDFLAGS =-avoid-version -shared -L$(top_builddir)/snd_parser/.libs +libagm_mixer_plugin_la_LIBADD = -ltinyalsa -lsndcardparser if AGM_NO_IPC libagm_mixer_plugin_la_CFLAGS += -DAGM_NO_IPC libagm_mixer_plugin_la_LDFLAGS += -L$(top_builddir)/service/.libs @@ -58,3 +63,11 @@ else libagm_mixer_plugin_la_LIBADD += -lagmclient libagm_mixer_plugin_la_LDFLAGS += -L$(top_builddir)/ipc/DBus/agm_client/.libs endif + +if AGM_IPC_SWBINDER +libagm_mixer_plugin_la_LIBADD += -L$(top_builddir)/ipc/SwBinders/agm_client/.libs/ -lagmclientwrapper +endif + +if USE_GLIB +libagm_mixer_plugin_la_LIBADD += $(GLIB_LIBS) +endif diff --git a/plugins/tinyalsa/test/Makefile.am b/plugins/tinyalsa/test/Makefile.am index cf29d8af..aba49d1a 100644 --- a/plugins/tinyalsa/test/Makefile.am +++ b/plugins/tinyalsa/test/Makefile.am @@ -3,8 +3,11 @@ pkgconfig_DATA = agmtest.pc EXTRA_DIST = $(pkgconfig_DATA) AM_CFLAGS = -Wno-unused-parameter -Wno-unused-result -AM_CFLAGS += -I$(top_srcdir)/service/inc/public -AM_CFLAGS += $(GLIB_CFLAGS) -include glib.h @KVH2XML_CFLAGS@ +AM_CFLAGS += -I${includedir}/acdbdata -I$(top_srcdir)/service/inc/public +if USE_GLIB +AM_CFLAGS += $(GLIB_CFLAGS) -include glib.h +endif +AM_CFLAGS += @KVH2XML_CFLAGS@ if USE_G_STR_FUNC AM_CFLAGS += -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat @@ -14,8 +17,12 @@ AM_CFLAGS += -DBACKEND_CONF_FILE=\"/etc/backend_conf.xml\" lib_LTLIBRARIES = libagmmixer.la libagmmixer_la_SOURCES = agmmixer.c libagmmixer_la_CFLAGS = $(AM_CFLAGS) -libagmmixer_la_LDFLAGS = -shared -version-number @LT_VERSION_NUMBER@ -libagmmixer_la_LIBADD = -ltinyalsa -ldl -lexpat @GLIB_LIBS@ +libagmmixer_la_LDFLAGS = -avoid-version -shared +libagmmixer_la_LIBADD = -ltinyalsa -ldl -lexpat + +if USE_GLIB +libagmmixer_la_LIBADD += @GLIB_LIBS@ +endif bin_PROGRAMS = agmplay agmplay_SOURCES = agmplay.c @@ -33,4 +40,4 @@ agmcap_LDADD = -ltinyalsa libagmmixer.la root_etcdir = "/etc" root_etc_SCRIPTS = backend_conf.xml install-data-hook: - chmod go-x $(DESTDIR)$(root_etcdir)/backend_conf.xml + chmod go-x $(DESTDIR)$(root_etcdir)/backend_conf.xml diff --git a/plugins/tinyalsa/test/agmcap.c b/plugins/tinyalsa/test/agmcap.c index 20ce9d67..3cf6028b 100644 --- a/plugins/tinyalsa/test/agmcap.c +++ b/plugins/tinyalsa/test/agmcap.c @@ -80,9 +80,9 @@ static void sigint_handler(int sig) capturing = 0; } -static void usage(char *progname) +static void usage(const char *progname) { - printf(" Usage: file.wav in /data [-help print usage] [-D card] [-d device]\n" + printf(" Usage: %s file.wav in /data [-help print usage] [-D card] [-d device]\n" " [-c channels] [-r rate] [-b bits] [-p period_size]\n" " [-n n_periods] [-T capture time] [-i intf_name] [-dkv device_kv]\n" " [-dppkv deviceppkv] : Assign 0 if no device pp in the graph\n" @@ -98,6 +98,7 @@ int main(int argc, char **argv) { FILE *file; struct wav_header header; + const char *progname = argv[0]; unsigned int card = 100; unsigned int device = 101; unsigned int usb_device = 1; @@ -120,7 +121,7 @@ int main(int argc, char **argv) bool is_24_LE = false; if (argc < 2) { - usage(argv[0]); + usage(progname); return 1; } @@ -208,7 +209,7 @@ int main(int argc, char **argv) if (*argv) usb_device = atoi(*argv); }else if (strcmp(*argv, "-help") == 0) { - usage(argv[0]); + usage(progname); } if (*argv) argv++; diff --git a/plugins/tinyalsa/test/agmplay.c b/plugins/tinyalsa/test/agmplay.c index 9e8bff8f..c04af299 100644 --- a/plugins/tinyalsa/test/agmplay.c +++ b/plugins/tinyalsa/test/agmplay.c @@ -74,7 +74,7 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in unsigned int channels, unsigned int rate, unsigned int bits, unsigned int *device_kv, unsigned int stream_kv, unsigned int instance_kv, unsigned int *devicepp_kv, struct chunk_fmt fmt, bool haptics, char **intf_name, - int intf_num, bool is_24_LE); + int intf_num, bool is_24_LE, unsigned int period_size, unsigned int period_count); void stream_close(int sig) { @@ -83,10 +83,10 @@ void stream_close(int sig) close = 1; } -static void usage(char *progname) +static void usage(const char *progname) { - printf(" Usage: file.wav in /data [-help print usage] [-D card] [-d device]\n" - " [-c channels] [-r rate] [-b bits]\n" + printf(" Usage: %s file.wav [-help print usage] [-D card] [-d device]\n" + " [-c channels] [-r rate] [-b bits] [-p period_size] [-n n_periods]\n" " [-num_intf num of interfaces followed by interface name]\n" " [-i intf_name] : Can be multiple if num_intf is more than 1\n" " [-dkv device_kv] : Can be multiple if num_intf is more than 1\n" @@ -105,11 +105,14 @@ int main(int argc, char **argv) struct riff_wave_header riff_wave_header; struct chunk_header chunk_header; struct chunk_fmt chunk_fmt; + const char *progname = argv[0]; unsigned int card = 100, device = 100, i=0; unsigned int usb_device = 1; unsigned int channels = 2; unsigned int rate = 48000; unsigned int bits = 16; + unsigned int period_size = 1024; + unsigned int period_count = 4; int intf_num = 1; uint32_t dkv = SPEAKER; uint32_t dppkv = DEVICEPP_RX_AUDIO_MBDRC; @@ -129,7 +132,7 @@ int main(int argc, char **argv) } if (argc < 3) { - usage(argv[0]); + usage(progname); return 1; } @@ -207,6 +210,14 @@ int main(int argc, char **argv) argv++; if (*argv) card = atoi(*argv); + } else if (strcmp(*argv, "-p") == 0) { + argv++; + if (*argv) + period_size = atoi(*argv); + } else if (strcmp(*argv, "-n") == 0) { + argv++; + if (*argv) + period_count = atoi(*argv); } else if (strcmp(*argv, "-num_intf") == 0) { argv++; if (*argv) @@ -273,7 +284,7 @@ int main(int argc, char **argv) if (*argv) usb_device = atoi(*argv); } else if (strcmp(*argv, "-help") == 0) { - usage(argv[0]); + usage(progname); } if (*argv) argv++; @@ -283,7 +294,8 @@ int main(int argc, char **argv) return 1; play_sample(file, card, device, usb_device, channels, rate, bits, device_kv, stream_kv, - instance_kv, devicepp_kv, chunk_fmt, haptics, intf_name, intf_num, is_24_LE); + instance_kv, devicepp_kv, chunk_fmt, haptics, intf_name, intf_num, is_24_LE, + period_size, period_count); fclose(file); if (device_kv) @@ -300,7 +312,7 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in unsigned int channels, unsigned int rate, unsigned int bits, unsigned int *device_kv, unsigned int stream_kv, unsigned int instance_kv, unsigned int *devicepp_kv, struct chunk_fmt fmt, bool haptics, char **intf_name, - int intf_num, bool is_24_LE) + int intf_num, bool is_24_LE, unsigned int period_size, unsigned int period_count) { struct pcm_config config; struct pcm *pcm; @@ -336,8 +348,8 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in memset(&config, 0, sizeof(config)); config.channels = fmt.num_channels; config.rate = fmt.sample_rate; - config.period_size = 1024; - config.period_count = 4; + config.period_size = period_size; + config.period_count = period_count; if (fmt.bits_per_sample == 32) { if (is_24_LE) config.format = PCM_FORMAT_S24_LE; diff --git a/service/Makefile.am b/service/Makefile.am index 4cc8f249..c81385bc 100644 --- a/service/Makefile.am +++ b/service/Makefile.am @@ -35,13 +35,22 @@ if USE_DEFAULT_ACDB_PATH libagm_la_CFLAGS += -DUSE_DEFAULT_ACDB_PATH endif +if CUTILS_SUPPORTED +libagm_la_LIBADD += -lcutils -llog +AM_CFLAGS += -DAGM_USE_CUTILS +endif + if USE_SYSLOG libagm_la_CFLAGS += -DAGM_USE_SYSLOG endif + +if MEMLOGGER_SUPPORTED +libagm_la_LIBADD += -laudio_log_utils -larmemlog +else libagm_la_CFLAGS += -DAGM_MEMLOG_UNSUPPORTED if USE_GLIB -libagm_la_LIBADD += -lglib-2.0 +libagm_la_LIBADD += $(GLIB_LIBS) libagm_la_CFLAGS += $(GLIB_CFLAGS) -include glib.h endif diff --git a/service/src/agm.c b/service/src/agm.c index 8acbb256..954873eb 100644 --- a/service/src/agm.c +++ b/service/src/agm.c @@ -37,6 +37,8 @@ #include #ifndef AGM_MEMLOG_UNSUPPORTED #include +#else +#include "gsl_intf.h" #endif #include "ats.h" #include diff --git a/snd_parser/Makefile.am b/snd_parser/Makefile.am index 419d59c2..e9cff26e 100644 --- a/snd_parser/Makefile.am +++ b/snd_parser/Makefile.am @@ -12,7 +12,7 @@ lib_includedir = $(includedir)/sndparser/ AM_CFLAGS = -I $(srcdir)/inc -I $(top_srcdir)/service/inc/public AM_CFLAGS += -Wno-unused-parameter AM_CFLAGS += -DCARD_DEF_FILE=\"/etc/card-defs.xml\" -AM_CFLAGS += -DCARD_DEF_FILE_NATIVE=\"/etc/card-defs-native.xml\" +AM_CFLAGS += -DCARD_DEF_FILE_NATIVE=\"@CARD_DEF_FILE_NATIVE@\" AM_CFLAGS += -Wl,-z,defs lib_LTLIBRARIES = libsndcardparser.la