diff --git a/cidre/src/av.rs b/cidre/src/av.rs index 1bd4199e..d6dacb2b 100644 --- a/cidre/src/av.rs +++ b/cidre/src/av.rs @@ -142,7 +142,7 @@ pub use audio::IoNodeInputBlock as AudioIoNodeInputBlock; pub use audio::MixerNode as AudioMixerNode; pub use audio::Node as AudioNode; pub use audio::NodeBus as AudioNodeBus; -pub use audio::NodeCompletionHandler as AudioNodeCompletionHandler; +pub use audio::NodeCh as AudioNodeCompletionHandler; pub use audio::OutputNode as AudioOutputNode; pub use audio::PacketCount as AudioPacketCount; pub use audio::PcmBuf as AudioPcmBuf; diff --git a/cidre/src/av/audio.rs b/cidre/src/av/audio.rs index 85f1b104..99904f29 100644 --- a/cidre/src/av/audio.rs +++ b/cidre/src/av/audio.rs @@ -13,7 +13,7 @@ pub use types::ChannelCount; pub use types::FrameCount; pub use types::FramePos; pub use types::NodeBus; -pub use types::NodeCompletionHandler; +pub use types::NodeCh; pub use types::PacketCount; pub use types::Point3d; pub use types::Vector3d; @@ -36,7 +36,7 @@ pub use mixer_node::MixerNode; mod mixing; pub use mixing::Mixing; -pub use mixing::MixingDestination; +pub use mixing::MixingDst; pub use mixing::StereoMixing; mod time; diff --git a/cidre/src/av/audio/mixing.rs b/cidre/src/av/audio/mixing.rs index 717f94fa..d9a63957 100644 --- a/cidre/src/av/audio/mixing.rs +++ b/cidre/src/av/audio/mixing.rs @@ -11,15 +11,16 @@ pub trait StereoMixing { define_obj_type!( #[doc(alias = "AVAudioMixingDestination")] - pub MixingDestination(ns::Id) + pub MixingDst(ns::Id) ); -impl MixingDestination { +impl MixingDst { #[objc::msg_send(connectionPoint)] pub fn connection_point(&self) -> arc::R; } -impl av::audio::StereoMixing for MixingDestination {} -impl av::audio::Mixing for MixingDestination {} + +impl av::audio::StereoMixing for MixingDst {} +impl av::audio::Mixing for MixingDst {} #[objc::protocol(AVAudioMixing)] pub trait Mixing: StereoMixing { @@ -28,7 +29,7 @@ pub trait Mixing: StereoMixing { &self, mixer: av::AudioNode, bus: av::AudioNodeBus, - ) -> Option>; + ) -> Option>; #[objc::msg_send(volume)] fn volume(&self) -> f32; diff --git a/cidre/src/av/audio/player_node.rs b/cidre/src/av/audio/player_node.rs index 6f1b41b4..64bc0e3d 100644 --- a/cidre/src/av/audio/player_node.rs +++ b/cidre/src/av/audio/player_node.rs @@ -37,16 +37,21 @@ define_obj_type!( ); impl PlayerNode { - /// Schedule playing samples from an [`av::AudioPCMBuf`]. + /// Schedule playing samples from an [`av::AudioPcmBuf`]. /// /// Schedules the buffer to be played following any previously scheduled commands. #[objc::msg_send(scheduleBuffer:completionHandler:)] pub fn schedule_buf_ch_block( &mut self, buffer: &av::AudioPcmBuf, - handler: Option<&mut audio::NodeCompletionHandler>, + handler: Option<&mut audio::NodeCh>, ); + pub fn schedule_buf_ch(&mut self, buffer: &av::AudioPcmBuf, handler: impl FnMut() + 'static) { + let mut block = blocks::EscBlock::new0(handler); + self.schedule_buf_ch_block(buffer, Some(&mut block)); + } + pub async fn schedule_buf(&mut self, buffer: &av::AudioPcmBuf) { let (future, mut block) = blocks::comp0(); self.schedule_buf_ch_block(buffer, Some(&mut block)); @@ -72,13 +77,13 @@ impl PlayerNode { pub fn volume(&self) -> f32; #[objc::msg_send(setVolume:)] - pub fn set_volume(&self, val: f32); + pub fn set_volume(&mut self, val: f32); #[objc::msg_send(pan)] pub fn pan(&self) -> f32; #[objc::msg_send(setPan:)] - pub fn set_pan(&self, val: f32); + pub fn set_pan(&mut self, val: f32); } #[link(name = "av", kind = "static")] diff --git a/cidre/src/av/audio/types.rs b/cidre/src/av/audio/types.rs index 9971c8b6..6024fcb6 100644 --- a/cidre/src/av/audio/types.rs +++ b/cidre/src/av/audio/types.rs @@ -1,15 +1,26 @@ use crate::blocks; +#[doc(alias = "AVAudioFramePosition")] pub type FramePos = i64; + +#[doc(alias = "AVAudioFrameCount")] pub type FrameCount = u32; + +#[doc(alias = "AVAudioPacketCount")] pub type PacketCount = u32; + #[doc(alias = "AVAudioChannelCount")] pub type ChannelCount = u32; + +/// AVAudioNode objects potentially have multiple input and/or output busses. +/// AVAudioNodeBus represents a bus as a zero-based index. +#[doc(alias = "AVAudioNodeBus")] pub type NodeBus = usize; -pub type NodeCompletionHandler = blocks::Block; +#[doc(alias = "AVAudioNodeCompletionHandler")] +pub type NodeCh = blocks::Block; -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] #[repr(C)] pub struct Point3d { pub x: f32, @@ -19,14 +30,14 @@ pub struct Point3d { pub type Vector3d = Point3d; -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] #[repr(C)] pub struct Vector3dOrientation { pub forward: Vector3d, pub up: Vector3d, } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] #[repr(C)] pub struct Angular3dOrientation { pub yaw: f32,