From 2d27164f3b3e57b8ab7fc9511b5b003acf8ed0c8 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 14 Sep 2018 13:42:04 +0200 Subject: [PATCH] Remove usage of unstable features --- Cargo.lock | 95 ++++++++++++++++++++++++++++++++ audio/Cargo.toml | 5 +- audio/src/block.rs | 22 -------- audio/src/decoder.rs | 26 ++++----- audio/src/graph.rs | 9 ++- audio/src/lib.rs | 4 +- audio/src/node.rs | 6 +- audio/src/offline_sink.rs | 2 +- audio/src/panner_node.rs | 3 +- backends/gstreamer/src/lib.rs | 2 - backends/gstreamer/src/player.rs | 1 + examples/Cargo.toml | 1 + examples/player/main.rs | 2 - servo-media-derive/src/lib.rs | 2 +- 14 files changed, 127 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81e249ba..0f9ab2cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,16 @@ name = "ascii" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "binary-space-partition" version = "0.1.2" @@ -70,6 +80,11 @@ name = "block" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "boxfnonce" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "build_const" version = "0.2.1" @@ -312,6 +327,18 @@ name = "either" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "env_logger" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.10.0" @@ -330,6 +357,7 @@ dependencies = [ name = "examples" version = "0.1.0" dependencies = [ + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -654,6 +682,14 @@ dependencies = [ "pkg-config 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "iovec" version = "0.1.2" @@ -1010,6 +1046,11 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.5.2" @@ -1079,6 +1120,14 @@ name = "redox_syscall" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex" version = "1.0.2" @@ -1160,6 +1209,7 @@ dependencies = [ name = "servo-media-audio" version = "0.1.0" dependencies = [ + "boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1286,6 +1336,24 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.5" @@ -1469,11 +1537,28 @@ name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winit" version = "0.16.2" @@ -1542,10 +1627,12 @@ dependencies = [ "checksum array-init 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c3cc8456d0ae81a8c76f59e384683a601548c38949a4bfcb65dd31ded5c75ff3" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff" "checksum bincode 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2fb9e29e72fd6bc12071533d5dc7664cb01480c59406f656d7ac25c7bd8ff7" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +"checksum boxfnonce 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cbec60c560f322d8e3cd403f91d8908cfd965fff53ba97154bd1b9d90149d98e" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byte-slice-cast 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "28346c117b50270785fbc123bd6e4ecad20d0c6d5f43d081dc80a3abcc62be64" "checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" @@ -1575,6 +1662,7 @@ dependencies = [ "checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c" "checksum dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b26e30aaa6bf31ec830db15fec14ed04f0f2ecfcc486ecfce88c55d3389b237f" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" +"checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70a2ebdf55fb9d6329046e026329a55ef8fbaae5ea833f56e170beb3125a8a5f" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" @@ -1605,6 +1693,7 @@ dependencies = [ "checksum gstreamer-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18e3ff41a9e0bc96d345f25b1dd00cfda31edcab2aa19535af5312fdb80d062b" "checksum gstreamer-video 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c1f04816d7e183714830da26274f97e7aeff09ae6641058538d21443b4ec07d" "checksum gstreamer-video-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e2efb301a0b94fa4af503122faa04247085936dd888fd59fa4e21eab3cbd37" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipc-channel 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd75debad4ffd295c00c6e3634d254df30050b0837a85e5cd039ac424365f24a" "checksum jni 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cffc930ce6a38a4013e30567b559bdc79f601013ba4a81e65dbda9207263efd4" @@ -1648,6 +1737,7 @@ dependencies = [ "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" "checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" "checksum quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" @@ -1656,6 +1746,7 @@ dependencies = [ "checksum rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df7a791f788cb4c516f0e091301a29c2b71ef680db5e644a7d68835c8ae6dbfa" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5bbbea44c5490a1e84357ff28b7d518b4619a159fed5d25f6c1de2d19cc42814" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" @@ -1672,6 +1763,8 @@ dependencies = [ "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" "checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" "checksum tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c4b103c6d08d323b92ff42c8ce62abcd83ca8efa7fd5bf7927efefec75f58c76" +"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum thread_profiler 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5920e77802b177479ab5795767fa48e68f61b2f516c2ac0041e2978dd8efe483" "checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" @@ -1692,7 +1785,9 @@ dependencies = [ "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec43db5991cc509f5b0c68cb0a0d3614f697c888999990a186a2e895c7f723c0" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "940586acb859ea05c53971ac231685799a7ec1dee66ac0bccc0e6ad96e06b4e3" diff --git a/audio/Cargo.toml b/audio/Cargo.toml index 0d8fe5f6..e9826b48 100644 --- a/audio/Cargo.toml +++ b/audio/Cargo.toml @@ -8,9 +8,10 @@ version = "0.1.0" name = "servo_media_audio" [dependencies] -smallvec = "0.6.1" -servo_media_derive = { path = "../servo-media-derive" } +boxfnonce = "0.1" euclid = "0.19.0" +servo_media_derive = { path = "../servo-media-derive" } +smallvec = "0.6.1" [dependencies.petgraph] version = "0.4.12" diff --git a/audio/src/block.rs b/audio/src/block.rs index 04b5ffe2..fddeb908 100644 --- a/audio/src/block.rs +++ b/audio/src/block.rs @@ -4,7 +4,6 @@ use graph::{PortIndex, PortKind}; use node::ChannelInterpretation; use smallvec::SmallVec; use std::f32::consts::SQRT_2; -use std::iter::Step; use std::mem; use std::ops::*; @@ -605,27 +604,6 @@ impl Div for Tick { } } -impl Step for Tick { - fn steps_between(start: &Self, end: &Self) -> Option { - Step::steps_between(&start.0, &end.0) - } - fn replace_one(&mut self) -> Self { - Tick(self.0.replace_one()) - } - fn replace_zero(&mut self) -> Self { - Tick(self.0.replace_zero()) - } - fn add_one(&self) -> Self { - Tick(self.0.add_one()) - } - fn sub_one(&self) -> Self { - Tick(self.0.sub_one()) - } - fn add_usize(&self, n: usize) -> Option { - self.0.add_usize(n).map(Tick) - } -} - impl Tick { pub fn from_time(time: f64, rate: f32) -> Tick { Tick((0.5 + time * rate as f64).floor() as u64) diff --git a/audio/src/decoder.rs b/audio/src/decoder.rs index 5087ae20..aafdc72c 100644 --- a/audio/src/decoder.rs +++ b/audio/src/decoder.rs @@ -1,11 +1,11 @@ -use std::boxed::FnBox; +use boxfnonce::SendBoxFnOnce; use std::sync::Mutex; pub struct AudioDecoderCallbacks { - pub eos: Mutex>>, - pub error: Mutex>>, + pub eos: Mutex>>, + pub error: Mutex>>, pub progress: Option>, u32) + Send + Sync + 'static>>, - pub ready: Mutex>>, + pub ready: Mutex>>, } impl AudioDecoderCallbacks { @@ -22,7 +22,7 @@ impl AudioDecoderCallbacks { let eos = self.eos.lock().unwrap().take(); match eos { None => return, - Some(callback) => callback(), + Some(callback) => callback.call(), }; } @@ -30,7 +30,7 @@ impl AudioDecoderCallbacks { let error = self.error.lock().unwrap().take(); match error { None => return, - Some(callback) => callback(), + Some(callback) => callback.call(), }; } @@ -45,7 +45,7 @@ impl AudioDecoderCallbacks { let ready = self.ready.lock().unwrap().take(); match ready { None => return, - Some(callback) => callback(channels), + Some(callback) => callback.call(channels), }; } } @@ -54,23 +54,23 @@ unsafe impl Send for AudioDecoderCallbacks {} unsafe impl Sync for AudioDecoderCallbacks {} pub struct AudioDecoderCallbacksBuilder { - eos: Option>, - error: Option>, + eos: Option>, + error: Option>, progress: Option>, u32) + Send + Sync + 'static>>, - ready: Option>, + ready: Option>, } impl AudioDecoderCallbacksBuilder { pub fn eos(self, eos: F) -> Self { Self { - eos: Some(Box::new(eos)), + eos: Some(SendBoxFnOnce::new(eos)), ..self } } pub fn error(self, error: F) -> Self { Self { - error: Some(Box::new(error)), + error: Some(SendBoxFnOnce::new(error)), ..self } } @@ -87,7 +87,7 @@ impl AudioDecoderCallbacksBuilder { pub fn ready(self, ready: F) -> Self { Self { - ready: Some(Box::new(ready)), + ready: Some(SendBoxFnOnce::new(ready)), ..self } } diff --git a/audio/src/graph.rs b/audio/src/graph.rs index 595ff5f0..c7a8567f 100644 --- a/audio/src/graph.rs +++ b/audio/src/graph.rs @@ -81,13 +81,16 @@ impl PortKind for InputPort { type Listener = (); } +#[derive(Debug, Hash, PartialOrd, Ord, PartialEq, Eq, Copy, Clone)] +pub enum Void {} + impl PortKind for OutputPort { - // Params are only a feature of input ports. By using a never type here + // Params are only a feature of input ports. By using an empty type here // we ensure that the PortIndex enum has zero overhead for outputs, // taking up no extra discriminant space and eliminating PortIndex::Param // branches entirely from the compiled code - type ParamId = !; - type Listener = !; + type ParamId = Void; + type Listener = Void; } diff --git a/audio/src/lib.rs b/audio/src/lib.rs index 2eb9aa70..c441d33c 100644 --- a/audio/src/lib.rs +++ b/audio/src/lib.rs @@ -1,9 +1,7 @@ -#![feature(cell_update)] -#![feature(fnbox, never_type, step_trait)] - #[macro_use] extern crate servo_media_derive; +extern crate boxfnonce; extern crate byte_slice_cast; extern crate euclid; extern crate num_traits; diff --git a/audio/src/node.rs b/audio/src/node.rs index 34d69eb4..1128da66 100644 --- a/audio/src/node.rs +++ b/audio/src/node.rs @@ -1,3 +1,4 @@ +use boxfnonce::SendBoxFnOnce; use block::{Block, Chunk, Tick}; use buffer_source_node::{AudioBufferSourceNodeMessage, AudioBufferSourceNodeOptions}; use channel_node::ChannelNodeOptions; @@ -5,7 +6,6 @@ use gain_node::GainNodeOptions; use oscillator_node::OscillatorNodeOptions; use panner_node::{PannerNodeMessage, PannerNodeOptions}; use param::{Param, ParamRate, ParamType, UserAutomationEvent}; -use std::boxed::FnBox; use std::sync::mpsc::Sender; /// Information required to construct an audio node @@ -188,11 +188,11 @@ pub enum AudioNodeMessage { SetParamRate(ParamType, ParamRate), } -pub struct OnEndedCallback(pub Box); +pub struct OnEndedCallback(pub SendBoxFnOnce<'static, ()>); impl OnEndedCallback { pub fn new(callback: F) -> Self { - OnEndedCallback(Box::new(callback)) + OnEndedCallback(SendBoxFnOnce::new(callback)) } } diff --git a/audio/src/offline_sink.rs b/audio/src/offline_sink.rs index e0a57e63..606011a4 100644 --- a/audio/src/offline_sink.rs +++ b/audio/src/offline_sink.rs @@ -79,7 +79,7 @@ impl AudioSink for OfflineAudioSink { channel_data.copy_from_slice(&chunk.blocks[0].data_chan(channel_number as u8)[0..copy_len]); } }; - self.rendered_blocks.update(|blocks| blocks + 1); + self.rendered_blocks.set(self.rendered_blocks.get() + 1); if last { if let Some(callback) = self.eos_callback.borrow_mut().take() { diff --git a/audio/src/panner_node.rs b/audio/src/panner_node.rs index 01e32644..8fc3d6e0 100644 --- a/audio/src/panner_node.rs +++ b/audio/src/panner_node.rs @@ -307,7 +307,8 @@ impl AudioNodeEngine for PannerNode { unimplemented!() } else { let (l, r) = block.data_mut().split_at_mut(FRAMES_PER_BLOCK.0 as usize); - for frame in Tick(0)..FRAMES_PER_BLOCK { + for frame in 0..FRAMES_PER_BLOCK.0 { + let frame = Tick(frame); self.update_parameters(info, frame); let data = listener_data.listener_data(frame); let (mut azimuth, _elev, dist) = self.azimuth_elevation_distance(data); diff --git a/backends/gstreamer/src/lib.rs b/backends/gstreamer/src/lib.rs index 53354f23..fb6ff4ce 100644 --- a/backends/gstreamer/src/lib.rs +++ b/backends/gstreamer/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(extern_prelude)] - extern crate byte_slice_cast; extern crate glib; diff --git a/backends/gstreamer/src/player.rs b/backends/gstreamer/src/player.rs index ad6b8e9d..a75778e4 100644 --- a/backends/gstreamer/src/player.rs +++ b/backends/gstreamer/src/player.rs @@ -1,3 +1,4 @@ +use glib; use glib::*; use gst; use gst_app; diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 108ef993..70675560 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" license = "MPL-2.0" [dependencies] +env_logger = "0.5" euclid = "0.19.0" gleam = "0.6.0" glutin = "0.17.0" diff --git a/examples/player/main.rs b/examples/player/main.rs index 08b9543d..7a89c7b6 100644 --- a/examples/player/main.rs +++ b/examples/player/main.rs @@ -2,8 +2,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#![feature(rustc_private)] - extern crate gleam; extern crate glutin; extern crate ipc_channel; diff --git a/servo-media-derive/src/lib.rs b/servo-media-derive/src/lib.rs index c54a5a25..bdb2e799 100644 --- a/servo-media-derive/src/lib.rs +++ b/servo-media-derive/src/lib.rs @@ -61,7 +61,7 @@ fn impl_audio_scheduled_source_node(ast: &syn::DeriveInput) -> quote::Tokens { if self.start_at.is_none() || self.onended_callback.is_none() { return; } - self.onended_callback.take().unwrap().0(); + self.onended_callback.take().unwrap().0.call(); } fn handle_source_node_message(&mut self, message: AudioScheduledSourceNodeMessage, sample_rate: f32) {