From 453d284c97ddb364d769fe83719adfbb168b4b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 3 Apr 2025 16:17:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?idel=20to=20suspend=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- ohosbuild/src/modules/BUILD.gn | 5 ++++- src/modules/module-suspend-on-idle.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ohosbuild/src/modules/BUILD.gn b/ohosbuild/src/modules/BUILD.gn index 2cd5b4ee0..59c88cb8b 100644 --- a/ohosbuild/src/modules/BUILD.gn +++ b/ohosbuild/src/modules/BUILD.gn @@ -142,7 +142,10 @@ ohos_shared_library("module-suspend-on-idle") { configs = [ ":common_config" ] deps = [ ":common_deps" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "init:libbegetutil", + "hilog:libhilog" + ] subsystem_name = "thirdparty" part_name = "pulseaudio" } diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c index 1cb699df9..aea41bdd8 100644 --- a/src/modules/module-suspend-on-idle.c +++ b/src/modules/module-suspend-on-idle.c @@ -32,6 +32,7 @@ #include #include #include "log/audio_log.h" +#include "parameter.h" PA_MODULE_AUTHOR("Lennart Poettering"); PA_MODULE_DESCRIPTION("When a sink/source is idle for too long, suspend it"); @@ -44,6 +45,8 @@ static const char* const valid_modargs[] = { NULL, }; +static const char* SUSPEND_ON_IDEL_TIMEOUT_KEY = "const.audio.suspend_idle_timeout"; +static const char* SUSPEND_ON_IDEL_DEFAULT_TIMEOUT = "3"; struct userdata { pa_core *core; pa_usec_t timeout; @@ -332,6 +335,14 @@ static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct user pa_assert(source || sink); timeout_str = pa_proplist_gets(sink ? sink->proplist : source->proplist, "module-suspend-on-idle.timeout"); + char paraValue[30] = {0}; //30 for system parameter + int32_t res = + GetParameter(SUSPEND_ON_IDEL_TIMEOUT_KEY, SUSPEND_ON_IDEL_DEFAULT_TIMEOUT, paraValue, sizeof(paraValue)); + if (res >0) { + AUDIO_INFO_LOG("Get timeout for system parameter, value is %{pubilc}s", paraValue); + timeout_str = paraValue; + } + if (timeout_str && pa_atoi(timeout_str, &timeout) >= 0) timeout_valid = true; else @@ -340,6 +351,7 @@ static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct user if (timeout_valid && timeout < 0) return PA_HOOK_OK; + AUDIO_INFO_LOG("timeout_str : %{pubilc}s, timeout_valid : %{pubilc}d", timeout_str, timeout_valid); d = pa_xnew(struct device_info, 1); d->userdata = u; d->source = source ? pa_source_ref(source) : NULL; -- Gitee From c10e7d6ff65eab55df8103310c01a2b7237abec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=BF=97=E5=BA=86?= Date: Thu, 3 Apr 2025 16:29:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?idel=20to=20suspend=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蒋志庆 --- ohosbuild/src/modules/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ohosbuild/src/modules/BUILD.gn b/ohosbuild/src/modules/BUILD.gn index 59c88cb8b..eccae1d0b 100644 --- a/ohosbuild/src/modules/BUILD.gn +++ b/ohosbuild/src/modules/BUILD.gn @@ -143,8 +143,8 @@ ohos_shared_library("module-suspend-on-idle") { configs = [ ":common_config" ] deps = [ ":common_deps" ] external_deps = [ + "hilog:libhilog", "init:libbegetutil", - "hilog:libhilog" ] subsystem_name = "thirdparty" part_name = "pulseaudio" -- Gitee