Trying to get smooth output on Android - AudioTransportSource and TimeSliceThread

I’m testing some simple audio playback on Android based on the Audio Player Tutorial. I’ve been getting some choppy/buffer overflow sounding audio, so now trying to use a TimeSliceThread and set a buffer size to try and get smooth playback, e.g.

transportSource.setSource (readerSource, 8192, &timeSliceThread, reader->sampleRate);

and I am also starting the thread in the class constructor.

However when I add the non-zero buffer size and &timeSliceThread argument, the app stops in its tracks at this point in the log:

Audio device - min buffers: 8208, 640; 44100 Hz; input chans: 2
OpenSL: numInputChannels = 0, numOutputChannels = 2, nativeBufferSize = 1024, nativeSampleRate = 44100, actualBufferSize = 6144, audioBuffersToEnqueue = 4, sampleRate = 44100
Suspending all threads took: 15.044ms

Replacing the line as previous with

transportSource.setSource (readerSource, 0, nullptr, reader->sampleRate);

allows it to load again.

Any clues?

Seems like this issue has gone now, not sure what changes got it working (no longer using an AudioAppComponent?)

I’m having a difficult time getting audio playing without crackling and dropouts on the Android emulator. Do you guys have some advice on getting smooth audio output on Android? So far I’ve only worked with audio input analysis on Android.

Audio on the android emulator is nearly impossible to use. I’ve talked to Android developers about this and they recommended to not use the emulator for audio apps.

1 Like