Skip to content

frontend: Fix Streamlabs sync offset overflow - #13875

Open
cuishuang wants to merge 1 commit into
obsproject:masterfrom
cuishuang:master
Open

cuishuang wants to merge 1 commit into
obsproject:masterfrom
cuishuang:master

Conversation

@cuishuang

@cuishuang cuishuang commented Sep 6, 2026

Copy link
Copy Markdown

Description

The Streamlabs importer stores the calculated audio sync offset in an int:

int sync = (int)(in_sync["sec"].number_value() * 1000000000 +
                 in_sync["nsec"].number_value());

This truncates the nanosecond offset to 32 bits. Sync offsets above approximately 2.147 seconds, or below approximately -2.147 seconds, can therefore be converted incorrectly before being written to the imported scene collection.

Calculate the offset using int64_t instead.

Motivation and Context

OBS stores source audio sync offsets as 64-bit nanosecond values through obs_source_set_sync_offset() and obs_data_get_int().

The OBS audio settings UI permits sync offsets up to 20,000 ms, so valid Streamlabs offsets such as 3, 5, 10, or 20 seconds must be preserved during import.

This change keeps the calculation in 64-bit arithmetic. json11 does not provide an int64_t constructor, so the final intermediate JSON value is explicitly represented as double; the supported range is well within the exact integer range of an IEEE-754 double.

How Has This Been Tested?

  • Verified the old and new calculations with Apple Clang for 3, 5, 10, and 20 second offsets.
  • Verified negative offsets, including -3 seconds.
  • Verified that a 3 second offset serializes as 3000000000.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Signed-off-by: cuishuang <imcusg@gmail.com>
@RytoEX RytoEX added kind/bug Categorizes issue or PR as related to a bug. area/ui-ux Anything to do with changes or additions to UI/UX elements. release-note/fix Groups pull request under the "Fixes" section in the associated patch notes labels Sep 9, 2026
@PatTheMav

Copy link
Copy Markdown
Member

Please complete the checklist. Per our contribution guidelines (that you checked to have read) you can check items that do not apply.

@Warchamp7 Warchamp7 self-assigned this Sep 14, 2026
@github-project-automation github-project-automation Bot moved this to Ready For Review in 33.1 Release Tracker Sep 14, 2026
@cuishuang

Copy link
Copy Markdown
Author

Please complete the checklist. Per our contribution guidelines (that you checked to have read) you can check items that do not apply.

@PatTheMav Done, thank you for the clarification.

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

Labels

area/ui-ux Anything to do with changes or additions to UI/UX elements. kind/bug Categorizes issue or PR as related to a bug. release-note/fix Groups pull request under the "Fixes" section in the associated patch notes

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

4 participants