From e7b9897ddd5b9c4ae840299ce124a9800e957d13 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Thu, 11 Jun 2026 17:37:43 +0200 Subject: [PATCH] MT#61856 media_player: check if frame seek failed Before to start the media player, check if the seek process for the start frame failed, because otherwise it starts from the unexpected position, and there is no awareness about it. Just add log for this case. Change-Id: I36a912a9ef044825b050f8b7a6ad5562571b7d34 --- daemon/media_player.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/media_player.c b/daemon/media_player.c index 2d4d5ad26..2085e05c9 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1255,6 +1255,8 @@ static const rtp_payload_type *media_player_play_init(struct media_player *mp) { static bool media_player_play_start(struct media_player *mp, const rtp_payload_type *dst_pt, str_case_value_ht codec_set) { + int ret = 0; + // needed to have usable duration for some formats. ignore errors. if (!mp->coder.fmtctx->streams || !mp->coder.fmtctx->streams[0]) avformat_find_stream_info(mp->coder.fmtctx, NULL); @@ -1280,10 +1282,14 @@ static bool media_player_play_start(struct media_player *mp, const rtp_payload_t // if start_pos is positive, try to seek to that position if (mp->opts.start_pos > 0) { ilog(LOG_DEBUG, "Seeking to position %lli", mp->opts.start_pos); - av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + ret = av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); } else // in case this is a repeated start - av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + ret = av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD); + + if (ret < 0) + ilog(LOG_ERR, "Failed to seek to beginning of media file"); + // should we return false at this point? media_player_read_packet(mp);