Repository navigation
Read a directory scan without retaining audio payloads - #120
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #120 +/- ##
==========================================
+ Coverage 93.01% 93.06% +0.05%
==========================================
Files 283 287 +4
Lines 54782 56456 +1674
Branches 5028 5370 +342
==========================================
+ Hits 50953 52540 +1587
- Misses 2280 2294 +14
- Partials 1549 1622 +73 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Path and stream reads keep tags, pictures, and small headers. Media payloads stay on disk and are copied back from the source path when a save rewrites the tags.
MemoryStream has no span write on that target, and IsNullOrEmpty does not narrow a source path there. Both broke the Release build in CI.
Add a BenchmarkDotNet project so a directory scan can be remeasured. The suite reads MP3, WAV, and FLAC through MediaFile.Read and reports allocations with MemoryDiagnoser.
BenchmarkDotNet 0.16.0-preview.2 is required for a net11 job. The benchmark project targets net11 only when the SDK is 11 or newer, so CI stays on the 8.0 and 10.0 SDKs.
MediaFile.Read opens the path directly. Format detection reads 32 bytes so the file buffer can satisfy the parser, and the MP3 window fills one array instead of copying its audio probe.
LAME stores that count as the stream size, including bytes before the first audio frame. A count past the end of the file still walks the frames that are present. The tag and the audio probe are read into one buffer.
decriptor
force-pushed
the
perf/scan-without-audio
branch
from
November 18, 2026 07:17
9361587 to
8c53708
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
MediaFile.Read(path)/ReadAsync(path)scan no longer keeps the audio or video payload. After the call returns, the file object holds tags, metadata pictures, and small headers (plus, for AIFF, the offset and length of each skippedSSND). Sample bytes stay on disk.Windowed formats, in addition to the MP3, FLAC, and WAV reads already on main:
mdat(the span parser no longer copies that box either).stco/co64/tfhd/tfra/saio/ilocstill move whenmoovchanges size.SSND. WavPack, Monkey's Audio, and Musepack read the header and the trailing APE tag. DSF reads the DSD/fmt/data headers and the ID3 tag at the metadata offset. DFF reads every chunk exceptDSD/DSTpayloads. ASF reads the header object and skips the data object.Save rewrites tags and copies the original payload bytes unchanged. A path opened file reloads those bytes from
SourcePaththroughfileSystem ??the filesystem stored at read time, and the same filesystem is what the write uses. A save with no source path and no loaded payload fails without replacing the file.Read(byte[])still keeps one copy where an in-memory render has no other source (APE-style files, ASF, DSF, DFF, Ogg FLAC, and AIFF opened from a buffer).Fixes #20
Comparison with TagLib# 2.3.0
Warm read of a local library of 4,668 MP3s, about 29 GB. Both calls open the file, read the title, the duration, and the picture count, then dispose it. .NET 8.
TagLib# 2.3.0 is the latest release on NuGet. Six empty files fail in both. TagLib# also rejects two files that contain no MPEG audio frame.
Tests
dotnet test tests/TagLibSharp2.Tests/TagLibSharp2.Tests.csproj -c Debug -f net8.0 -p:WarningsNotAsErrors=CA2027Passed: 4315, Failed: 0, Skipped: 10, Total: 4325
dotnet format TagLibSharp2.slnx --verify-no-changes --severity warnis clean.