#define LOG_TAG "AmlMpMultiThreadTest" #include "AmlMpTest.h" #include #include #include #include "TestUrlList.h" #include "../amlMpTestSupporter/TestModule.h" #include #include #include #include using namespace aml_mp; TEST_F(AmlMpTest, DVRMultiThreadStop) { std::string url; char recordPathInfo[100]; for (auto &url: mUrls) { sptr testDvrPlayer = nullptr; DVRRecordRecordStream(url); createMpTestSupporter(&testDvrPlayer); testDvrPlayer->setDataSource(AML_MP_RECORD_PATH); testDvrPlayer->prepare(CryptoMode); testDvrPlayer->startDVRPlayback(); AML_MP_DVRPLAYER dvrplayer = getDVRPlayer(testDvrPlayer); EXPECT_FALSE(waitPlaying(20* 1000ll)); std::mutex lock; std::condition_variable cond; bool beginStop = false; std::thread stopThread1([&, dvrplayer]() { { std::unique_lock _l(lock); cond.wait(_l, [&]{return beginStop;}); } MLOGI("thread call stop"); EXPECT_EQ(Aml_MP_DVRPlayer_Stop(dvrplayer), AML_MP_OK); }); { std::unique_lock _l(lock); beginStop = true; cond.notify_all(); } MLOGI("main call stop"); EXPECT_EQ(Aml_MP_DVRPlayer_Stop(dvrplayer), AML_MP_OK); stopThread1.join(); } }