fix timing issue with _concatenate_fragements #1039
Merged
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.
This pull request intends to address a timing issue when concatenating fragments. It results in an error discussed here.
I have incorrectly diagnosed the problem a couple times but I think I have it figured out now.
To reproduce
create_event_clipenabledIn theory this would also result in not taking into account all segments if a segment ends during the recording and another is started while recording is in progress.
This case will not result in an error. However, there will be one segment missing from the concatenation.
The fix
The in the PR involved adding a delay in the thread that concatenates the segments. This allows time for in progress segments to be written to disk.
Reason for this solution and alternate approach
It seems like a delay similar to this is used at another locaation in the code.
An alternate way may be able to have logic that blocks the concatenation until the in progress segment is written to disk.
As this is for the clip recording feature it is OK to have this delay before the recording is fully complete.
Test cases
There should be test cases that address the cases I am aware of. One can comment out the delay in concatenation to see the impact on the test cases.
The return value to
_concatenate_fragmentswas added to aid in unit testing.