Pārlūkot izejas kodu

Z991239-2055 #comment fix: 解决在广告策略对应的广告文件缺失情况下消耗系统资源异常问题

陈礼鹏80274480 4 gadi atpakaļ
vecāks
revīzija
78306438d4

+ 7 - 2
Module/mod_localmediaplay/AdvertManage/MediaManage.cpp

@@ -151,7 +151,7 @@ size_t mediaManage::GetPlayListByLocal(rvcResourceParse_t* ResourceArr, size_t u
 		if (false == bloged){
 			Dbg("new deep copy play extend %c:%s, %s, %s, %s", it->type, it->resourcePath.c_str(), it->videoNames.c_str(), it->vaildTime.c_str(), it->playTime.c_str());
 		}
-		if (checkInVaildTime(it->vaildTime, true) && checkInPlayTime(it->playTime, true)) {
+		if (checkInVaildTime(it->vaildTime, true) && checkInPlayTime(it->playTime, true) && IsResourceExist(it->resourcePath, it->videoNames)) {
 			rvcResourceParse_t* pNode = ResourceArr+uNum;
 			pNode->type = it->type;
 			pNode->fullScreen = it->fullScreen;
@@ -343,7 +343,7 @@ void mediaManage::InitResourceListByLocal()
 		m_localList.push_back(*it);
 		unetworkList++;
 	}
-	//Dbg("headList size is %d, branchList size is %d, networkList size is %d, and m_localList size is %u.", uheadList, ubranchList, unetworkList, m_localList.size());
+	Dbg("headList size is %d, branchList size is %d, networkList size is %d, and m_localList size is %u.", uheadList, ubranchList, unetworkList, m_localList.size());
 
 #endif // RVC_OS_WIN
 	
@@ -410,6 +410,11 @@ bool mediaManage::findVaildConfig(string dirPath, string &configPath)
 		return false;
 }
 
+bool mediaManage::IsResourceExist(string strPath, string strName)
+{
+	return checkFileExist(strPath + strName);
+}
+
 void mediaManage::clearOutdataResource()
 {
 	vector<string> dirInfo, needDelete(10);

+ 1 - 0
Module/mod_localmediaplay/AdvertManage/mediaManage.h

@@ -34,6 +34,7 @@ private:
 	bool AddResourceList(vector<string> resourceList);
 	void DeleteResourceList(vector<string> resourceList);
 	bool findVaildConfig(string dirPath, string &configPath);
+	bool IsResourceExist(string strPath, string strName);
 	string m_addvertPath, m_downloadPath;
 	vector<ParseInfo> m_curParse;
 	vector<ResourceParse> m_localList;

+ 15 - 24
Module/mod_localmediaplay/mod_localmediaplay.cpp

@@ -826,19 +826,8 @@ void* StartMediaPlayFunc(void* param)
 	{
 		rvcResourceParse_t ResourceList[MAX_LOCAL_MEDIAS] = { 0 };
 		size_t uCount = entity->m_mediaManage.GetPlayListByLocal(ResourceList, MAX_LOCAL_MEDIAS);
-		//Dbg("uCount == %d", uCount);
-		//for (int i = 0; i < uCount; i++)
-		//{
-		//	rvcResourceParse_t item = ResourceList[i];
-		//	Dbg("%s:%d    ResourceList[%d] address is 0x%0x.", __FUNCTION__, __LINE__, i, ResourceList[i]);
-		//	Dbg("item->type address is 0x%0x.", item.type);
-		//	Dbg("item->presourcePath address is 0x%0x.", item.strResourcePath);
-		//	Dbg("item->pvideoNames address is 0x%0x.", item.strvideoNames);
-		//	Dbg("play extend %c:%s, %s", item.type, item.strResourcePath, item.strvideoNames);
-		//}
-
-		if (0 == uCount)
-		{
+
+		if (0 == uCount){
 			int64_t playThreadId  = 0;
 			CMediaPlayConfig config = {0};
 			memcpy(&config, &(entity->m_Videos[entity->m_mediaParam.nCfgInx]), sizeof(CMediaPlayConfig));
@@ -848,29 +837,28 @@ void* StartMediaPlayFunc(void* param)
 			config.nWndY = entity->m_mediaParam.nWndY;
 			config.nWndWidth = entity->m_mediaParam.nWndWidth;
 			config.nWndHeight = entity->m_mediaParam.nWndHeight;
-			if (IS_DEBUG)
-			{
+			if (IS_DEBUG){
 				config.bFullScreen = false;
 				config.bPrimMonitor = true;
 			}
 
-			if (!entity->GetLocalVideoVolume(0, config.nVolume))
-			{
+			if (!entity->GetLocalVideoVolume(0, config.nVolume)){
 				config.nVolume = entity->m_defaultVolum;
 			}
-			//Dbg("config.nVolume=%d while play local video.", config.nVolume);
 
 			struct tm* ptm = NULL;
 			time_t t = time(NULL);
 			ptm = localtime(&t);
 			TCHAR strNow[TIME_LEN] = {0};
 			sprintf(strNow, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
-			if (strcmp(strNow, config.strVideoRunTime_S) < 0 || strcmp(strNow, config.strVideoRunTime_E) >= 0)
-			{
+			if (strcmp(strNow, config.strVideoRunTime_S) < 0 || strcmp(strNow, config.strVideoRunTime_E) >= 0){
 				Sleep(10000);
 				continue;
 			}
-			entity->m_pMediaPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config);
+
+			if (-1 == entity->m_pMediaPlayer[entity->m_mediaParam.nCfgInx]->PlayMedia(config)){
+				Sleep(60000);
+			}
 		}
 
 		for (int i = 0; i < uCount && i < MAX_LOCAL_MEDIAS && entity->GetPlayFlag(); i++)
@@ -1011,9 +999,12 @@ void CLocalMediaPlayEntity::StartAudio(const char *pAudioNames)
 #else
 
 	if (m_pMediaAudioPlayer->checkIsPlay()) {
-		Dbg("aurrent is playing, wait for it.");
-		//m_pMediaAudioPlayer->Close();
-		pthread_join(m_uMediaPlayThreadId, NULL);
+		Dbg("current is playing, close it.");
+		if (0 != m_uMediaPlayThreadId){
+			m_pMediaAudioPlayer->Close();
+			m_uMediaPlayThreadId = 0;
+			Sleep(800);
+		}
 	}
 
 	m_lastPlayAudio = pAudioNames;

+ 3 - 2
Other/libmediaplayer/libmediaplayer.cpp

@@ -314,6 +314,7 @@ public:
 		else {
 			m_pHostApi->Debug(MEDIA_LOG_DEBUG,"File %s is not exist.", strFileName);
 			t_param.uFilesCount = 0;
+			return iRet;
 		}
 		
 		m_pHostApi->Debug(MEDIA_LOG_DEBUG,"pParam uFilesCount = %d", t_param.uFilesCount);
@@ -432,9 +433,9 @@ bool Clibmediaplayer::checkIsStop()
 	return m_pImpl->isStop();
 }
 
-void Clibmediaplayer::PlayMedia(CMediaPlayConfig& config)
+int Clibmediaplayer::PlayMedia(CMediaPlayConfig& config)
 {
-	m_pImpl->StartPlayMedia(config);
+	return m_pImpl->StartPlayMedia(config);
 }
 
 void Clibmediaplayer::Close()

+ 1 - 1
Other/libmediaplayer/libmediaplayer.h

@@ -35,7 +35,7 @@ public:
 
 	bool checkIsStop();
 
-	void PlayMedia(CMediaPlayConfig& config);
+	int PlayMedia(CMediaPlayConfig& config);
 
 	void SetVolume(int nVolume);
 

+ 1 - 1
Other/libmediaplayer/player.cpp

@@ -280,7 +280,7 @@ int CMediaPlayer::Initialize_Player_Stat(rvc_media_player_param_t* pMedia_Player
 		memcpy(m_player_stat->strPlayLists[i], pMedia_Player->strPlayLists[i], strlen(pMedia_Player->strPlayLists[i]));
 	}
 	if (0 == pMedia_Player->uFilesCount || NULL == m_player_stat->rvc_hostapi || NULL == m_player_stat->prvc_cb || NULL == m_player_stat->piconpath) {
-		player_deinit(m_player_stat);
+		av_free(m_player_stat);
 		m_player_stat = NULL;
 		return iRet;
 	}