File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 18491849 }
18501850
18511851 LOGI () << " Starting AVAudioEngine..." ;
1852- NSError * error = nil ;
18531852 BOOL start_result = false ;
18541853 int start_retry_count = 0 ;
18551854
18561855 // Workaround for error -66637, when recovering from interruptions with categoryMode:
18571856 // .mixWithOthers.
18581857 while (!start_result && start_retry_count < kStartEngineMaxRetries ) {
18591858 if (start_retry_count > 0 ) {
1860- LOGW () << " Retrying engine start (attempt " << start_retry_count + 1 << " /"
1859+ LOGW () << " Retrying engine start (attempt " << ( start_retry_count + 1 ) << " /"
18611860 << kStartEngineMaxRetries << " )" ;
18621861 usleep (kStartEngineRetryDelayMs * 1000 );
18631862 }
18641863
1865- // Workaround for cases where engine fails to start.
1866- [engine_device_ prepare ];
1867- sleep (1 );
1864+ NSString * error_string = nil ;
1865+
1866+ @try {
1867+ NSError * error = nil ;
1868+ start_result = [engine_device_ startAndReturnError: &error];
1869+ if (!start_result && error != nil ) {
1870+ error_string = error.localizedDescription ;
1871+ }
1872+ } @catch (NSException * exception) {
1873+ start_result = false ;
1874+ error_string = exception.reason ?: @" Unknown exception" ;
1875+ }
18681876
1869- start_result = [engine_device_ startAndReturnError: &error];
18701877 if (!start_result) {
1871- LOGE () << " Failed to start engine: " << error.localizedDescription .UTF8String ;
1878+ if (error_string != nil ) {
1879+ LOGE () << " Failed to start engine: " << error_string.UTF8String ;
1880+ }
18721881 start_retry_count++;
18731882 }
18741883 }
You can’t perform that action at this time.
0 commit comments