From 8cfe176e5221a79ffeb1350340df84ca0f70c199 Mon Sep 17 00:00:00 2001 From: shockham Date: Fri, 7 Apr 2017 11:06:00 +0100 Subject: [PATCH] Fix for loop in EventLoop::run being optimised out in a release build on macOS --- src/coreaudio/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/coreaudio/mod.rs b/src/coreaudio/mod.rs index d60d3e0..2e0e823 100644 --- a/src/coreaudio/mod.rs +++ b/src/coreaudio/mod.rs @@ -16,6 +16,8 @@ use futures::task::Task; use futures::task; use futures::stream::Stream; use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::Duration; use self::coreaudio::audio_unit::AudioUnit; use self::coreaudio::audio_unit::render_callback::{self, data}; @@ -50,7 +52,12 @@ impl EventLoop { #[inline] pub fn new() -> EventLoop { EventLoop } #[inline] - pub fn run(&self) { loop {} } + pub fn run(&self) { + loop { + // So the loop does not get optimised out in --release + thread::sleep(Duration::new(1u64, 0u32)); + } + } } pub struct Buffer { @@ -84,9 +91,6 @@ impl Buffer where T: Sample { } } -type NumChannels = usize; -type NumFrames = usize; - pub struct Voice { playing: bool, audio_unit: AudioUnit