Browse Source

Z991239-1812 #comment other 优化呼叫挂断资源释放流程

陈礼鹏80274480 4 năm trước cách đây
mục cha
commit
2ccf948b40

+ 1 - 1
Module/mod_mediacontroller/capture.cpp

@@ -1731,7 +1731,7 @@ namespace MediaController {
 		{
 			int inumber = 0;
 			int icount = rvc_videocap_get_device_count();
-			for (int i = 0; i < 2 * icount; ++i) {
+			for (int i = 0; i < 64 && inumber < icount; ++i) {
 				char strcamera[2 * MAX_PATH] = { 0 };
 				char strpath[MAX_PATH] = { 0 };
 

+ 13 - 8
Other/libaudioframework/audiomicspklinux.c

@@ -170,27 +170,30 @@ static audiostream_vtbl_t g_stream_vtbl = {
 void audiomicspklinux_destroy(audiomicspklinux_t* micspk)
 {
 	sem_post(micspk->audio_device_started_sem);
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
+
 	if (micspk->ply_stream) {
 		Pa_AbortStream(micspk->ply_stream);
 		Pa_CloseStream(micspk->ply_stream);
 	}
 
-	if (micspk->rec_stream) {
-		Pa_AbortStream(micspk->rec_stream);
-		Pa_CloseStream(micspk->rec_stream);
+	if (false == micspk->baudio_from_shm_flag){
+		if (micspk->rec_stream) {
+			Pa_AbortStream(micspk->rec_stream);
+			Pa_CloseStream(micspk->rec_stream);
+		}
 	}
 
 	if (micspk->ply_dbuf)
 		delay_buf_destroy((delay_buf*)micspk->ply_dbuf);
+	
 	if (micspk->rec_dbuf)
 		delay_buf_destroy((delay_buf*)micspk->rec_dbuf);
+	
 	if (micspk->opt & AMS_OPT_AS_ENGINE) {
 		//DeleteCriticalSection(&micspk->engine_lock);
 	}
 	sem_destroy(micspk->audio_device_started_sem);
 
-	audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d", __FUNCTION__, __LINE__);
 	//fclose(micspk->pcmfile);
 	//fclose(micspk->putpcmfile);
 	//fclose(micspk->highhzpcmFile);
@@ -317,9 +320,11 @@ static void uninitialize_speaker(audiomicspklinux_t* micspk)
 
 static void uninitialize_micro(audiomicspklinux_t* micspk)
 {
-	if (micspk->rec_stream) {
-		Pa_AbortStream(micspk->rec_stream);
-		Pa_CloseStream(micspk->rec_stream);
+	if (false == micspk->baudio_device_started_flag){
+		if (micspk->rec_stream) {
+			Pa_AbortStream(micspk->rec_stream);
+			Pa_CloseStream(micspk->rec_stream);
+		}
 	}
 
 	if (micspk->rec_dbuf) {

+ 4 - 3
Other/libmediadeviceinfo/libvideodeviceinfo.cpp

@@ -280,11 +280,12 @@ int  rvc_videocap_get_video_device_id(const char* dev_name)
 		return iret;
 	}
 
-	int n = rvc_videocap_get_device_count();
-	printf("device count is %d.\n", n);
-	for (int i = 0; i < 2*n; ++i) {
+	int icount = rvc_videocap_get_device_count();
+	int ifound = 0;
+	for (int i = 0; i < 64 && ifound < icount; ++i) {
 		char strfullname[2*MAX_PATH] = { 0 };
 		if (0 == rvc_videocap_get_device_fullpathname(i, strfullname, 2 * MAX_PATH)){
+			ifound++;
 			printf("camera name is: %s\n", strfullname);
 			printf("   dev name is: %s\n", dev_name);
 			if (0 == strcasecmp(strfullname, dev_name))

+ 7 - 3
Other/libvideoframework/videortp.c

@@ -1145,7 +1145,7 @@ void* recv_proc(void* arg)
 	int rtp_timeout_cnt = 0;
 	int64_t pre_500_ms = TimeInMilliseconds();
 
-	rtpDbg(vrtp,"recv_proc.");
+	rtpDbg(vrtp,"enter recv_proc.");
 #ifdef _WIN32
 	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
 #else
@@ -1169,7 +1169,7 @@ void* recv_proc(void* arg)
 		ts.tv_nsec = (unsec % 1000000000);
 		//sem_getvalue(&vrtp->sem_evt, &ivalue);
 		//rtpDbg(vrtp,"%s:%d sem value is %d", __FUNCTION__, __LINE__, ivalue);
-		if (0 != sem_timedwait(&vrtp->sem_evt, &ts) /*&& (ETIMEDOUT == errno)*/)
+		if (0 != sem_timedwait(&vrtp->sem_evt, &ts) && (ETIMEDOUT == errno))
 #endif
 		{
 			int n;
@@ -1282,7 +1282,7 @@ void* recv_proc(void* arg)
 			break;
 		}
 	}
-
+	rtpDbg(vrtp, "exit recv_proc.");
 	return 0;
 }
 
@@ -2105,7 +2105,9 @@ int videortp_create(const videortp_config_t *config, videortp_t **p_rtp)
 		vrtp->framenum = 0;
 	}
 
+#ifdef _WIN32
 	congestion_control_create(vrtp, config);
+#endif
 	{
 		h264_packetizer_cfg cfg;
 		cfg.mtu = get_mtu(config->mtu);
@@ -2140,7 +2142,9 @@ void videortp_destroy(videortp_t *vrtp)
 		free(part);
 	}
 
+#ifdef _WIN32
 	congestion_control_destroy(vrtp);
+#endif
 	video_stats_uninit();
 	jitter_buffer_destory(vrtp);
 	rtp_header_extension_api_destroy(vrtp->rtp_header_extension);

+ 1 - 1
Other/showdev/main.cpp

@@ -291,7 +291,7 @@ static void show_video_dev()
 	printf("video devices(%d):\n", icount);
 
 	int inumber = 0;
-	for (int i = 0; i < 2 * icount; ++i) {
+	for (int i = 0; i < 64 && inumber < icount; ++i) {
 		char strcamera[2*MAX_PATH] = { 0 };
 		char strpath[MAX_PATH] = { 0 };