speechd-discuss
[Top][All Lists]
Advanced

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

Re: Is there an off-by-1 bug in notification callbacks?


From: Nolan Darilek
Subject: Re: Is there an off-by-1 bug in notification callbacks?
Date: Wed, 19 Aug 2020 10:38:56 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

OK, sort of figured it out--I'm not strong in the C. :) Looks like the state parameter is the index into the enum values, not the value itself. I.e. cancel notifications send 3, the index of SPD_NOTIFICATION_CANCEL in the enum, rather than the value which is 8.


Is it just me, or is that strange? Anyway, I'll see how to make Rust convert that to an enum value I can match on.

On 8/19/20 10:05 AM, Nolan Darilek wrote:

I've written a Rust binding to speech-dispatcher, but one notable missing feature is notification callbacks. I've defined my callback like so:


unsafe extern "C" fn cb(msg_id: u64, client_id: u64, state: u32) {
println!("Here, {}, {}, {}", msg_id, client_id, state);
...
}
I'm noticing an off-by-1 bug with the state parameter, though. In particular, when speaking starts, I get 0, and when it ends, I get 1. The begin and end state enum values are 1 and 2, respectively, and if I add 1 to the state parameter, they seem to match up.
This seems like a fairly major bug to go unspotted, so I'm wondering if I'm missing something here? I don't want to just start manipulating callback values since I might be misunderstanding something.
Also, is there some way to match individual messages with the msg_id parameter in the callback? Say I speak "Hello world" and "Goodbye". How would I match up individual notifications to these utterances such that I can return the msg_id to the caller somehow, and they can track when that given utterance finishes?
Thanks.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]