From 8961ca1659f52b0f8d03dd49a804f254c821143f Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 30 Aug 2020 17:03:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E6=97=A0?= =?UTF-8?q?=E9=99=90=E9=80=92=E5=BD=92=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/FFmpegSource.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/FFmpegSource.cpp b/server/FFmpegSource.cpp index d0bddeb3..53b481bc 100644 --- a/server/FFmpegSource.cpp +++ b/server/FFmpegSource.cpp @@ -270,8 +270,18 @@ void FFmpegSource::onRegist(MediaSource &sender, bool regist){ } void FFmpegSource::onGetMediaSource(const MediaSource::Ptr &src) { - _listener = src->getListener(); - src->setListener(shared_from_this()); + auto listener = src->getListener(); + if (listener.lock().get() != this) { + //防止多次进入onGetMediaSource函数导致无效递归调用的bug + src->setListener(shared_from_this()); + _listener = listener; + } else { + WarnL << "多次触发onGetMediaSource事件:" + << src->getSchema() << "/" + << src->getVhost() << "/" + << src->getApp() << "/" + << src->getId(); + } } void FFmpegSnap::makeSnap(const string &play_url, const string &save_path, float timeout_sec, const function &cb) {