From ef16eaee367220d7ef57fd81a58ef11b13227a4a Mon Sep 17 00:00:00 2001
From: Sean Bright <sean@seanbright.com>
Date: Thu, 5 Jan 2023 11:41:37 -0500
Subject: [PATCH] app_playback.c: Fix PLAYBACKSTATUS regression.

In Asterisk 11, if a channel was redirected away during Playback(),
the PLAYBACKSTATUS variable would be set to SUCCESS. In Asterisk 12
(specifically commit 7d9871b3940fa50e85039aef6a8fb9870a7615b9) that
behavior was inadvertently changed and the same operation would result
in the PLAYBACKSTATUS variable being set to FAILED. The Asterisk 11
behavior has been restored.

Partial fix for ASTERISK~25661.

Change-Id: I53f54e56b59b61c99403a481b6cb8d88b5a559ff
---
 apps/app_playback.c                                 | 3 +--
 doc/UPGRADE-staging/app_playback_playbackstatus.txt | 8 ++++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
 create mode 100644 doc/UPGRADE-staging/app_playback_playbackstatus.txt

diff --git a/apps/app_playback.c b/apps/app_playback.c
index 56c2a86682..afa959be00 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -507,8 +507,7 @@ static int playback_exec(struct ast_channel *chan, const char *data)
 			if (!res) {
 				res = ast_waitstream(chan, "");
 				ast_stopstream(chan);
-			}
-			if (res) {
+			} else {
 				if (!ast_check_hangup(chan)) {
 					ast_log(LOG_WARNING, "Playback failed on %s for %s\n", ast_channel_name(chan), (char *)data);
 				}
diff --git a/doc/UPGRADE-staging/app_playback_playbackstatus.txt b/doc/UPGRADE-staging/app_playback_playbackstatus.txt
new file mode 100644
index 0000000000..49302b7966
--- /dev/null
+++ b/doc/UPGRADE-staging/app_playback_playbackstatus.txt
@@ -0,0 +1,8 @@
+Subject: app_playback
+
+In Asterisk 11, if a channel was redirected away during Playback(),
+the PLAYBACKSTATUS variable would be set to SUCCESS. In Asterisk 12
+(specifically commit 7d9871b3940fa50e85039aef6a8fb9870a7615b9) that
+behavior was inadvertently changed and the same operation would result
+in the PLAYBACKSTATUS variable being set to FAILED. The Asterisk 11
+behavior has been restored.
-- 
GitLab