Merge branch '32bit' into 'master'
Fix msg_id and client_id being size_t in C Closes #5 See merge request ndarilek/speech-dispatcher-rs!5
This commit is contained in:
commit
0efdccc9aa
|
@ -122,12 +122,12 @@ fn c_int_to_result(r: c_int) -> Result<(), Error> {
|
|||
|
||||
#[derive(Default)]
|
||||
struct Callbacks {
|
||||
begin: Option<Box<dyn FnMut(u64, u64)>>,
|
||||
end: Option<Box<dyn FnMut(u64, u64)>>,
|
||||
index_mark: Option<Box<dyn FnMut(u64, u64, String)>>,
|
||||
cancel: Option<Box<dyn FnMut(u64, u64)>>,
|
||||
pause: Option<Box<dyn FnMut(u64, u64)>>,
|
||||
resume: Option<Box<dyn FnMut(u64, u64)>>,
|
||||
begin: Option<Box<dyn FnMut(size_t, size_t)>>,
|
||||
end: Option<Box<dyn FnMut(size_t, size_t)>>,
|
||||
index_mark: Option<Box<dyn FnMut(size_t, size_t, String)>>,
|
||||
cancel: Option<Box<dyn FnMut(size_t, size_t)>>,
|
||||
pause: Option<Box<dyn FnMut(size_t, size_t)>>,
|
||||
resume: Option<Box<dyn FnMut(size_t, size_t)>>,
|
||||
}
|
||||
|
||||
unsafe impl Send for Callbacks {}
|
||||
|
@ -135,13 +135,13 @@ unsafe impl Send for Callbacks {}
|
|||
unsafe impl Sync for Callbacks {}
|
||||
|
||||
lazy_static! {
|
||||
static ref callbacks: Mutex<HashMap<u64, Callbacks>> = {
|
||||
static ref callbacks: Mutex<HashMap<size_t, Callbacks>> = {
|
||||
let m = HashMap::new();
|
||||
Mutex::new(m)
|
||||
};
|
||||
}
|
||||
|
||||
unsafe extern "C" fn cb(msg_id: u64, client_id: u64, state: u32) {
|
||||
unsafe extern "C" fn cb(msg_id: size_t, client_id: size_t, state: u32) {
|
||||
let state = match state {
|
||||
SPDNotificationType_SPD_EVENT_BEGIN => Notification::Begin,
|
||||
SPDNotificationType_SPD_EVENT_END => Notification::End,
|
||||
|
@ -165,7 +165,7 @@ unsafe extern "C" fn cb(msg_id: u64, client_id: u64, state: u32) {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn cb_im(msg_id: u64, client_id: u64, state: u32, index_mark: *mut c_char) {
|
||||
unsafe extern "C" fn cb_im(msg_id: size_t, client_id: size_t, state: u32, index_mark: *mut c_char) {
|
||||
let index_mark = CStr::from_ptr(index_mark);
|
||||
let index_mark = index_mark.to_string_lossy().to_string();
|
||||
let state = match state {
|
||||
|
@ -205,7 +205,7 @@ impl fmt::Display for Error {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Connection(pub Arc<*mut SPDConnection>, u64);
|
||||
pub struct Connection(pub Arc<*mut SPDConnection>, size_t);
|
||||
|
||||
impl Connection {
|
||||
pub fn open<S: Into<String>>(
|
||||
|
@ -287,7 +287,7 @@ impl Connection {
|
|||
if let Some(client_id) = client_id {
|
||||
let client_id: Vec<&str> = client_id.split("-").collect();
|
||||
if let Some(client_id) = client_id.get(1) {
|
||||
if let Ok(client_id) = client_id.parse::<u64>() {
|
||||
if let Ok(client_id) = client_id.parse::<size_t>() {
|
||||
self.1 = client_id;
|
||||
}
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_begin(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
|
||||
pub fn on_begin(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -702,7 +702,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_end(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
|
||||
pub fn on_end(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -711,7 +711,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_cancel(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
|
||||
pub fn on_cancel(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -720,7 +720,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_pause(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
|
||||
pub fn on_pause(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -729,7 +729,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_resume(&self, f: Option<Box<dyn FnMut(u64, u64)>>) {
|
||||
pub fn on_resume(&self, f: Option<Box<dyn FnMut(size_t, size_t)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -738,7 +738,7 @@ impl Connection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_index_mark(&self, f: Option<Box<dyn FnMut(u64, u64, String)>>) {
|
||||
pub fn on_index_mark(&self, f: Option<Box<dyn FnMut(size_t, size_t, String)>>) {
|
||||
if let Ok(mut cbs) = callbacks.lock() {
|
||||
let cb = cbs.get_mut(&self.1);
|
||||
if let Some(cb) = cb {
|
||||
|
@ -784,7 +784,7 @@ impl Connection {
|
|||
Ok(modules)
|
||||
}
|
||||
|
||||
pub fn client_id(&self) -> u64 {
|
||||
pub fn client_id(&self) -> size_t {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user