Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Gapless broken on Android (Read 6088 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Gapless broken on Android

I've been using Foobar2000 mobile on Android for a few years, since Google Play Music was withdrawn. Proper gapless support has always been very important to me, and it has always worked flawlessly. However, in the last week or so I've noticed it seems to be broken.

My files are all in m4a format, encoded using the Apple iTunes AAC encoder by Foobar2000 on Windows, mostly from CDs ripped to FLAC. They are stored on an SD card in my phone. The files aren't the problem because there are thousands of them, some years old, and they all used to play fine without gaps. My phone is a Moto G73 5G running Android 14. I've tried turning on, and turning off, all battery saving optimisations, using OpenSL audio output, listening via several different Bluetooth devices, or wired headphones, or the phone's speaker, and disabling the Dolby Atmos app. None of it makes any difference and I can't think of anything else. There is a short half-second gap between tracks – but if you then immediately rewind to the end of the previous track to try to repeat it, the gap disappears. But then it's back for the next track, and if you leave an album to play through, the gaps are always there. It seems to make no difference if the app is foregrounded or backgrounded. I don't know if the issue was introduced by the update to Android 14, or by the recent Foobar2000 app update, or something else, and I'm at a loss how to fix it.

Can anyone help? Are others seeing the same issue? Many thanks.

Re: Gapless broken on Android

Reply #1
If I open the console, I see the message "Playback interrupted, source is stalling..." is logged between each line showing "Opening track for playback" followed by the location on the SD card. Also, turning on or off the option to use read-ahead for playing local files in the advanced options doesn't seem to help.

Re: Gapless broken on Android

Reply #2
Yesterday I encoded another album from a CD, using a different operating system (Linux not Windows), different software (fre:ac instead of foobar2000) and a different codec (Opus instead of Apple AAC). I transferred it to the SD card in my phone, and when I listened to it, it played back perfectly, with no gaps. But when I played exactly the same album again today, the gaps are all back! I have not even restarted my phone since yesterday.

So I played a random old album, that I'm sure I've never played before since I last changed my phone. It played back without gaps. But when I closed the foobar2000 app and reopened it and played the album a second time, the gaps were back. So I chose another random old album -- but this time, the gaps were present the first time I played it. Now I can't get anything to play without gaps again.

Is no one able to replicate this really strange behaviour? I can't think of anything remotely unusual about my set-up: a mass-market Motorola phone, running Android 14, playing music off a new, fast, branded 128 GB SD card, through wired headphones. Are the devs likely to see this, or is there some way of raising a bug report? Thanks for anyone who can help!

Re: Gapless broken on Android

Reply #3
Have you tried checking your SD card for issues?  Or tried a lossless format like FLAC for a few albums to see if it disappears entirely?

Re: Gapless broken on Android

Reply #4
It's a 128 GB Integral Ultima Pro Micro SDXC card bought from a Currys shop (a large UK retailer) only a few months ago. I checked it with H2testw, which found no errors and reported a read speed of 17.6 MB/s and a write speed of 17.2 MB/s. So it seems to be genuine and working fine. It was formatted in the phone itself. I also store photos and videos on it, and it seems happy transferring data fast between Windows, Linux and Android devices.

I haven't tried playing FLAC files from it. I will see if that makes any difference and report back. Thanks for the input. Does anyone else have any ideas? I would be really interested to hear if anyone else can replicate this, as I can't understand why it would only be happening to me. Is gapless really still working fine for others using SD storage on Android 14?


Re: Gapless broken on Android

Reply #6
Well, encoding using FLAC doesn't make any difference. I am still getting gaps between tracks (apart from the very first time I play the album, immediately after copying it on to the SD card) and the console log is still showing the message "Playback interrupted, source is stalling..." in between each line showing "Opening track for playback". So the behaviour is the same whatever the codec.

Thanks for the feedback, @marc2k3 . Yes, it used to work perfectly for me, too, on my ancient Nokia 7 running Android 9. I am guessing therefore that something changed in requesting SD card reads in Android 13 or 14, and it now takes slightly longer to access a file, causing the momentary stalling. Maybe the files are cached briefly when first copying them across, which is why it works the first time but not the following day. I can't see any way of changing read-ahead times in the app, unless anyone knows better? Do the devs see this forum?

Re: Gapless broken on Android

Reply #7
does this happen to files copied into the internal memory?
fwiw Android SD card support was hit or miss for its entire history, sadly.

what if you format the SD card on the computer?
and try different supported filesystems, notably exFAT (which has a chance to work on some Android phones)?

> Do the devs see this forum?
Yes, at least some of the times
a fan of AutoEq + Meier Crossfeed

Re: Gapless broken on Android

Reply #8
Also, to rule out a foobar2000 update, I guess you can try old builds, apparently they are still hosted:
https://www.foobar2000.org/old
a fan of AutoEq + Meier Crossfeed

Re: Gapless broken on Android

Reply #9
If I copy an album from the SD card to the internal memory, gapless works correctly with no gaps between tracks. I am not an Android developer, but this suggests to me that my theory about SD card read accesses taking longer on Android 13/14 than they used to may be correct. But if so I'm amazed no one else has noticed. Maybe I'm the only one who cares about gapless who still wants to use SD cards on a new phone!

Could the devs at least try reading ahead the next track slightly earlier, as I think this would solve the problem? Or allow the read-ahead time to be increased in the advanced settings in the app?

Re: Gapless broken on Android

Reply #10
If I copy an album from the SD card to the internal memory, gapless works correctly with no gaps between tracks. I am not an Android developer, but this suggests to me that my theory about SD card read accesses taking longer on Android 13/14 than they used to may be correct. But if so I'm amazed no one else has noticed. Maybe I'm the only one who cares about gapless who still wants to use SD cards on a new phone!

Could the devs at least try reading ahead the next track slightly earlier, as I think this would solve the problem? Or allow the read-ahead time to be increased in the advanced settings in the app?
I have no issues with gapless on my older DAP, iBasso DX160 running Android 8.1. However what you have described is likely an issue Google introduced with the SAF requirements. Perhaps some sort of read ahead as you mention can help but not sure if this is the best solution for these newer devices.

Re: Gapless broken on Android

Reply #11
If I copy an album from the SD card to the internal memory, gapless works correctly with no gaps between tracks. I am not an Android developer, but this suggests to me that my theory about SD card read accesses taking longer on Android 13/14 than they used to may be correct. But if so I'm amazed no one else has noticed. Maybe I'm the only one who cares about gapless who still wants to use SD cards on a new phone!

Could the devs at least try reading ahead the next track slightly earlier, as I think this would solve the problem? Or allow the read-ahead time to be increased in the advanced settings in the app?
I have no issues with gapless on my older DAP, iBasso DX160 running Android 8.1. However what you have described is likely an issue Google introduced with the SAF requirements. Perhaps some sort of read ahead as you mention can help but not sure if this is the best solution for these newer devices.

I'm not sure I follow you. What other solution is there? If Google have changed something, I doubt they will change it back. So the only option is to change foobar2000 to make it work again, otherwise, as more people (unwillingly, in my case!) upgrade their phones, it will eventually stop working for everyone.

I'm assuming (and, as I said, I'm not an Android developer!) that there is some degree of read-ahead already, as surely gapless would be impossible if the app literally waits until one file is completely finished before demanding the next. So I was just proposing increasing it a tiny bit because accesses seem to take slightly longer than they used to. Maybe I'm being simplistic?

Re: Gapless broken on Android

Reply #12
If I copy an album from the SD card to the internal memory, gapless works correctly with no gaps between tracks. I am not an Android developer, but this suggests to me that my theory about SD card read accesses taking longer on Android 13/14 than they used to may be correct. But if so I'm amazed no one else has noticed. Maybe I'm the only one who cares about gapless who still wants to use SD cards on a new phone!

Could the devs at least try reading ahead the next track slightly earlier, as I think this would solve the problem? Or allow the read-ahead time to be increased in the advanced settings in the app?
Works fine for me on A 14 and I do care about gapless (a lot).
Maybe it helps that it's LineageOS, they provide updates more often (every week) and do not include bloatware.
I checked, sadly seems like it's not available for Moto G73. Maybe eventually someone will make it happen though? If the phone is not too locked down to begin with.
a fan of AutoEq + Meier Crossfeed

Re: Gapless broken on Android

Reply #13
I'm not sure I follow you. What other solution is there? If Google have changed something, I doubt they will change it back. So the only option is to change foobar2000 to make it work again, otherwise, as more people (unwillingly, in my case!) upgrade their phones, it will eventually stop working for everyone.
Your suggestion about increasing the read-ahead may potentially resolve this in some cases. But other users have already reported they don't have this issue on devices with A14. So the read-ahead may not be the real problem. So my point was that until the developer has a chance to look into this further there is now way to guess at what may need to be done.

Re: Gapless broken on Android

Reply #14
Might want to try latest preview build, I noticed that we had rather low buffer size of 1 second, with no tweak option to override. I bumped the default to 5 seconds for 1.6.2.
Sounds like what you're experiencing is a symptom of exactly this, though strangely I have never encountered the problem on my own devices, including some really low spec ones...

I'm planning to do this properly (output settings page) for 1.7.
Microsoft Windows: We can't script here, this is bat country.

Re: Gapless broken on Android

Reply #15
Thank you so much, Peter, and I'm very sorry for the long delay in replying: the forum didn't notify me of your post so I didn't know about it!

The change to a 5 second buffer in 1.6.2 has solved the problem for me! I'm so happy about that. Gapless is working again. If I look in the console, I can see the new track being opened well in advance of the previous one finishing, and the "Playback interrupted, source is stalling..." message is no longer shown.

An adjustable buffer in 1.7 would be great, as I think even on my problematic device 2 seconds would probably be enough.

My old phone was prehistoric compared to my new one, and it used to work just fine too – so low spec devices don't seem to be at the root of the problem. Not sure what's going on, but you've fixed it, so thank you!

Re: Gapless broken on Android

Reply #16
Might want to try latest preview build, I noticed that we had rather low buffer size of 1 second, with no tweak option to override. I bumped the default to 5 seconds for 1.6.2.
Sounds like what you're experiencing is a symptom of exactly this, though strangely I have never encountered the problem on my own devices, including some really low spec ones...

I'm planning to do this properly (output settings page) for 1.7.
Any idea why this needs to be such a long buffer on newer/faster devices? Seems counter to the idea of superior devices to have them need more buffer time.

Re: Gapless broken on Android

Reply #17
Might want to try latest preview build, I noticed that we had rather low buffer size of 1 second, with no tweak option to override. I bumped the default to 5 seconds for 1.6.2.
Sounds like what you're experiencing is a symptom of exactly this, though strangely I have never encountered the problem on my own devices, including some really low spec ones...

I'm planning to do this properly (output settings page) for 1.7.
Any idea why this needs to be such a long buffer on newer/faster devices? Seems counter to the idea of superior devices to have them need more buffer time.

I'm sure it doesn't need to be quite that long, the gap I was hearing was a fraction of a second, so I think a one-second buffer just wasn't quite long enough. But why SD card accesses apparently take longer on a new phone with a new card than they did on an old phone with an old card – pass. I'm guessing Google have "improved" Android in some way but how or why I don't know. Or maybe it's Motorola's doing: there's something called "ThinkShield" on my phone which is enabled and can't be disabled and which claims to be "enhancing protection at every level". All I can say is that reads clearly do take a fraction longer on this phone, because increasing the buffer has solved the problem.

Re: Gapless broken on Android

Reply #18
> I bumped the default to 5 seconds for 1.6.2.

Is this also for the situation when "read ahead" is not enabled?
(in the past I noticed sometimes "read ahead" had worsened the playback stability if I turned it on)
it is also diffucult to understand if I try to think about it - one would assume that for gapless, at least some read-ahead is inherently necessary either way, no?
a fan of AutoEq + Meier Crossfeed

Re: Gapless broken on Android

Reply #19
Buffer is for decoded data. Read-ahead is for data read from file. So, buffer that is big enough can compensate for lack of read-ahead.