diff --git a/DLGPlayer/codec/DLGPlayerAudioManager.m b/DLGPlayer/codec/DLGPlayerAudioManager.m index 6f1e9a8..38993a6 100644 --- a/DLGPlayer/codec/DLGPlayerAudioManager.m +++ b/DLGPlayer/codec/DLGPlayerAudioManager.m @@ -347,15 +347,23 @@ - (BOOL)play:(NSError **)error { if (DLGPlayerUtils.debugEnabled) { NSLog(@"[Audio] %zd -> play", self.hash); } - OSStatus status = AudioOutputUnitStart(_audioUnit); - _playing = (status == noErr); - if (!_playing) { - NSError *rawError = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; - [DLGPlayerUtils createError:error - withDomain:DLGPlayerErrorDomainAudioManager - andCode:DLGPlayerErrorCodeCannotStartAudioUnit - andMessage:[DLGPlayerUtils localizedString:@"DLG_PLAYER_STRINGS_CANNOT_START_AUDIO_UNIT"] - andRawError:rawError]; + + @try { + OSStatus status = AudioOutputUnitStart(_audioUnit); + _playing = (status == noErr); + if (!_playing) { + NSError *rawError = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; + [DLGPlayerUtils createError:error + withDomain:DLGPlayerErrorDomainAudioManager + andCode:DLGPlayerErrorCodeCannotStartAudioUnit + andMessage:[DLGPlayerUtils localizedString:@"DLG_PLAYER_STRINGS_CANNOT_START_AUDIO_UNIT"] + andRawError:rawError]; + } + } @catch (NSException *exception) { + if (DLGPlayerUtils.debugEnabled) { + NSLog(@"[Audio] Unknown Error = %@", exception); + } + return NO; } } return _playing;