From 34d833a1ed7f3a0d89098c6159806cfb9ed25a10 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 10 Nov 2021 10:49:42 +0800 Subject: [PATCH] =?UTF-8?q?Player:=20=E6=92=AD=E6=94=BE=E5=99=A8=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=90=8C=E6=AD=A5=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- player/FFMpegDecoder.cpp | 4 ++-- player/FFMpegDecoder.h | 4 ++-- player/test_player.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/player/FFMpegDecoder.cpp b/player/FFMpegDecoder.cpp index 836bbc5a..d132a060 100644 --- a/player/FFMpegDecoder.cpp +++ b/player/FFMpegDecoder.cpp @@ -263,8 +263,8 @@ bool FFmpegDecoder::inputFrame_l(const Frame::Ptr &frame) { return decodeFrame(frame->data(), frame->size(), frame->dts(), frame->pts()); } -bool FFmpegDecoder::inputFrame(const Frame::Ptr &frame) { - if (!TaskManager::isEnabled()) { +bool FFmpegDecoder::inputFrame(const Frame::Ptr &frame, bool may_async) { + if (!may_async || !TaskManager::isEnabled()) { return inputFrame_l(frame); } auto frame_cache = Frame::getCacheAbleFrame(frame); diff --git a/player/FFMpegDecoder.h b/player/FFMpegDecoder.h index a1073fd1..dba0b2e6 100644 --- a/player/FFMpegDecoder.h +++ b/player/FFMpegDecoder.h @@ -87,7 +87,7 @@ private: std::shared_ptr _thread; }; -class FFmpegDecoder : public FrameWriterInterface, private TaskManager { +class FFmpegDecoder : private TaskManager { public: using Ptr = std::shared_ptr; using onDec = function; @@ -95,7 +95,7 @@ public: FFmpegDecoder(const Track::Ptr &track); ~FFmpegDecoder(); - bool inputFrame(const Frame::Ptr &frame) override; + bool inputFrame(const Frame::Ptr &frame, bool may_async = true); void setOnDecode(onDec cb); void flush(); const AVCodecContext *getContext() const; diff --git a/player/test_player.cpp b/player/test_player.cpp index 7619db22..995070c1 100644 --- a/player/test_player.cpp +++ b/player/test_player.cpp @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) { }); }); auto delegate = std::make_shared([decoder](const Frame::Ptr &frame) { - return decoder->inputFrame(frame); + return decoder->inputFrame(frame, false); }); videoTrack->addDelegate(delegate); } @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) { audio_player->playPCM((const char *) (pcm->get()->data[0]), len); }); auto audio_delegate = std::make_shared( [decoder](const Frame::Ptr &frame) { - return decoder->inputFrame(frame); + return decoder->inputFrame(frame, false); }); audioTrack->addDelegate(audio_delegate); }