Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5370794imb; Thu, 7 Mar 2019 14:07:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwHCv3glTFrHKHCUvizWrmJtt9JviRrTpQ+VCVFNU1Oc8jWC1fjYLZRgapjoeFwlnxaswRA X-Received: by 2002:a63:d04f:: with SMTP id s15mr13548471pgi.80.1551996461852; Thu, 07 Mar 2019 14:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551996461; cv=none; d=google.com; s=arc-20160816; b=e3rt8/Lb/C07DbDKEUFKvTLgCKIYfIZSFnfUjt58ygPgQaCzMvLBRNIMvFkCWONnT8 CSgw48EhqH5P5nNU197ziDDFs+QSqjLwMY8WLPFG5EBAEOWJShsa74LTe/A/klgaqy55 Ynabf9GWlPlCwsGqOd4zKnEdY5aDWl+o8QJphAdmuyTW9Q122rubBVLSm/oh2LJx9U2s iN8sS046Uv4DI4fuWUzWrny3Sub7NhuRmkn7pvov94JQPYqDjNrwjyDselS8huFfPW2N g4Rh0Uq1z6jB1NFiZEKjsW0TNcWUhqUeYALT7ccugE13J7GxiXj4Y6xbdNo8LOoqyyxB p31g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:mail-followup-to:message-id:subject:cc:to:from:date; bh=WdEp+wFP98y7syYdY7lR3bGlh5nUH8nq0MY6uwOYOvE=; b=MghcB68vjTDhHqD8EB/pL0bi1jXXulE03UdTXe0RrMlEwCwqs8A8h4LRMSzZkJKqcF Cw/C9bRpdpkGgrhff3gR0jlDEClhnwJP5EIqbDkssLe4ci5YdPI8wg40QhXqNPGsQ6kJ TvGp8MQGfsFRXRkO8WI5mzHVb+wJY7c1gVg61pNHHU7s6FNg3dam6byLW4Njbm8ZqmFr cAthyiI/LYxEd2c15cW+DciAuQWGcEXY3IiczCTecsy2TfoYkwRib/gHph/oNEwKGEFt 8S5ybCWMJuanv/TSBwQ9abIOTS7Wi0ReYgpA/79bsr82O+fCrGk5BIzpEuoea/XlTnnb ucUQ== 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 a15si4894386pgg.560.2019.03.07.14.07.26; Thu, 07 Mar 2019 14:07:41 -0800 (PST) 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 S1726309AbfCGWHB (ORCPT + 99 others); Thu, 7 Mar 2019 17:07:01 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:57528 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfCGWHA (ORCPT ); Thu, 7 Mar 2019 17:07:00 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 0AB4B126DF; Thu, 7 Mar 2019 23:06:59 +0100 (CET) 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 rHdssakLjNzt; Thu, 7 Mar 2019 23:06:58 +0100 (CET) Received: from function (dhcp-97-35.dsi-ext.ens-lyon.fr [140.77.97.35]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 6A1A4126DC; Thu, 7 Mar 2019 23:06:58 +0100 (CET) Received: from samy by function with local (Exim 4.92) (envelope-from ) id 1h21AH-0006fz-TN; Thu, 07 Mar 2019 23:06:57 +0100 Date: Thu, 7 Mar 2019 23:06:57 +0100 From: Samuel Thibault To: gregkh@linuxfoundation.org Cc: speakup@braille.uwo.ca, linux-kernel@vger.kernel.org Subject: staging/speakup_soft: Fix alternate speech with other synths Message-ID: <20190307220657.huhswewazlo5mp5x@function> Mail-Followup-To: Samuel Thibault , gregkh@linuxfoundation.org, speakup@braille.uwo.ca, linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 };