Call cannot be disconnected due to delay observed in AudioOutputUnitStop API

We have a VOIP calling application that releases resources at the end of call. When the AudioOutputUnitStop API is invoked, it takes upto 700millisecond to return back sometimes. If we comment that API call as a test then the AudioUnitUninitialize API takes upto 700ms. Once the cleanup is done, as part of the call flow, the application invokes a BYE SIP message. Hence in cases where the API takes more than 200 ms, the Bye message is sent with that much delay and gets blocked as per the server DDOS settings. (DDOS timer will start as soon as a the UDP socket is disconnected with the client and will timeout within 200 ms and Bye request coming post that time will get blocked) We need to understand why there is a delay of more than 200ms observed sometimes while in other cases it requires less than 50ms?

Hello @Adhakde, thank you for your post. You might be able to work around this issue by not waiting for AudioOutputUnitStop or AudioUnitUninitialize to finish before you message your server. If your current logic is synchronous, an asynchronous design could help you release resources and message your server at the same time.

Thanks for your response.

We tried asynchronous designing approach but it causes some other issues. The current architecture is designed in such a way where “AudioOutputUnitStop” should release resource synchronously. This approach would require some major architecture level changes. For example, users may get another call in parallel and before answering that call, the previous call must be ended cleanly before allocating resources to the new call.

Is there any other way to reduce the API time for AudioOutputUnitStop API or use any alternate API ?

Call cannot be disconnected due to delay observed in AudioOutputUnitStop API
 
 
Q