Skip to content

use a per-call DecimalFormat in OggAudioParser duration output#2920

Open
rootvector2 wants to merge 2 commits into
apache:mainfrom
rootvector2:ogg-per-call-decimalformat
Open

use a per-call DecimalFormat in OggAudioParser duration output#2920
rootvector2 wants to merge 2 commits into
apache:mainfrom
rootvector2:ogg-per-call-decimalformat

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

the static DURATION_FORMAT is shared across the ogg parser singletons but DecimalFormat is not thread-safe, so concurrent parses race on its mutable internal state; create it per call inside extractDuration like MP4Parser already does.

@hiSandog

hiSandog commented Jul 3, 2026

Copy link
Copy Markdown

Moving DecimalFormat to per-call scope is the right fix for thread safety. One small regression test would make this durable: parse two Ogg inputs concurrently with different duration shapes and assert the emitted metadata is stable across repeated runs. That would catch both shared formatter mutation and any future attempt to reintroduce a static formatter for allocation savings.

@rootvector2

Copy link
Copy Markdown
Contributor Author

good call. added OggAudioParserDurationTest that drives extractDuration from 32 threads over a set of rounding-heavy duration shapes and asserts XMPDM.DURATION matches the single-threaded value every time. it stays green now and would fail if a shared static formatter ever came back.

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.

2 participants