Added missing status checks

This commit is contained in:
Thong Nguyen 2014-01-31 20:35:44 +00:00
parent f321f1a0d7
commit 70fe37cd4a
1 changed files with 50 additions and 0 deletions

View File

@ -1664,20 +1664,56 @@ static BOOL GetHardwareCodecClassDesc(UInt32 formatId, AudioClassDescription* cl
status = AudioComponentInstanceNew(component, &audioUnit);
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
UInt32 flag = 1;
status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, kOutputBus, &flag, sizeof(flag));
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &canonicalAudioStreamBasicDescription, sizeof(canonicalAudioStreamBasicDescription));
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = playbackCallback;
callbackStruct.inputProcRefCon = (__bridge void*)self;
status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callbackStruct, sizeof(callbackStruct));
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
status = AudioUnitInitialize(audioUnit);
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
pthread_mutex_unlock(&playerMutex);
}
@ -1687,6 +1723,13 @@ static BOOL GetHardwareCodecClassDesc(UInt32 formatId, AudioClassDescription* cl
status = AudioOutputUnitStart(audioUnit);
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return NO;
}
return YES;
}
@ -1704,6 +1747,13 @@ static BOOL GetHardwareCodecClassDesc(UInt32 formatId, AudioClassDescription* cl
status = AudioOutputUnitStop(audioUnit);
if (status)
{
[self unexpectedError:STKAudioPlayerErrorAudioSystemError];
return;
}
stopReason = stopReasonIn;
self.internalState = STKAudioPlayerInternalStateStopped;
}