From 7a83ce891a7ad508bb71b587bf306de2ced9a706 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Thu, 21 May 2026 16:22:40 +0200 Subject: [PATCH] MT#62750 media_player: skip MP init if there is ongoing MoH Both the play media and the music on hold use the `media_player::call_play_media_for_ml()` as an entrance towards the `media_player::media_player_new()` and `media_player::media_player_play_init()`. Prevent allocation of new MoH over ongoing one, as well as the `play media` command over ongoing MoH. Otherwise a media player will be re-used to override ongoing activity. Explicit policy must be used: First the MoH has to be stopped by getting back to the SDP `sendrecv` state, before any other MoH request, or play media request can be fulfilled. Change-Id: Ia5fdc10cfa8f491109ade9a2225b182ccdaa4778 --- daemon/media_player.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/daemon/media_player.c b/daemon/media_player.c index 4f383d979..8210bc5bd 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1706,9 +1706,17 @@ const char * call_play_media_for_ml(struct call_monologue *ml, /* this starts the audio player if needed */ update_init_monologue_subscribers(ml, OP_PLAY_MEDIA); - /* media_player_new() now knows that audio player is in use - * TODO: player options can have changed if already exists */ - media_player_new(&ml->player, ml, NULL, &opts); + + if (ml->player && ml->player->opts.moh) { + ilog(LOG_DEBUG, "There is already ongoing media playback for MoH. Ignore new one."); + /* pretend that everything is good */ + return NULL; + } + else { + /* media_player_new() now knows that audio player is in use + * TODO: player options can have changed if already exists */ + media_player_new(&ml->player, ml, NULL, &opts); + } if (opts.file.len) { if (!media_player_play_file(ml->player, opts))