You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working with @piyushtank on integrating the ExampleAVAudioEngineDevice into our Twilio based app and it's working great from the mixed audio standpoint, the major issue I currently have is that the application will randomly crash on startup sometimes when it creates an instance of ExampleAVAudioEngineDevice. It is not reproducible every time, but it happens much more frequently on the simulator then on an actual device, although it's happening on about 25% of launches on our testing hardware.
The crash occurs in the ExampleAVAudioEngineDevicePlayoutCallback and it ALWAYS happens when the system goes through the else path in the startRendering function below. The crash doesn't happen when the startup doesn't fall through this else path. I'm wondering if anyone has any insight into how we can lock down the startup sequence so it's not random in how it starts up so we don't end up crashing on startup.
My current version of the device file ( minimal changes made to export the AudioEngines )
`- (BOOL)startRendering:(nonnull TVIAudioDeviceContext)context { @synchronized(self) {
NSLog(@"START RENDERING");
/*
* In this example, the app always publishes an audio track. So we will start the audio unit from the capturer
* call backs. We will restart the audio unit if a remote participant adds an audio track after the audio graph is
* established. Also we will re-establish the audio graph in case the format changes.
*/
if (_audioUnit) {
[self stopAudioUnit];
[self teardownAudioUnit];
}
// If music is being played then we have already setup the engine
if (!self.continuousMusic) {
// We will make sure AVAudioEngine and AVAudioPlayerNode is accessed on the main queue.
dispatch_async(dispatch_get_main_queue(), ^{
AVAudioFormat *manualRenderingFormat = self.playoutEngine.manualRenderingFormat;
TVIAudioFormat *engineFormat = [[TVIAudioFormat alloc] initWithChannels:manualRenderingFormat.channelCount
sampleRate:manualRenderingFormat.sampleRate
framesPerBuffer:kMaximumFramesPerBuffer];
if ([engineFormat isEqual:[[self class] activeFormat]]) {
if (self.playoutEngine.isRunning) {
[self.playoutEngine stop];
}
NSError *error = nil;
if (![self.playoutEngine startAndReturnError:&error]) {
NSLog(@"Failed to start AVAudioEngine, error = %@", error);
}
} else {
NSLog(@"TEARING DOWN AND RESTARTING PLAYBACK ENGINE");
[self teardownPlayoutFilePlayer];
[self teardownPlayoutAudioEngine];
[self setupPlayoutAudioEngine];
}
});
}`
The text was updated successfully, but these errors were encountered:
Just as a further piece of information it seems like if the device has a 48mhz microphone we end up in this crash scenario as the call to check if our current engineFormat matches the activeFormat fails ( engineFormat is 44100 ). On some devices these values match and on others they do not which causes the crash.
I've been working with @piyushtank on integrating the ExampleAVAudioEngineDevice into our Twilio based app and it's working great from the mixed audio standpoint, the major issue I currently have is that the application will randomly crash on startup sometimes when it creates an instance of ExampleAVAudioEngineDevice. It is not reproducible every time, but it happens much more frequently on the simulator then on an actual device, although it's happening on about 25% of launches on our testing hardware.
The crash occurs in the ExampleAVAudioEngineDevicePlayoutCallback and it ALWAYS happens when the system goes through the else path in the startRendering function below. The crash doesn't happen when the startup doesn't fall through this else path. I'm wondering if anyone has any insight into how we can lock down the startup sequence so it's not random in how it starts up so we don't end up crashing on startup.
My current version of the device file ( minimal changes made to export the AudioEngines )
`- (BOOL)startRendering:(nonnull TVIAudioDeviceContext)context {
@synchronized(self) {
NSLog(@"START RENDERING");
/*
* In this example, the app always publishes an audio track. So we will start the audio unit from the capturer
* call backs. We will restart the audio unit if a remote participant adds an audio track after the audio graph is
* established. Also we will re-establish the audio graph in case the format changes.
*/
if (_audioUnit) {
[self stopAudioUnit];
[self teardownAudioUnit];
}
The text was updated successfully, but these errors were encountered: