Skip to content

Commit 3233a54

Browse files
authored
Merge pull request #104 from akhudek/master
Fix input and output scope and element usage.
2 parents a128519 + 939e503 commit 3233a54

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/audio_unit/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,27 +290,28 @@ impl AudioUnit {
290290
&mut self,
291291
stream_format: StreamFormat,
292292
scope: Scope,
293+
element: Element,
293294
) -> Result<(), Error> {
294295
let id = sys::kAudioUnitProperty_StreamFormat;
295296
let asbd = stream_format.to_asbd();
296-
self.set_property(id, scope, Element::Output, Some(&asbd))
297+
self.set_property(id, scope, element, Some(&asbd))
297298
}
298299

299300
/// Return the current Stream Format for the AudioUnit.
300-
pub fn stream_format(&self, scope: Scope) -> Result<StreamFormat, Error> {
301+
pub fn stream_format(&self, scope: Scope, element: Element) -> Result<StreamFormat, Error> {
301302
let id = sys::kAudioUnitProperty_StreamFormat;
302-
let asbd = self.get_property(id, scope, Element::Output)?;
303+
let asbd = self.get_property(id, scope, element)?;
303304
StreamFormat::from_asbd(asbd)
304305
}
305306

306307
/// Return the current output Stream Format for the AudioUnit.
307308
pub fn output_stream_format(&self) -> Result<StreamFormat, Error> {
308-
self.stream_format(Scope::Output)
309+
self.stream_format(Scope::Input, Element::Output)
309310
}
310311

311312
/// Return the current input Stream Format for the AudioUnit.
312313
pub fn input_stream_format(&self) -> Result<StreamFormat, Error> {
313-
self.stream_format(Scope::Input)
314+
self.stream_format(Scope::Output, Element::Input)
314315
}
315316
}
316317

src/audio_unit/render_callback.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,7 @@ impl AudioUnit {
467467
{
468468
// First, we'll retrieve the stream format so that we can ensure that the given callback
469469
// format matches the audio unit's format.
470-
let id = sys::kAudioUnitProperty_StreamFormat;
471-
let asbd = self.get_property(id, Scope::Input, Element::Output)?;
472-
let stream_format = super::StreamFormat::from_asbd(asbd)?;
470+
let stream_format = self.output_stream_format()?;
473471

474472
// If the stream format does not match, return an error indicating this.
475473
if !D::does_stream_format_match(&stream_format) {
@@ -540,9 +538,7 @@ impl AudioUnit {
540538
{
541539
// First, we'll retrieve the stream format so that we can ensure that the given callback
542540
// format matches the audio unit's format.
543-
let id = sys::kAudioUnitProperty_StreamFormat;
544-
let asbd = self.get_property(id, Scope::Output, Element::Input)?;
545-
let stream_format = super::StreamFormat::from_asbd(asbd)?;
541+
let stream_format = self.input_stream_format()?;
546542

547543
// If the stream format does not match, return an error indicating this.
548544
if !D::does_stream_format_match(&stream_format) {

0 commit comments

Comments
 (0)