]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_record: Fix hangup handling during beep playback
authorUpBeta <1.51861782e+08+UpBeta@users.noreply.github.com>
Sat, 23 May 2026 21:00:53 +0000 (21:00 +0000)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Mon, 1 Jun 2026 16:40:33 +0000 (16:40 +0000)
When a hangup occurs while app_record is playing the initial beep,
the application does not detect the hangup and continues running
until the maxduration timeout expires.

Replace the manual ast_streamfile() + ast_waitstream() sequence with
ast_stream_and_wait(), which properly detects hangup and returns
non-zero, allowing the application to exit immediately with
RECORD_STATUS set to HANGUP.

Resolves: #1950

apps/app_record.c

index 5dc362ca48283a3a1db368d70930e32e46d8b4af..7004fd9f8b07d789e768c22260e8e4ed336dc0fb 100644 (file)
@@ -457,15 +457,11 @@ static int record_exec(struct ast_channel *chan, const char *data)
        }
 
        if (!ast_test_flag(&flags, OPTION_QUIET)) {
-               /* Some code to play a nice little beep to signify the start of the record operation */
-               res = ast_streamfile(chan, "beep", ast_channel_language(chan));
-               if (!res) {
-                       res = ast_waitstream(chan, "");
-               } else {
-                       ast_log(LOG_WARNING, "ast_streamfile(beep) failed on %s\n", ast_channel_name(chan));
-                       res = 0;
+               /* Play a beep to signify the start of the record operation */
+               if (ast_stream_and_wait(chan, "beep", "")) {
+                       status_response = "HANGUP";
+                       goto out;
                }
-               ast_stopstream(chan);
        }
 
        /* The end of beep code.  Now the recording starts */