Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1149398imu; Tue, 20 Nov 2018 12:31:42 -0800 (PST) X-Google-Smtp-Source: AJdET5eRNY2ZbTlvRGAH5HtTh35ug5NGAD2hDhy9qztYFfXE9T+t5aMYTSHqfS4lkJ+79bVb3AmC X-Received: by 2002:a62:59cd:: with SMTP id k74-v6mr3687464pfj.243.1542745902774; Tue, 20 Nov 2018 12:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542745902; cv=none; d=google.com; s=arc-20160816; b=zcIsvXqR8CWWSFWU/4mi/5x70Qv0WT9nzRn1QBwTFrCFijLktQDkN0sKEGqJwH8Lia MZ9NGrII6XtwNnr+uNvjC/83X91bTdLal1/Iu+VxGfJS2bm4fyXPmZv0Er4HX68NIhYB fGJEv/OlYUH2HLPwP3LDJ5dfC/H9Y0iJOuHwceLWWsSN5jNq2WRCsVFyd2OjDbqNgXmT Fvck1wbrFAO3C+/OWC9JLW7IddoY9VzDetJJ+hcos5wtS0H6yjwVwcLLI6swj6TgNtbE vn99BjRjn9QbHSD1Etl1nL+4fXRfRqr28lGOS1B8N+INjoFXTmy7/YwYRURuOnLACMCx QdjA== 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:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date; bh=WdEp+wFP98y7syYdY7lR3bGlh5nUH8nq0MY6uwOYOvE=; b=LQzJ47FWBktLRE9H3ziADjexUOIye9+UMbNXP8yOfp16giPutpqeLJ0kmkSY19nJjz O0Texw7LNZL8ih7afnhtTA/2Z9LFInRAJFyny4UrA9d8oX9yxFWqATj5qSoX3hlMyFLu rp4h6IhimHNVr3SoEMWdZhTyskFGb+YXB40kdsh7vc3MPt/BzAUQ4KqCjAn6DJBdpEgg xg1Jx60XCMjTz0of94cs3i4W0fIEqpy3kSXzO51DXMKb+uOIQ8jtbotC4Jqfr3JAMe8d bUv1sEb2enSWo5w0JoKiJJ4BiBo0BBwJatApu/0XMDC7wcKSzgqWyfxaeZWkDTq2q4EP R5Cg== 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 o6-v6si51351762pfa.162.2018.11.20.12.31.27; Tue, 20 Nov 2018 12:31:42 -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 S1726644AbeKUGg1 (ORCPT + 99 others); Wed, 21 Nov 2018 01:36:27 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:47400 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbeKUGg1 (ORCPT ); Wed, 21 Nov 2018 01:36:27 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id B91FA35A8; Tue, 20 Nov 2018 21:05:33 +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 UGCeDk08eBse; Tue, 20 Nov 2018 21:05:31 +0100 (CET) Received: from function (unknown [212.51.165.254]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 4FDD235B2; Tue, 20 Nov 2018 21:05:31 +0100 (CET) Received: from samy by function with local (Exim 4.91) (envelope-from ) id 1gPCH4-0005XY-Ul; Tue, 20 Nov 2018 21:05:30 +0100 Date: Tue, 20 Nov 2018 21:05:30 +0100 From: Samuel Thibault To: akpm@linux-foundation.org, speakup@braille.uwo.ca, linux-kernel@vger.kernel.org Subject: staging/speakup_soft: Fix alternate speech with other synths Message-ID: <20181120200530.xlntzbyfrq3xjz6n@function> Mail-Followup-To: Samuel Thibault , akpm@linux-foundation.org, speakup@braille.uwo.ca, linux-kernel@vger.kernel.org References: <20181023193624.6oftkzsziwz5jm7o@function> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181023193624.6oftkzsziwz5jm7o@function> 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 };