Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3878287ima; Tue, 23 Oct 2018 12:46:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5e6gQ1ry6tAVgFe2XZ0YLshSliI+2ubdzBC3ONmuf9XBcq6gB/Gn8ISitZx656UYP5mzOro X-Received: by 2002:a17:902:b203:: with SMTP id t3-v6mr5617118plr.128.1540324019343; Tue, 23 Oct 2018 12:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540324019; cv=none; d=google.com; s=arc-20160816; b=A+bzI+0ggcaHAXL4IaT5+5AE/U1Nqp2A6j6FCtUK3h2M38wljmk2Rs0GSzftltFkjZ GQqoenZ9jqIV2LAPT1MVyOcBzHiivPWXeg4PqQ934V6yZR+gSbILzcbTbJVhctkforjd LGkAlYSkf3L7g91SBH0YnpFAdZMgE/kD6A2Xue+cwwlFfqyFK6Pb3iXEfo0ZeqfD4nYS 3xbUq0CgIrkQ3BxAT140KlfWCHyPUJZ+7ahGffT8kVrtVjPqx1vV38K9+c3Adi9M6A/p 7I7Hot650HPA6fXO09My4N0yFZN4WQpI3CROVmllt0kTQxwkKVVIji1Z/XNrPIhUO+pf ioyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization :content-disposition:mime-version:mail-followup-to:message-id :subject:cc:to:from:date; bh=WdEp+wFP98y7syYdY7lR3bGlh5nUH8nq0MY6uwOYOvE=; b=fX75BuWFlMElyYhe7TqjZzHYWHxehxAjpDdrxVMxqN+n55RCypXEiklAW36ODgAkSh /1XlrozHgYygSytnGrB+zWEG6hTqznD31WOsrxEWPN2ubj6/wWhp62eWz2eowLFwNqDf fmntkLKqkV7LLXr4RkKbucuTFLMoBtxCUEJgPPV3BUdvB1AiJODnpdzDZ37jdfuSmF/m SQ8LLcZSDXfRoYBGXSaXTv7aDICTB/o62Q/u7tO84mHXFVYxC6Q4r0NwKol91bypHRYm wsbaIDp8j3evt7r/Zn0H/Xge/IkKsHFurkM/iSkPbt8Ar0RnoMF2bkJmPelPfUFTDeu6 Rhdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32-v6si2098691pgf.203.2018.10.23.12.46.43; Tue, 23 Oct 2018 12:46:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbeJXEKW (ORCPT + 99 others); Wed, 24 Oct 2018 00:10:22 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:34646 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeJXEKW (ORCPT ); Wed, 24 Oct 2018 00:10:22 -0400 X-Greylist: delayed 547 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Oct 2018 00:10:22 EDT Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8015E1813; Tue, 23 Oct 2018 21:36:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J-zyL5tBIPKo; Tue, 23 Oct 2018 21:36:25 +0200 (CEST) Received: from function (lfbn-bor-1-169-137.w90-50.abo.wanadoo.fr [90.50.25.137]) by hera.aquilenet.fr (Postfix) with ESMTPSA id C2CC917D4; Tue, 23 Oct 2018 21:36:25 +0200 (CEST) Received: from samy by function with local (Exim 4.91) (envelope-from ) id 1gF2TY-0001Im-Vn; Tue, 23 Oct 2018 21:36:24 +0200 Date: Tue, 23 Oct 2018 21:36:24 +0200 From: Samuel Thibault To: akpm@linux-foundation.org Cc: speakup@braille.uwo.ca, linux-kernel@vger.kernel.org Subject: staging/speakup_soft: Fix alternate speech with other synths Message-ID: <20181023193624.6oftkzsziwz5jm7o@function> Mail-Followup-To: Samuel Thibault , akpm@linux-foundation.org, speakup@braille.uwo.ca, linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: I am not organized User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When switching from speakup_soft to another synth, speakup_soft would keep calling synth_buffer_getc() from softsynthx_read. Let's thus make synth.c export the knowledge of the current synth, so that speakup_soft can determine whether it should be running. speakup_soft also needs to set itself alive, otherwise the switch would let it remain silent. Signed-off-by: Samuel Thibault --- drivers/staging/speakup/speakup_soft.c | 16 +++++++++++----- drivers/staging/speakup/spk_priv.h | 1 + drivers/staging/speakup/synth.c | 6 ++++++ 3 files changed, 18 insertions(+), 5 deletions(-) --- a/drivers/staging/speakup/speakup_soft.c +++ b/drivers/staging/speakup/speakup_soft.c @@ -208,12 +208,15 @@ static ssize_t softsynthx_read(struct fi return -EINVAL; spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_soft.alive = 1; while (1) { prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); - if (!unicode) - synth_buffer_skip_nonlatin1(); - if (!synth_buffer_empty() || speakup_info.flushing) - break; + if (synth_current() == &synth_soft) { + if (!unicode) + synth_buffer_skip_nonlatin1(); + if (!synth_buffer_empty() || speakup_info.flushing) + break; + } spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (fp->f_flags & O_NONBLOCK) { finish_wait(&speakup_event, &wait); @@ -233,6 +236,8 @@ static ssize_t softsynthx_read(struct fi /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ while (chars_sent <= count - bytes_per_ch) { + if (synth_current() != &synth_soft) + break; if (speakup_info.flushing) { speakup_info.flushing = 0; ch = '\x18'; @@ -329,7 +334,8 @@ static __poll_t softsynth_poll(struct fi poll_wait(fp, &speakup_event, wait); spin_lock_irqsave(&speakup_info.spinlock, flags); - if (!synth_buffer_empty() || speakup_info.flushing) + if (synth_current() == &synth_soft && + (!synth_buffer_empty() || speakup_info.flushing)) ret = EPOLLIN | EPOLLRDNORM; spin_unlock_irqrestore(&speakup_info.spinlock, flags); return ret; --- a/drivers/staging/speakup/spk_priv.h +++ b/drivers/staging/speakup/spk_priv.h @@ -72,6 +72,7 @@ int synth_request_region(unsigned long s int synth_release_region(unsigned long start, unsigned long n); int synth_add(struct spk_synth *in_synth); void synth_remove(struct spk_synth *in_synth); +struct spk_synth *synth_current(void); extern struct speakup_info_t speakup_info; --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -495,4 +495,10 @@ void synth_remove(struct spk_synth *in_s } EXPORT_SYMBOL_GPL(synth_remove); +struct spk_synth *synth_current(void) +{ + return synth; +} +EXPORT_SYMBOL_GPL(synth_current); + short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };