Created
December 11, 2012 20:51
-
-
Save tkemp/4262016 to your computer and use it in GitHub Desktop.
Set AudioFilePlayer AU stream format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the ASBD from the player unit | |
UInt32 playerASBDsz; | |
checkError(AudioUnitGetProperty(_playerUnit, | |
kAudioUnitProperty_StreamFormat, | |
kAudioUnitScope_Output, | |
BUS_PLAYER_OUTPUT, | |
&_playerASBD, | |
&playerASBDsz), | |
"AudioUnitSetProperty failed: getting stream format from the player unit", false); | |
// Update with channels and sample rate from the main application: | |
_playerASBD.mChannelsPerFrame = _outputASBD.mChannelsPerFrame; | |
_playerASBD.mSampleRate = _outputASBD.mSampleRate; | |
// Re-apply the ASBD to the player unit | |
checkError(AudioUnitSetProperty(_playerUnit, | |
kAudioUnitProperty_StreamFormat, | |
kAudioUnitScope_Output, | |
BUS_PLAYER_OUTPUT, | |
&_playerASBD, | |
sizeof(_playerASBD)), | |
"AudioUnitSetProperty failed: setting channels & sample rate to player output ASBD", false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment