Slow buffering, pops, and crackles with BASS_StreamCreateFileUser on Android

Started by mcooper,

mcooper

All of our music files are either eaac+ or aac so its only been noticed on those.  Most users have said this issue is unique to our app, although one user admitted that he has also heard crackling on another music app (google play music), but much less frequently.

Valdi

Hello Ian!

We've added BASS_CONFIG_DEV_NONSTOP to our code for android to avoid pops and crackling between tracks.
The problem we have now is that it consumes a lot of power while the music is in paused state.
One of wake locks audiomix is not released until I remove that option from our code.

Is there any way to fix that issue?
Thanks in advance for your help.

Ian @ un4seen

I'm not sure whether it will be as effective as enabling BASS_CONFIG_DEV_NONSTOP, but one thing you could try is just delaying the stopping of the output for a short time. You could do that by using a sample of the wanted delay length. For example, something like this:

// initialization
BASS.BASS_SetConfig(BASS_CONFIG_DEV_NONSTOP, 0); // disable nonstop output
sample=BASS.BASS_SampleCreate(30*2, 1000, 1, 1, 0); // create a 30ms sample

...

// pausing playback
int samchan=BASS.BASS_SampleGetChannel(sample, false); // get a sample channel
BASS.BASS_ChannelSetAttribute(samchan, BASS.BASS_ATTRIB_VOL, 0); // mute it (saves CPU)
BASS.BASS_ChannelPlay(samchan, false); // start it
BASS.BASS_ChannelPause(music); // pause playback of the music

You can try adjusting the length of the sample to find the smallest (if any) delay that works. If that avoids the "pops" when stopping playback, but you're also getting them when starting, then you could also try playing the sample just before starting playback of the main channel.

Ian @ un4seen

If delaying the output stopping doesn't help (eg. it just delays the "pop" sound), then another thing you could try is the BASS_CONFIG_DEV_PERIOD option. That was added quite recently and is currently undocumented, but it controls how often BASS sends data to the output device and how much each time. The default setting is 10ms, which means it sends 10ms of data to the output device 100 times per second. Perhaps raising that (eg. to 15ms) will reduce the power usage when BASS_CONFIG_DEV_NONSTOP is enabled. Note that it needs to be set prior to calling BASS_Init, like the BASS_CONFIG_DEV_BUFFER option.