Prevent crash when reading unsupported types and raise didEncounterError delegate callback
This commit is contained in:
parent
9b952de734
commit
0eb7687a63
|
|
@ -94,7 +94,8 @@ typedef enum
|
|||
AudioPlayerErrorQueuePauseFailed,
|
||||
AudioPlayerErrorUnknownBuffer,
|
||||
AudioPlayerErrorQueueStopFailed,
|
||||
AudioPlayerErrorOther
|
||||
AudioPlayerErrorQueueCreationFailed,
|
||||
AudioPlayerErrorOther = -1
|
||||
}
|
||||
AudioPlayerErrorCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -722,12 +722,22 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
if (audioQueue == nil)
|
||||
{
|
||||
[self createAudioQueue];
|
||||
|
||||
if (audioQueue == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (memcmp(¤tAudioStreamBasicDescription, ¤tlyReadingEntry->audioStreamBasicDescription, sizeof(currentAudioStreamBasicDescription)) != 0)
|
||||
{
|
||||
if (currentlyReadingEntry == currentlyPlayingEntry)
|
||||
{
|
||||
[self createAudioQueue];
|
||||
|
||||
if (audioQueue == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1145,6 +1155,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
|
||||
if (error)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self.delegate audioPlayer:self didEncounterError:AudioPlayerErrorQueueCreationFailed];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1152,6 +1167,8 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
|
||||
if (error)
|
||||
{
|
||||
[self.delegate audioPlayer:self didEncounterError:AudioPlayerErrorQueueCreationFailed];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1193,6 +1210,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
|
||||
if (error)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self.delegate audioPlayer:self didEncounterError:AudioPlayerErrorQueueCreationFailed];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1209,6 +1231,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
|
||||
if (error)
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self.delegate audioPlayer:self didEncounterError:AudioPlayerErrorQueueCreationFailed];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1229,6 +1256,11 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
{
|
||||
free(cookieData);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self.delegate audioPlayer:self didEncounterError:AudioPlayerErrorQueueCreationFailed];
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1816,9 +1848,12 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
|
|||
[self stopAudioQueueWithReason:@"from startAudioQueue"];
|
||||
[self createAudioQueue];
|
||||
|
||||
self.internalState = AudioPlayerInternalStateWaitingForQueueToStart;
|
||||
|
||||
AudioQueueStart(audioQueue, NULL);
|
||||
if (audioQueue != nil)
|
||||
{
|
||||
self.internalState = AudioPlayerInternalStateWaitingForQueueToStart;
|
||||
|
||||
AudioQueueStart(audioQueue, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
[self stopSystemBackgroundTask];
|
||||
|
|
|
|||
Loading…
Reference in New Issue