Skip to content

Fix #438 by accounting for the fact that only half of the buffer of a continuous flow is readable at any one point in time#443

Open
KimonHoffmann wants to merge 1 commit intomainfrom
users/kimonhoffmann/fix_438
Open

Fix #438 by accounting for the fact that only half of the buffer of a continuous flow is readable at any one point in time#443
KimonHoffmann wants to merge 1 commit intomainfrom
users/kimonhoffmann/fix_438

Conversation

@KimonHoffmann
Copy link
Copy Markdown
Collaborator

The configured history duration is used to determine the buffer size, but before this change this failed to account for the fact that only half of the buffer is readable at any one point in time, effectively halving the history duration for all continuous flows.

@KimonHoffmann KimonHoffmann requested review from a team March 26, 2026 14:21
@KimonHoffmann KimonHoffmann self-assigned this Mar 26, 2026
@KimonHoffmann KimonHoffmann added the backport/v1.0 This PR should be back ported to the release branch of version 1.0. label Mar 26, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Test Results

70 tests  ±0   70 ✅ ±0   17s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 0d5b266. ± Comparison against base commit 3394ee9.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@pedro-alves-ferreira pedro-alves-ferreira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. LGTM, with one comment.

auto const sampleRate = parser.getGrainRate();
// Compute the grain count based on our configured history duration
auto const bufferLength = _historyDuration * sampleRate.numerator / (1'000'000'000ULL * sampleRate.denominator);
auto const bufferLength = _historyDuration * sampleRate.numerator / (500'000'000ULL * sampleRate.denominator);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment to make it clearer. Something like: "The denominator is multiplied by 500M, rather than 1B, so that the buffer length is twice as large as the history duration."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, I added an explanatory comment.

… continuous flow is readable at any one point in time.

Signed-off-by: Kimon Hoffmann <Kimon.Hoffmann@lawo.com>
@vt-tv
Copy link
Copy Markdown
Contributor

vt-tv commented Apr 1, 2026

@KimonHoffmann could you add the unit test that was attached to the bug report? that would validate your fix

@KimonHoffmann
Copy link
Copy Markdown
Collaborator Author

@KimonHoffmann could you add the unit test that was attached to the bug report? that would validate your fix

Unfortunately not, because it lacks a DCO signoff and does not follow the practices of our unit tests (it has intermittent console output, for example). I can try to attach a clean room test instead.

@SpungeCake
Copy link
Copy Markdown

Hi, Serge from GV here, I'm the one who reported the problem to Vincent Trussart. This is not an acceptable fix, I tried it with the unit test I wrote that reproduces the issue, still not fixed. Doubling the history will make the size match the video and anc duration but for an audio only configuration the returned size is invalid since only half of it is usable. That makes the test fail.

@KimonHoffmann
Copy link
Copy Markdown
Collaborator Author

KimonHoffmann commented Apr 2, 2026

Hi, Serge from GV here, I'm the one who reported the problem to Vincent Trussart. This is not an acceptable fix, I tried it with the unit test I wrote that reproduces the issue, still not fixed. Doubling the history will make the size match the video and anc duration but for an audio only configuration the returned size is invalid since only half of it is usable. That makes the test fail.

You mean that only half of mxlContinuousFlowConfigInfo::bufferLength is actually accessible for reading?
While I agree that this does not match the way in which mxlDiscreteFlowConfigInfo::grainCount can be used, we claim nowhere that all of bufferLength is accessible for reading. On the contrary the documentation in architecture.md explicitly states otherwise.

We can consider how to improve the UX on this, I'm not really in favor of having the physical buffer length diverge from mxlContinuousFlowConfigInfo::bufferLength, but maybe an easy to use inline function to obtain the usable min-index for a given flow could be a way to help users?

@SpungeCake
Copy link
Copy Markdown

My point is mainly that a flow writer and reader user need to know exactly how much data a flow can hold and when it is outside the range. This fixes the continuous buffer duration not matching the discrete flow, I'm ok with this. However we still need to provide a way for a continuous user to know the exact history duration. I just find it awkward that I have to divide by 2 the bufferLength given by the mxlContinuousFlowConfigInfo, we need a cleaner way, maybe inline function will do the work. The fact that mxlFlowConfigInfo is a union of the two types of config makes you think it returns a similar information about the buffer duration, I'm pretty sure more will do the same mistake and not divide the bufferLength by two. At least flowinfo.h header should be updated to explain this for mxlContinuousFlowConfigInfo.

@KimonHoffmann
Copy link
Copy Markdown
Collaborator Author

Yes, I agree that the UX as it is right now is error prone.
I think an inline function and a comment in mxlContinuousFlowConfigInfo referring to it should do the trick.

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

Labels

backport/v1.0 This PR should be back ported to the release branch of version 1.0.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

History duration issue with continuous ring buffers

4 participants