Repository navigation
[mod_voicemail] Fix message length when recording at another sample rate - #3231
Open
andreinknv wants to merge 1 commit into
Open
andreinknv wants to merge 1 commit into
andreinknv wants to merge 1 commit into
Conversation
`create_file()` computed the message length, and with it the `min-record-len` check, as `fh.samples_out / fh.samplerate`. `samples_out` is counted in channel-rate samples, before the core resamples to the file rate (`fh.native_rate`), so whenever the file rate differs from the call's rate the length is divided by the rate ratio. With `record-sample-rate` set to 16000 an 8 kHz caller's 12 second message is stored as 6 seconds and a 5 second one is discarded as too short; at 48000 messages under 18 seconds are discarded. Divide by `fh.native_rate`, as `switch_ivr_record_file()` does for `record_seconds`, and fall back to the previous divisor when it is not set.
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.
Fixes #3229
create_file()computed the message length, and with it themin-record-lencheck, asfh.samples_out / fh.samplerate.samples_outcounts channel-rate samples, taken before the core resamples to the file rate. So whenrecord-sample-rate(or therecord_sample_ratechannel variable) differs from the call's rate, the length is divided by the rate ratio. An 8 kHz caller recorded at 16 kHz gets half the realmessage_len, and messages shorter than 6 s are discarded. At 48 kHz the length is a sixth, and messages shorter than 18 s are discarded.The fix divides by
fh.native_rate, the channel rate thatswitch_ivr_record_file()already uses forrecord_seconds. When that is not set it falls back to the previous divisor. Nothing changes when the file and call rates are the same.Prepared with the help of an AI coding assistant; the reproduction and results below were run locally.
Testing: FreeSWITCH master 12ac48a on Debian 13 arm64. An 8 kHz loopback leg plays a continuous 440 Hz tone into voicemail (greeting and instructions skipped) and hangs up.
min-record-lenis 3. Storedmessage_lencompared with the length of the recorded WAV:The module builds with the project flags (
-Wall -Werror -pedantic -std=c99). A build with-Wextrashows the same 41 warnings before and after the change.🤖 Generated with Claude Code