refactor(processor): serialize AVFilterGraphFree calls with mutex for loudnorm concurrency safety#101
Merged
Merged
Conversation
Verify that FFmpeg's ebur128 filter under metadata=1 emits zero AV_LOG_INFO lines during frame processing, with all ~47 lines (ebur128 + astats) deferred to graph teardown. Control run confirms metadata=0 produces 33,000 mid-loop lines, validating that metadata mode suppresses per-frame framelog. Confirms Option 1 (single process-wide mutex around AVFilterGraphFree) is sufficient for concurrent multi-file processing. Test gracefully skips if testdata/fixture-5m.flac is absent. Signed-off-by: Martin Wimpress <code@wimpress.io>
… loudnorm concurrency safety - Introduce process-global graphFreeMu mutex to serialize all AVFilterGraphFree calls - Add freeFilterGraphLocked helper that acquires lock before free in normalise.go - Route all 8 production free sites through freeFilterGraphLocked (frame_processor, analyzer, analyzer_output, processor) - Extend loudnorm capture bracket (startLoudnormCapture/stopLoudnormCapture) to hold graphFreeMu lock across entire raise→install→free→parse→restore span - Fold lifecycleMu into graphFreeMu (superset covers all graph-free exclusion, eliminates redundancy) - Extract inline filter literal at analyzer_output.go:40 to package-level constant outputRegionAnalysisFilterFormat for guard test reuse - Add normalise_guard_test.go with TestMetadataModeGuard and TestLoudnormCaptureExcludesConcurrentGraphFree assertions These changes make loudnorm JSON capture safe under parallel multi-file processing. Serial path unchanged; verified under -race. Signed-off-by: Martin Wimpress <code@wimpress.io>
Contributor
There was a problem hiding this comment.
No issues found across 7 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This PR introduces a global mutex to serialize AVFilterGraphFree calls across the processor package, affecting core concurrency and locking patterns; despite clean AI review, such refactors carry risk of deadlocks or performance regressions in production paths and require human judgment to validate.
Re-trigger cubic
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.
raise→install→free→parse→restore span
These changes make loudnorm JSON capture safe under parallel multi-file processing. Serial path unchanged; verified under -race.