From patchwork Sun Jan 24 00:30:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 8098231 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DEBF79F818 for ; Sun, 24 Jan 2016 00:30:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECB6420380 for ; Sun, 24 Jan 2016 00:30:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id BFDB520373 for ; Sun, 24 Jan 2016 00:30:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 090D3260502; Sun, 24 Jan 2016 01:30:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BF678260505; Sun, 24 Jan 2016 01:30:40 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 37325260505; Sun, 24 Jan 2016 01:30:39 +0100 (CET) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by alsa0.perex.cz (Postfix) with ESMTP id B0DC426048C; Sun, 24 Jan 2016 01:30:32 +0100 (CET) Received: by mail-pf0-f182.google.com with SMTP id e65so62294224pfe.0; Sat, 23 Jan 2016 16:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=IFhLhta8MjCCkUxq6rzTzUydBiHYhxLRPx3hPrOlw34=; b=c7V3vS99vtgat3cxM5yS9020MKOSV8tyf7PhqIbVQSSSHqAqDoTS2UmwY4lCgZFhUr oV2vIFS4f2W9p2JzUu8FDePvLbbmMHi/xfj9jhtAXtag3rdlxjSnQ0VeMOVAA1SMBxqD qJO/IxunK27Eb1unKuzB/d9l1FfUZtcEIOOrViXkioDnbRrzW1QPlNINW4/nL+5fRTha UUfXsj39LuRB0wxLJCtUvUp/EZHmaYc52sI9RNUuqmZJ3Aj3xIsDhRTGPMX+3o/inWVA QM1e0hS7HTIdqpVzQb/TFeGwTJICre53wb8F5eZM2+3jK29lhF05dLlfqstmcqwB0P19 HOOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=IFhLhta8MjCCkUxq6rzTzUydBiHYhxLRPx3hPrOlw34=; b=dCOtlEZ3p/Dj5kN6FnyR700FSl4Y/J+hKPTpCkAt5UpMO4R4uucUdHfL8c5wgBmzxO CjbrvGFLyFQWBbE6cpD8vmFcQGt54n8RRKRK4OzxgGcEckVt+HQ6ZDaa+/qh+kiXcqnb 5l+e435O2iSj/1R3GbUlsYw8OyHDP9Irpi18jAoufAibByXIlLoZ5WxsUKD7CAYqjycl AogHcImxjGbdUvJTZDyyFy5t6D6W9RdID5m+G+mBD+GivSfnNfrU3BPV0D43HPkcxImJ CixYYeu670LbZSRqOBq7+JrmEtAOwM9xDIadOD+T6vBWBR3NU29fFQVBllh0LNL8Umaf WiJA== X-Gm-Message-State: AG10YOTd+LvgIC1Gw4JS4Liud7Pvh6ZMcr/aS0h8O0DXtRqQH2t0ok+3UniWnaaDsc2EZg== X-Received: by 10.98.86.214 with SMTP id h83mr15299621pfj.112.1453595431294; Sat, 23 Jan 2016 16:30:31 -0800 (PST) Received: from localhost.localdomain (123202047244.ctinets.com. [123.202.47.244]) by smtp.gmail.com with ESMTPSA id c86sm18680908pfd.75.2016.01.23.16.30.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 23 Jan 2016 16:30:30 -0800 (PST) Message-ID: <56a41b26.5908620a.ff61a.6c10@mx.google.com> X-Google-Original-Message-ID: <1453595423-611-1-git-send-email-me> From: tom.ty89@gmail.com X-Google-Original-From: me To: patch@alsa-project.org Date: Sun, 24 Jan 2016 08:30:23 +0800 X-Mailer: git-send-email 2.7.0 Cc: alsa-devel@alsa-project.org, Tom Yan Subject: [alsa-devel] [PATCH - alsactl 1/1] make systemd service start in proper way X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Yan Use sound.target to trigger the service, which is the proper way to start a service related to sound card. This also makes sure that the service will only start if a sound card exists in the system. basic.target is too early for either of the service: 1. alsa-state.service will spam "No soundcards found" on every boot 2. alsa-restore.service will never start because of "ConditionPathExistsGlob=/dev/snd/control*" "After=sysinit.target" is removed from alsa-state.service because it never made any sense. "After=alsa-state.service" is removed from alsa-restore.service because it is completely unnecessary with the daemon conf switch. Now either of serivce is enough to manage the state all by itself without the udev rules if only ONE sound card exists in the system, while the rules are still necessary in system with multiple sound cards. "StandardOutput=syslog" is also removed from alsa-restore.service because it makes little sense (if it has ever switched the behaviour away from default). Signed-off-by: Tom Yan diff --git a/alsactl/Makefile.am b/alsactl/Makefile.am index cac8094..90fab9d 100644 --- a/alsactl/Makefile.am +++ b/alsactl/Makefile.am @@ -29,8 +29,8 @@ systemdsystemunit_DATA = \ install-data-hook: $(MKDIR_P) -m 0755 \ - $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants - ( cd $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants && \ + $(DESTDIR)$(systemdsystemunitdir)/sound.target.wants + ( cd $(DESTDIR)$(systemdsystemunitdir)/sound.target.wants && \ rm -f alsa-state.service alsa-restore.service && \ $(LN_S) ../alsa-state.service alsa-state.service && \ $(LN_S) ../alsa-restore.service alsa-restore.service) diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in index 2884098..fbcf983 100644 --- a/alsactl/alsa-restore.service.in +++ b/alsactl/alsa-restore.service.in @@ -6,12 +6,9 @@ [Unit] Description=Save/Restore Sound Card State ConditionPathExists=!@daemonswitch@ -ConditionPathExistsGlob=/dev/snd/control* -After=alsa-state.service [Service] Type=oneshot RemainAfterExit=true ExecStart=-@sbindir@/alsactl restore ExecStop=-@sbindir@/alsactl store -StandardOutput=syslog diff --git a/alsactl/alsa-state.service.in b/alsactl/alsa-state.service.in index f1321d6..5a8fe5e 100644 --- a/alsactl/alsa-state.service.in +++ b/alsactl/alsa-state.service.in @@ -6,7 +6,6 @@ [Unit] Description=Manage Sound Card State (restore and store) ConditionPathExists=@daemonswitch@ -After=sysinit.target [Service] Type=simple