diff --git a/media/server/gstplayer/source/GstGenericPlayer.cpp b/media/server/gstplayer/source/GstGenericPlayer.cpp index a075fa732..4df616b5f 100644 --- a/media/server/gstplayer/source/GstGenericPlayer.cpp +++ b/media/server/gstplayer/source/GstGenericPlayer.cpp @@ -270,6 +270,12 @@ void GstGenericPlayer::termPipeline() m_finishSourceSetupTimer.reset(); + if (m_playbackInfoTimer && m_playbackInfoTimer->isActive()) + { + m_playbackInfoTimer->cancel(); + } + m_playbackInfoTimer.reset(); + for (auto &elem : m_context.streamInfo) { StreamInfo &streamInfo = elem.second; diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp index 2c599dede..067f8c170 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/GstGenericPlayerPrivateTest.cpp @@ -1629,6 +1629,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldStartPositionReportingTimer) .WillOnce(Return(ByMove(std::move(audioUnderflowTimerMock)))); willNotifyPlaybackInfo(); std::unique_ptr playbackInfoTimerMock = std::make_unique>(); + EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillRepeatedly(Return(false)); EXPECT_CALL(*m_timerFactoryMock, createTimer(kPlaybackInfoTimerMs, _, common::TimerType::PERIODIC)) .WillOnce(Return(ByMove(std::move(playbackInfoTimerMock)))); @@ -1643,6 +1644,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldNotStartPositionReportingTimerWhenItIs .WillOnce(Return(ByMove(std::move(timerMock)))); willNotifyPlaybackInfo(); std::unique_ptr playbackInfoTimerMock = std::make_unique>(); + EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillRepeatedly(Return(false)); EXPECT_CALL(*m_timerFactoryMock, createTimer(kPlaybackInfoTimerMs, _, common::TimerType::PERIODIC)) .WillOnce(Return(ByMove(std::move(playbackInfoTimerMock)))); m_sut->startPositionReportingAndCheckAudioUnderflowTimer(); @@ -1667,6 +1669,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldScheduleReportPositionWhenPositionRepo })); willNotifyPlaybackInfo(); std::unique_ptr playbackInfoTimerMock = std::make_unique>(); + EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillRepeatedly(Return(false)); EXPECT_CALL(*m_timerFactoryMock, createTimer(kPlaybackInfoTimerMs, _, common::TimerType::PERIODIC)) .WillOnce(Invoke( [&](const std::chrono::milliseconds &timeout, const std::function &callback, common::TimerType timerType) @@ -1687,7 +1690,9 @@ TEST_F(GstGenericPlayerPrivateTest, shouldStopActivePositionReportingTimer) .WillOnce(Return(ByMove(std::move(timerMock)))); willNotifyPlaybackInfo(); std::unique_ptr playbackInfoTimerMock = std::make_unique>(); - EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillOnce(Return(true)); + EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()) + .WillOnce(Return(true)) + .WillRepeatedly(Return(false)); EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), cancel()); EXPECT_CALL(*m_timerFactoryMock, createTimer(kPlaybackInfoTimerMs, _, common::TimerType::PERIODIC)) .WillOnce(Return(ByMove(std::move(playbackInfoTimerMock)))); @@ -1703,7 +1708,7 @@ TEST_F(GstGenericPlayerPrivateTest, shouldNotStopInactivePositionReportingTimer) .WillOnce(Return(ByMove(std::move(timerMock)))); willNotifyPlaybackInfo(); std::unique_ptr playbackInfoTimerMock = std::make_unique>(); - EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillOnce(Return(false)); + EXPECT_CALL(dynamic_cast &>(*playbackInfoTimerMock), isActive()).WillRepeatedly(Return(false)); EXPECT_CALL(*m_timerFactoryMock, createTimer(kPlaybackInfoTimerMs, _, common::TimerType::PERIODIC)) .WillOnce(Return(ByMove(std::move(playbackInfoTimerMock)))); m_sut->startPositionReportingAndCheckAudioUnderflowTimer(); diff --git a/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.cpp b/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.cpp index 3920d589a..d978c7d2e 100644 --- a/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.cpp +++ b/tests/unittests/media/server/gstplayer/genericPlayer/common/GstGenericPlayerTestCommon.cpp @@ -25,6 +25,7 @@ #include using ::testing::_; +using ::testing::AnyNumber; using ::testing::ByMove; using ::testing::Invoke; using ::testing::Return; @@ -54,6 +55,7 @@ void GstGenericPlayerTestCommon::gstPlayerWillBeDestroyed() { expectShutdown(); expectStop(); + EXPECT_CALL(*m_timerFactoryMock, createTimer(_, _, _)).Times(AnyNumber()); EXPECT_CALL(*m_gstWrapperMock, gstPipelineGetBus(GST_PIPELINE(&m_pipeline))).WillOnce(Return(&m_bus)); EXPECT_CALL(*m_gstWrapperMock, gstBusSetSyncHandler(&m_bus, nullptr, nullptr, nullptr)); EXPECT_CALL(*m_gstWrapperMock, gstObjectUnref(&m_bus));