Skip to content

Commit

Permalink
Fix macos build (RustAudio#186)
Browse files Browse the repository at this point in the history
* fix compile error

* fix missing function error

* fix undefined behavior issue

* require callback to be `Send`
  • Loading branch information
chyvonomys authored and tomaka committed Dec 6, 2017
1 parent 5105427 commit 37016e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/coreaudio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct EventLoop {

struct ActiveCallbacks {
// Whenever the `run()` method is called with a callback, this callback is put in this list.
callbacks: Mutex<Vec<&'static mut FnMut(VoiceId, UnknownTypeBuffer)>>,
callbacks: Mutex<Vec<&'static mut (FnMut(VoiceId, UnknownTypeBuffer) + Send)>>,
}

struct VoiceInner {
Expand Down Expand Up @@ -98,9 +98,9 @@ impl EventLoop {

#[inline]
pub fn run<F>(&self, mut callback: F) -> !
where F: FnMut(VoiceId, UnknownTypeBuffer)
where F: FnMut(VoiceId, UnknownTypeBuffer) + Send
{
let callback: &mut FnMut(VoiceId, UnknownTypeBuffer) = &mut callback;
let callback: &mut (FnMut(VoiceId, UnknownTypeBuffer) + Send) = &mut callback;
self.active_callbacks
.callbacks
.lock()
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl EventLoop {
/// You can call the other methods of `EventLoop` without getting a deadlock.
#[inline]
pub fn run<F>(&self, mut callback: F) -> !
where F: FnMut(VoiceId, UnknownTypeBuffer)
where F: FnMut(VoiceId, UnknownTypeBuffer) + Send
{
self.0.run(move |id, buf| callback(VoiceId(id), buf))
}
Expand Down

0 comments on commit 37016e6

Please sign in to comment.