igorski / MWEngine

Audio engine and DSP library for Android, written in C++ providing low latency performance within a musical context, while providing a Java/Kotlin API. Supports both OpenSL and AAudio.
MIT License
261 stars 45 forks source link

sometimes sound is interrupted for a few ms #57

Closed harthorst closed 5 years ago

harthorst commented 5 years ago

there are some sound glitches from time to time. in the log I see:

IBufferQueue.c:57: pthread_mutex_lock_timeout_np returned 110

Google says that's a general problem but maybe you have some hints to prevent this. My app is using up to 5% of cpu power and I'm working with SampleEvents only.

igorski commented 5 years ago

Hi, this is a tough one to crack as it lies outside of the engine's reach. The fact that your app is very low on CPU resources would indicate that there is no issue with threading priority, can you do the same check for memory allocation using a profiler (the one in Android Studio is great for this) ? Also, can you verify whether there are other applications in the background that could be generating audio (most other music making applications could be expected to use OpenSL as well). This is also the reason why the ExampleActivity for MWEngine releases the OpenSL callback when suspending the app.

harthorst commented 5 years ago

Hi. Memory usage is about 29-30MB. I'm also sure the reason for this problem lies outside of the app. After I uninstalled some apps and restarted the phone it was much better.

teotigraphix commented 5 years ago

I have this as well testing on Nexus 7 2nd Gen.

I profiled and memory and CPU seem fine, CPU for the app is not even about 5-10%.

This was also with nothing running(apps in background)

harthorst commented 5 years ago

Just for the record: Increasing buffer size helped a lot.