[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#686742: linux: speakup: lower default software speech rate



On Wed, 2012-09-05 at 10:33 +0200, Samuel Thibault wrote:
> Package: linux
> Version: 3.2.23-1
> Severity: important
> Tags: patch
> 
> Hello,
> 
> The following patch has been applied to greg's staging tree, it would be
> important to get it into Wheezy, as it noticeably improves usability for
> blind users.
[...]

OK, I will do.

But I looked at what exactly is done with this 'vars' table and... it
looks really nasty.  This goes into an initialisation string which will
be the first thing the userland synthesiser gets when it reads the
softsynth char device, right?

However:
1. The last character of the init string will be repeated.
2. If the read() caller doesn't provide a big enough buffer for the init
string, the next read() will get it again from the start, so it can
never make progress.

Would you be able to test the attached patch, that should fix those
bugs?

Ben.

-- 
Ben Hutchings
Make three consecutive correct guesses and you will be considered an expert.
From 1e360a61f7af79f0aefc3643ee3006e03f017689 Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 10 Sep 2012 03:38:41 +0100
Subject: [PATCH] staging: speakup_soft: Fix reading of init string

softsynth_read() reads a character at a time from the init string;
when it finds the null terminator it sets the initialized flag but
then repeats the last character.

Additionally, if the read() buffer is not big enough for the init
string, the next read() will start reading from the beginning again.
So the caller may never progress to reading anything else.

Replace the simple initialized flag with the current position in
the init string, carried over between calls.  Switch to reading
real data once this reaches the null terminator.

(This assumes that the length of the init string can't change, which
seems to be the case.  Really, the string and position belong together
in a per-file private struct.)

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/staging/speakup/speakup_soft.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
index 2a67610..e2f5c81 100644
--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -40,7 +40,7 @@ static int softsynth_is_alive(struct spk_synth *synth);
 static unsigned char get_index(void);
 
 static struct miscdevice synth_device;
-static int initialized;
+static int init_pos;
 static int misc_registered;
 
 static struct var_t vars[] = {
@@ -194,7 +194,7 @@ static int softsynth_close(struct inode *inode, struct file *fp)
 	unsigned long flags;
 	spk_lock(flags);
 	synth_soft.alive = 0;
-	initialized = 0;
+	init_pos = 0;
 	spk_unlock(flags);
 	/* Make sure we let applications go before leaving */
 	speakup_start_ttys();
@@ -239,13 +239,8 @@ static ssize_t softsynth_read(struct file *fp, char *buf, size_t count,
 			ch = '\x18';
 		} else if (synth_buffer_empty()) {
 			break;
-		} else if (!initialized) {
-			if (*init) {
-				ch = *init;
-				init++;
-			} else {
-				initialized = 1;
-			}
+		} else if (init[init_pos]) {
+			ch = init[init_pos++];
 		} else {
 			ch = synth_buffer_getc();
 		}

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: