In the below code AudioKit.start() crashes on my iPhone SE with iOS 10.1.1. It works fine on the Simulator.
private func play(note: Int) {
let pluckedString = AKPluckedString()
AudioKit.output = pluckedString
AudioKit.start() // <-- Crash here!
let frequency = note.midiNoteToFrequency()
pluckedString.trigger(frequency: frequency)
}
The console error log is
2016-12-04 10:51:45.765130 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.766519 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch, 44100 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.767008 MyApp[1833:720319] [aurioc] 889: failed: -10851 (enable 2, outf< 2 ch, 44100 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
2016-12-04 10:51:45.767982 MyApp[1833:720319] [central] 54: ERROR: [0x1b42d7c40] >avae> AVAudioEngineGraph.mm:2515: PerformCommand: error -10851
What have I missed? I can't find any documentation about any needed extra setup for devices compared to the simulator. The version of AudioKit is 3.5. XCode version is 8.1
I found the issue. I had a recording category set for the audio session. By making sure that the audio session category isn't AVAudioSessionCategoryRecord on playback; my app doesn't crash anymore.
Related
I'm trying to test AVAudioEngine, watched the WWDC conferences about it, and did everything by the book to try to play a simple file.
Despite everything being exactly the same as in the samples that I found (WWDC and a few other places), despite everything seeming fine (no error, seems to be running), I have no sound output.
Here's the code:
NSError *error = Nil;
[AVAudioSession.sharedInstance setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error: &error];
[AVAudioSession.sharedInstance setActive:YES error:&error];
AVAudioEngine *engine = [[AVAudioEngine alloc] init];
AVAudioPlayerNode *player = [[AVAudioPlayerNode alloc] init];
[engine attachNode:player];
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:#"piano" withExtension:#"wav"];
AVAudioFile *file = [[AVAudioFile alloc] initForReading:fileURL error:&error];
AVAudioMixerNode *mainMixer = [engine mainMixerNode];
AVAudioOutputNode *outputNode = engine.outputNode;
[engine connect:player to:mainMixer format:file.processingFormat];
[engine connect:engine.mainMixerNode to:outputNode format:nil];
[engine prepare];
if (!engine.isRunning) {
if (![engine startAndReturnError:&error]) {
//TODO
}
}
[player scheduleFile:file atTime:nil completionHandler:nil];
[player play];
NSLog(#"Engine description: %#", [engine description]);
Here's the output of the log call:
Engine description:
________ GraphDescription ________
AVAudioEngineGraph 0x10100d820: initialized = 1, running = 1, number of nodes = 3
******** output chain ********
node 0x28388d200 {'auou' 'rioc' 'appl'}, 'I'
inputs = 1
(bus0, en1) <- (bus0) 0x2838a0880, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x2838a0880 {'aumx' 'mcmx' 'appl'}, 'I'
inputs = 1
(bus0, en1) <- (bus0) 0x282a8df00, {'augn' 'sspl' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
outputs = 1
(bus0, en1) -> (bus0) 0x28388d200, {'auou' 'rioc' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 0x282a8df00 {'augn' 'sspl' 'appl'}, 'I'
outputs = 1
(bus0, en1) -> (bus0) 0x2838a0880, {'aumx' 'mcmx' 'appl'}, [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
______________________________________
I have no idea how to diagnose this and can't find any mistake or reason for which this would not work.
Any idea?
Keeping the question in case anyone has this problem: as I was testing, all my variables were local variables in a test method, and as soon as the method was finished it was probably GC by ARC or something.
Having the AVAudioEngine variable outside (keeping a reference to it) fixed it.
I've got crash with this code
// ViewController.swift
import UIKit
import AVFoundation
class ViewController: UIViewController {
var engine:AVAudioEngine!
var EQNode:AVAudioUnitEQ!
override func viewDidLoad() {
engine.reset()
let Format = engine.inputNode.outputFormat(forBus: 0)
print("channelcount:",engine.inputNode.inputFormat(forBus: 0).channelCount)
//----->Start CRASH App stoped here
engine.connect(engine.inputNode, to: EQNode, format: Format)
engine.connect(EQNode, to: engine.mainMixerNode, format: Format)
var error: NSError?
engine.prepare()
print("done prepare")
do {
try engine.start()
} catch {
print(error)
}
print("done start")
}
}
And if I change Format to nil it make my app not working but not crash.
All of this work perfectly fine on Xcode simulator with no error.
But in the real iOS device (I use iPad 2019) test it crash.
Detail about my app: Live microphone adjust in Equalizer and display Equalized sound real-time.
ERROR:
SelfhearEQ[3532:760180] [aurioc] AURemoteIO.cpp:1086:Initialize: failed: -10851
(enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Float32>)
channelcount: 0
2019-10-22 18:01:29.891748+0700 SelfhearEQ[3532:760180] [aurioc] AURemoteIO.cpp:1086:Initialize: failed: -10851
(enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 1 ch, 44100 Hz, Float32>)
2019-10-22 18:01:29.892326+0700 SelfhearEQ[3532:760180] [avae]
AVAEInternal.h:76 required condition is false: [AVAudioEngineGraph.mm:2127:_Connect: (IsFormatSampleRateAndChannelCountValid(format))]
2019-10-22 18:01:29.896270+0700 SelfhearEQ[3532:760180] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
I found the answer for this it nothing about formatting causing this error.
Check it out on my other question it fixed.
avaudioengine-connect-crash-on-hardware-not-simulator
I am developing a VoIP application using Pjsip in Objective-C.
I want to try and integrate CallKit but I got an error on configureAudioSession. I copied AudioController.h and AudioController.mm from SpeakerBox from Apple into my project.
And I added this code :
AudioController *audioController;
- (void)configureAudioSession {
if (!audioController) {
audioController = [[AudioController alloc] init];
}
}
- (void)handleIncomingCallFrom:(NSString *)dest {
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
[callUpdate setLocalizedCallerName:dest];
[callUpdate setHasVideo:NO];
CXHandle *calleeHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:dest];
[callUpdate setRemoteHandle:calleeHandle];
[provider reportNewIncomingCallWithUUID:[NSUUID UUID] update:callUpdate completion:^(NSError *error){
[self configureAudioSession];
}];
}
Phone is ringing, I can handle the call but it crashes whenever I answer. I receive this error :
AVAudioSession error activating: Error Domain=NSOSStatusErrorDomain Code=561017449 "(null)"
2017-03-09 18:17:48.830893 MyVoIPProject[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>)
2017-03-09 18:17:48.841301 MyVoIPProject[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 44100 Hz, Int16> inf< 1 ch, 44100 Hz, Int16>)
2017-03-09 18:17:48.850282 MyVoIPProject[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 48000 Hz, Int16> inf< 1 ch, 48000 Hz, Int16>)
.
.
.
.
Can you tell me how can I integrate Callkit?
This bug causes by you forget to add the Mircophone description in your Info.plist.
Reference: SpeakerBox from Apple
iOS - AudioUnitInitialize returns error code 561017449
Im trying to make sure my app works on IOS. And doing so by trying to launch it to a IPhonesimulator on my mac.
doing:
./gradlew ios:launchIPhoneSimulator
Makes my app start on the simulator, the standard splashscreen by libgdx appears and then it shuts down and nothing more happends.
But when I build it ./gradlew ios:build ios:launchIPhoneSimulator I get these errors:
2015-06-12 17:39:36.226 IOSLauncher[730:16518] [debug] IOSApplication: iOS version: 8.3
2015-06-12 17:39:36.227 IOSLauncher[730:16518] [debug] IOSApplication: Running in 64-bit mode
2015-06-12 17:39:36.229 IOSLauncher[730:16518] [debug] IOSApplication: scale: 2.0
2015-06-12 17:39:36.347 IOSLauncher[730:16518] [debug] IOSApplication: Unscaled View: Portrait 375x667
2015-06-12 17:39:36.347 IOSLauncher[730:16518] [debug] IOSApplication: View: Portrait 750x1334
2015-06-12 17:39:36.348 IOSLauncher[730:16518] [debug] IOSGraphics: 750.0x1334.0, 2.0
2015-06-12 17:39:37.104 IOSLauncher[730:16518] [debug] IOSGraphics: Display: ppi=264, density=1.65
2015-06-12 17:39:37.631 IOSLauncher[730:16658] 17:39:37.614 ERROR: 98: Error '!obj' trying to fetch default input device's sample rate
2015-06-12 17:39:37.631 IOSLauncher[730:16658] 17:39:37.631 ERROR: 100: Error getting audio input device sample rate: '!obj'
2015-06-12 17:39:37.632 IOSLauncher[730:16658] 17:39:37.632 WARNING: 230: The input device is 0x0; '(null)'
2015-06-12 17:39:37.632 IOSLauncher[730:16658] 17:39:37.632 WARNING: 234: The output device is 0x26; 'AppleHDAEngineOutput:1B,0,1,2:0'
2015-06-12 17:39:37.632 IOSLauncher[730:16658] 17:39:37.632 ERROR: 296: error '!obj'
2015-06-12 17:39:37.632 IOSLauncher[730:16618] 17:39:37.632 ERROR: 296: error -66680
2015-06-12 17:39:37.633 IOSLauncher[730:16518] 17:39:37.632 ERROR: >aurioc> 806: failed: -10851 (enable 2, outf< 2 ch, 44100 Hz, Int16, inter> inf< 2 ch, 0 Hz, Int16, inter>)
2015-06-12 17:39:37.633 IOSLauncher[730:16618] 17:39:37.633 ERROR: 113: * * * NULL AQIONode object
2015-06-12 17:39:37.633 IOSLauncher[730:16518] OAL Error: +[ALWrapper openDevice:]: Could not open device (null)
2015-06-12 17:39:37.633 IOSLauncher[730:16518] OAL Error: -[ALDevice initWithDeviceSpecifier:]: : Failed to create OpenAL device (null)
2015-06-12 17:39:37.635 IOSLauncher[730:16518] OAL Error: +[ALWrapper closeDevice:]: Invalid Value (error code 0x0000a004)
2015-06-12 17:39:37.635 IOSLauncher[730:16618] 17:39:37.635 ERROR: 703: Can't make UISound Renderer
2015-06-12 17:39:37.636 IOSLauncher[730:16518] OAL Warning: -[OALAudioSession onAudioError:]: Received audio error notification, but last reset was 0.377221 seconds ago. Doing nothing.
2015-06-12 17:39:37.636 IOSLauncher[730:16518] OAL Error: -[OALSimpleAudio initWithSources:]: : Could not create OpenAL device
2015-06-12 17:39:37.656 IOSLauncher[730:16518] [error] IOSAudio: No OALSimpleAudio instance available, audio will not be availabe
2015-06-12 17:39:37.944 IOSLauncher[730:16518] [debug] IOSApplication: created
2015-06-12 17:39:39.155 IOSLauncher[730:16658] 17:39:39.155 ERROR: 296: error -66680
2015-06-12 17:39:39.156 IOSLauncher[730:16664] 17:39:39.156 ERROR: >aurioc> 806: failed: -10851 (enable 2, outf< 2 ch, 44100 Hz, Int16, inter> inf< 2 ch, 0 Hz, Int16, inter>)
2015-06-12 17:39:39.157 IOSLauncher[730:16664] OAL Error: +[ALWrapper openDevice:]: Could not open device (null)
2015-06-12 17:39:39.157 IOSLauncher[730:16664] OAL Error: -[ALDevice initWithDeviceSpecifier:]: : Failed to create OpenAL device (null)
2015-06-12 17:39:39.157 IOSLauncher[730:16664] OAL Error: +[ALWrapper closeDevice:]: Invalid Value (error code 0x0000a004)
2015-06-12 17:39:39.157 IOSLauncher[730:16664] OAL Warning: -[OALAudioSession onAudioError:]: Received audio error notification. Resetting audio session.
BUILD SUCCESSFUL
And hereĀ“s my IOSLauncher if its to any help..
public class IOSLauncher extends IOSApplication.Delegate {
#Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new MainClass(null,null), config);
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}
}
You simulator's audio output is borked. The openal audio toolkit is failing init which is causing everything to crash.
When i use PBJVsion to capture a video ,why is the video's start time output by AVAssetWriter is not zero?
the video output imformation use some video tools as below:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Duration: 00:00:08.12, start: 0.023220, bitrate: 1050 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 480x480, 976 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, mono, fltp, 75 kb/s
[17:39:56] scan: decoding previews for title 1