Skip to content

core: add SMBF_LAST media bug flag to keep a bug behind all others - #3

Merged
pragmatrix merged 5 commits into
v1.11.3-qnfrom
smbf-last
Oct 19, 2026
Merged

pragmatrix merged 5 commits into
v1.11.3-qnfrom
smbf-last

Conversation

@pragmatrix

@pragmatrix pragmatrix commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Why

To record audio reliably, the recording bug has to see each frame after every other bug has changed it. On the write path, SMBF_WRITE_STREAM and SMBF_WRITE_REPLACE callbacks run in one loop in list order, so a recorder only sees the written audio as modified by the bugs linked in front of it. SMBF_FIRST lets a bug go to the front of the list, but nothing lets a bug stay at the end: any bug added later is appended behind it. So once a bug that replaces written frames is added after the recording starts, the recording no longer captures the audio that is actually sent.

The read path doesn't have this problem: all SMBF_READ_REPLACE callbacks run before any SMBF_READ_STREAM buffer is filled. There, SMBF_LAST only orders the replace bugs among themselves.

Summary

  • Add SMBF_LAST (1 << 28). A bug added with this flag goes to the end of the list. Bugs added after it, without the flag, are linked in front of the first SMBF_LAST bug, so SMBF_LAST bugs always stay at the tail, in the order they were added.
  • switch_core_media_bug_add rejects SMBF_FIRST | SMBF_LAST with SWITCH_STATUS_GENERR.
  • The flag is only honored when the bug is added. Setting it later with switch_core_media_bug_set_flag does not move the bug.
  • Unit test media_bug_last_ordering in tests/unit/switch_ivr_async.c pins down the ordering together with SMBF_FIRST.

Validation

  • Not built or tested locally: the tree isn't configured on the dev machine, and this fork has no CI runs.
  • fs-image runs switch_ivr_async in its unit-test stage, so it will cover the new test once it builds from this fork instead of signalwire/freeswitch v1.11.3.

Known gaps

  • src/mod/languages/mod_managed/managed/swig.cs has not been regenerated, so SMBF_LAST is missing from the C# bindings.

Note

This was created with AI assistance.

@pragmatrix
pragmatrix merged commit 0741b63 into v1.11.3-qn Oct 19, 2026
6 checks passed
@pragmatrix
pragmatrix deleted the smbf-last branch October 19, 2026 16:43
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.

1 participant