#[repr(C)]pub struct AUAudioUnitBus { /* private fields */ }
AUAudioUnit
only.Expand description
An input or output connection point on an audio unit.
See also Apple’s documentation
Implementations§
Source§impl AUAudioUnitBus
impl AUAudioUnitBus
Sourcepub unsafe fn shouldAllocateBuffer(&self) -> bool
pub unsafe fn shouldAllocateBuffer(&self) -> bool
Controls the audio unit’s allocation strategy for a bus.
Hosts can set this flag to communicate whether an audio unit should allocate its own buffer. By default this flag is set to true.
On the output side, shouldAllocateBuffer=false means the AU can assume that it will be called with non-null output buffers. If shouldAllocateBuffer=true (the default), the AU must be prepared to be called with null pointers and replace them with pointers to its internally allocated buffer.
On the input side, shouldAllocateBuffer=false means the AU can pull for input using a buffer list with null buffer pointers, and assume that the pull input block will provide pointers. If shouldAllocateBuffer=true (the default), the AU must pull with non-null pointers while still being prepared for the source to replace them with pointers of its own.
Bridged to the v2 property kAudioUnitProperty_ShouldAllocateBuffer.
Sourcepub unsafe fn setShouldAllocateBuffer(&self, should_allocate_buffer: bool)
pub unsafe fn setShouldAllocateBuffer(&self, should_allocate_buffer: bool)
Setter for shouldAllocateBuffer
.
Sourcepub unsafe fn isEnabled(&self) -> bool
pub unsafe fn isEnabled(&self) -> bool
Whether the bus is active.
Hosts must enable input busses before using them. The reason for this is to allow a unit such as a mixer to be prepared to render a large number of inputs, but avoid the work of preparing to pull inputs which are not in use.
Bridged to the v2 properties kAudioUnitProperty_MakeConnection and kAudioUnitProperty_SetRenderCallback.
Sourcepub unsafe fn setEnabled(&self, enabled: bool)
pub unsafe fn setEnabled(&self, enabled: bool)
Setter for isEnabled
.
Sourcepub unsafe fn name(&self) -> Option<Retained<NSString>>
pub unsafe fn name(&self) -> Option<Retained<NSString>>
A name for the bus. Can be set by host.
Sourcepub unsafe fn index(&self) -> NSUInteger
pub unsafe fn index(&self) -> NSUInteger
The index of this bus in the containing array.
Sourcepub unsafe fn busType(&self) -> AUAudioUnitBusType
pub unsafe fn busType(&self) -> AUAudioUnitBusType
The AUAudioUnitBusType.
Sourcepub unsafe fn ownerAudioUnit(&self) -> Retained<AUAudioUnit>
pub unsafe fn ownerAudioUnit(&self) -> Retained<AUAudioUnit>
The audio unit that owns the bus.
Sourcepub unsafe fn supportedChannelLayoutTags(
&self,
) -> Option<Retained<NSArray<NSNumber>>>
pub unsafe fn supportedChannelLayoutTags( &self, ) -> Option<Retained<NSArray<NSNumber>>>
This is an array of NSNumbers representing AudioChannelLayoutTag.
Sourcepub unsafe fn contextPresentationLatency(&self) -> NSTimeInterval
pub unsafe fn contextPresentationLatency(&self) -> NSTimeInterval
Information about latency in the audio unit’s processing context.
This should not be confused with the audio unit’s latency property, where the audio unit describes to the host any processing latency it introduces between its input and its output.
A host may set this property to describe to the audio unit the presentation latency of its input and/or output audio data. Latency is described in seconds. A value of zero means either no latency or an unknown latency.
A host should set this property on each active bus, since, for example, the audio routing path to each of multiple output busses may differ.
For input busses: Describes how long ago the audio arriving on this bus was acquired. For instance, when reading from a file to the first audio unit in a chain, the input presentation latency is zero. For audio input from a device, this initial input latency is the presentation latency of the device itself, i.e. the device’s safety offset and latency.
A second chained audio unit’s input presentation latency will be the input presentation latency of the first unit, plus the processing latency of the first unit.
For output busses: Describes how long it will be before the output audio of an audio unit is presented. For instance, when writing to a file, the output presentation latency of the last audio unit in a chain is zero. When the audio from that audio unit is to be played to a device, then that initial presentation latency will be the presentation latency of the device itself, which is the I/O buffer size, plus the device’s safety offset and latency
A previous chained audio unit’s output presentation latency is the last unit’s presentation latency plus its processing latency.
So, for a given audio unit anywhere within a mixing graph, the input and output presentation latencies describe to that unit how long from the moment of generation it has taken for its input to arrive, and how long it will take for its output to be presented.
Bridged to the v2 property kAudioUnitProperty_PresentationLatency.
Sourcepub unsafe fn setContextPresentationLatency(
&self,
context_presentation_latency: NSTimeInterval,
)
pub unsafe fn setContextPresentationLatency( &self, context_presentation_latency: NSTimeInterval, )
Setter for contextPresentationLatency
.
Source§impl AUAudioUnitBus
Methods declared on superclass NSObject
.
impl AUAudioUnitBus
Methods declared on superclass NSObject
.
Source§impl AUAudioUnitBus
AUAudioUnitImplementation.
Aspects of AUAudioUnitBus of interest only to the implementation of v3 AUs.
impl AUAudioUnitBus
AUAudioUnitImplementation. Aspects of AUAudioUnitBus of interest only to the implementation of v3 AUs.
Sourcepub unsafe fn supportedChannelCounts(
&self,
) -> Option<Retained<NSArray<NSNumber>>>
Available on crate feature AUAudioUnitImplementation
only.
pub unsafe fn supportedChannelCounts( &self, ) -> Option<Retained<NSArray<NSNumber>>>
AUAudioUnitImplementation
only.An array of numbers giving the supported numbers of channels for this bus.
If supportedChannelCounts is nil, then any number less than or equal to maximumChannelCount is supported. If setting supportedChannelCounts makes the current format unsupported, then format will be set to nil. The default value is nil.
Sourcepub unsafe fn setSupportedChannelCounts(
&self,
supported_channel_counts: Option<&NSArray<NSNumber>>,
)
Available on crate feature AUAudioUnitImplementation
only.
pub unsafe fn setSupportedChannelCounts( &self, supported_channel_counts: Option<&NSArray<NSNumber>>, )
AUAudioUnitImplementation
only.Setter for supportedChannelCounts
.
Sourcepub unsafe fn maximumChannelCount(&self) -> AUAudioChannelCount
Available on crate feature AUAudioUnitImplementation
only.
pub unsafe fn maximumChannelCount(&self) -> AUAudioChannelCount
AUAudioUnitImplementation
only.The maximum numbers of channels supported for this bus.
If supportedChannelCounts is set, then this value is derived from supportedChannelCounts. If setting maximumChannelCount makes the current format unsupported, then format will be set to nil. The default value is UINT_MAX.
Sourcepub unsafe fn setMaximumChannelCount(
&self,
maximum_channel_count: AUAudioChannelCount,
)
Available on crate feature AUAudioUnitImplementation
only.
pub unsafe fn setMaximumChannelCount( &self, maximum_channel_count: AUAudioChannelCount, )
AUAudioUnitImplementation
only.Setter for maximumChannelCount
.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AUAudioUnitBus> for AUAudioUnitBus
impl AsRef<AUAudioUnitBus> for AUAudioUnitBus
Source§impl AsRef<AnyObject> for AUAudioUnitBus
impl AsRef<AnyObject> for AUAudioUnitBus
Source§impl AsRef<NSObject> for AUAudioUnitBus
impl AsRef<NSObject> for AUAudioUnitBus
Source§impl Borrow<AnyObject> for AUAudioUnitBus
impl Borrow<AnyObject> for AUAudioUnitBus
Source§impl Borrow<NSObject> for AUAudioUnitBus
impl Borrow<NSObject> for AUAudioUnitBus
Source§impl ClassType for AUAudioUnitBus
impl ClassType for AUAudioUnitBus
Source§const NAME: &'static str = "AUAudioUnitBus"
const NAME: &'static str = "AUAudioUnitBus"
Source§type ThreadKind = <<AUAudioUnitBus as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<AUAudioUnitBus as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for AUAudioUnitBus
impl Debug for AUAudioUnitBus
Source§impl Deref for AUAudioUnitBus
impl Deref for AUAudioUnitBus
Source§impl Hash for AUAudioUnitBus
impl Hash for AUAudioUnitBus
Source§impl Message for AUAudioUnitBus
impl Message for AUAudioUnitBus
Source§impl NSObjectProtocol for AUAudioUnitBus
impl NSObjectProtocol for AUAudioUnitBus
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref