Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/audio_unit/render_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl AudioUnit {
// First, we'll retrieve the stream format so that we can ensure that the given callback
// format matches the audio unit's format.
let id = sys::kAudioUnitProperty_StreamFormat;
let asbd = try!(self.get_property(id, Scope::Output, Element::Output));
let asbd = try!(self.get_property(id, Scope::Input, Element::Output));
let stream_format = super::StreamFormat::from_asbd(asbd)?;

// If the stream format does not match, return an error indicating this.
Expand Down
9 changes: 5 additions & 4 deletions src/audio_unit/stream_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use sys;
/// Seeing as `LinearPCM` data (the `AudioFormat` used by the `AudioUnit` API) implies a single
/// frame per packet, we can infer many of the fields in an ASBD from the sample type.
///
/// `bytes_per_packet` = size_of::<S>()
/// `bytes_per_frame` = size_of::<S>()
/// `bytes_per_packet` = channels_per_frame * size_of::<S>()
/// `bytes_per_frame` = channels_per_frame * size_of::<S>()
/// `frames_per_packet` = 1
/// `bits_per_channel` = size_of::<S>() * 8
///
Expand Down Expand Up @@ -111,10 +111,11 @@ impl StreamFormat {

let flag = maybe_flag.unwrap_or(::std::u32::MAX -2147483647);

let bytes_per_frame = sample_format.size_in_bytes() as u32;
let bytes_per_frame = channels_per_frame * sample_format.size_in_bytes() as u32;
let bits_per_channel = sample_format.size_in_bytes() as u32 * 8;

const FRAMES_PER_PACKET: u32 = 1;
let bytes_per_packet = bytes_per_frame * FRAMES_PER_PACKET;
let bits_per_channel = bytes_per_frame * 8;

sys::AudioStreamBasicDescription {
mSampleRate: sample_rate,
Expand Down