Skip to content

Add support for audio files of more than 2GB (find_frames function); fixes #13#14

Open
arigit wants to merge 17 commits into
LMS-Community:masterfrom
arigit:master
Open

Add support for audio files of more than 2GB (find_frames function); fixes #13#14
arigit wants to merge 17 commits into
LMS-Community:masterfrom
arigit:master

Conversation

@arigit

@arigit arigit commented Jun 5, 2026

Copy link
Copy Markdown

This patch set changes the return type for the *_find_frame functions in all of the Audio Formats that support it (e.g. flac, ogg, ogf, mp4 etc). We change the type to off_t in C, IV in perl, i.e. 64 bit. The original type was 32 bits integer.

Fixes: #13

Before this change, find_frame was returning a negative value when the seek result was pointing to frames that were past the 2GB byte mark in the audio file. This was due to the rollover of the 32 bit integer that was used, unable to accomodate values larger than 2*10^9.

One effect of this issue was that during a library scan, if a multi-track file (e.g. single-flac+cuesheet) was larger than 2GB and there were tracks past the 2GB mark, those tracks get added to the library with a meaningless negative value as starting frame and were not playable in lyrion.

For people using multi-track flac containers, typical Hi-Res 2-channel albums with a total length of more than ~100 minutes were affected by this problem.

arigit added 17 commits June 5, 2026 09:31
The flac_find_frame function was changed to return off_t instead of int
64-bit return type to prevent 32-bit overflow with large flac files
Fixes the 32b rollover in files of more than 2GB
Fixes support for files of > 2GB, prevents 32b rollover
Fixes support for files of > 2GB, prevents 32b counter rollover
Fixes support for files of more than 2GB
Perl-native 64b; off_t does not apply here (that is only for C code)
@arigit arigit changed the title Add support for audio files of more than 2GB (find_frames function); fixes #13 Add support for audio files of more than 2GB (find_frames function); fixes https://github.com/LMS-Community/Audio-Scan/issues/13 Jun 5, 2026
@arigit arigit changed the title Add support for audio files of more than 2GB (find_frames function); fixes https://github.com/LMS-Community/Audio-Scan/issues/13 Add support for audio files of more than 2GB (find_frames function); fixes #13 Jun 5, 2026
@ralph-irving

Copy link
Copy Markdown

Thank you for providing the PR. I'll review and test over the next few days.

@arigit

arigit commented Jun 6, 2026

Copy link
Copy Markdown
Author

My own patch test notes for reference that I had included in the bug discussion, but they belong here.

The patch-set changes all the (*_find_frames) functions, changing return type from int/32bit to off_t/64 bits, c files, header files, and Scan.xs in alignment.

I built the updated binary inside the latest stable LMS 9.1 container, it builds clean (no warnings), and then tested it by replacing scan.so within the container. I rescanned my library, problem solved, all the negative starting frame values are gone. I had some 70 albums (hundreds of tracks) that were affected by this.

I tested playback of many of the formerly unplayable tracks (the ones beyond the 2GB boundary) - fully playable, issue fixed.

I recommend exposing this change in nightly builds for a while, my collection only has flacs so we want to expose this to more diverse testing. Other formats that should now work with files of more than 2GB: ogg, opus, ogv, mp4, asf, mp3.

While it's common to have these days hi-res multi-track flac going beyond 2GB that would trigger the problem, I saw postings in the forum of people having issues with very long single-track recordings as well. The old issue impacted very long high-bit-rate mp3, ogg etc, which should now work fine with LMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-file (multi-track) FLAC + Cuesheet issue when the FLAC size is > 2GB

2 participants