Permalink
Browse files

Safety net when sample rate cannot be determined

  • Loading branch information...
1 parent b806484 commit 85003025a96af0e6471f3d52f4aba43cb9e04b93 @martijnthe martijnthe committed Apr 11, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 YBAudioUnit/YBAudioFilePlayer.m
@@ -74,7 +74,11 @@ - (void)setFileURL:(NSURL *)fileURL typeHint:(AudioFileTypeID)typeHint {
propsize = sizeof(_fileASBD);
AudioUnitGetProperty(_auAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &_unitASBD, &propsize);
- _sampleRateRatio = _unitASBD.mSampleRate / _fileASBD.mSampleRate;
+ if (_fileASBD.mSampleRate > 0 && _unitASBD.mSampleRate > 0) {
+ _sampleRateRatio = _unitASBD.mSampleRate / _fileASBD.mSampleRate;
+ } else {
+ _sampleRateRatio = 1.;
+ }
}
}
@@ -133,7 +137,7 @@ - (void)primeBuffersWithFrames:(UInt32)numberOfFrames {
- (id)initWithAUNode:(AUNode)auNode audioUnit:(AudioUnit)auAudioUnit inGraph:(YBAudioUnitGraph *)graph {
self = [super initWithAUNode:auNode audioUnit:auAudioUnit inGraph:graph];
if (self) {
-
+ _sampleRateRatio = 1.;
}
return self;
}

0 comments on commit 8500302

Please sign in to comment.