⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pthread_manager.c

📁 1、基于韩国at2041芯片开发的Linux环境的DVR代码。 2、以原来代码进行了修改。 3、主要修改网络通讯出现异常问题处理 4、硬盘覆盖录像不起作用
💻 C
字号:
/* set tabstop=4 *//******************************************************************************** *                                                                              * * Copyright(C) 2004  Penta-Micro                                               * *                                                                              * * ALL RIGHT RESERVED                                                           * *                                                                              * * This software is the property of Penta-Micro and is furnished under          * * license by Penta-Micro. This software may be used only in accordance         *	 * with the terms of said license. This copyright notice may not be             * * removed, modified or obliterated without the prior written permission        * * of Penta-Micro.                                                              * *                                                                              * * This software may not be copyed, transmitted, provided to or otherwise       * * made available to any other person, company, corporation	or other entity     * * except as specified in the terms of said license.                            * *                                                                              * * No right, title, ownership or other interest in the software is hereby       * * granted or transferred.                                                      * *                                                                              * * The information contained herein is subject to change without notice and     * * should not be construed as a commitment by Penta-Micro.                      * *                                                                              * ********************************************************************************   MODULE NAME:  PTHREAD_MANAGER.C    REVISION HISTORY:    Date       Ver Name                  Description  ---------- --- --------------------- -----------------------------------------  06/28/2004 2.0 CheulBeck(whitefe)       Created     07/20/2005 2.1 JiGwanKang(xchannel)  Modified  ...............................................................................   DESCRIPTION:    This Module contains functions for Thread Managing.   ...............................................................................*/   /** ************************************************************************* **  ** includes ** ************************************************************************* **/#include <stdio.h>#include "main.h"/** ************************************************************************* **  ** defines ** ************************************************************************* **/#define m_DEBUG(format, args...)  printf(format, ## args);//#define m_DEBUG(format, args...)  #define m_MSG(format, args...)	printf(format, ## args);#define m_ERROR(format, args...)  printf(format, ## args);/** ************************************************************************* **  ** typedefs ** ************************************************************************* **/	 /** ************************************************************************* **  ** globals ** ************************************************************************* **/extern PTHREAD_STATE	*gp_state_thread;  /** ************************************************************************* **  ** locals ** ************************************************************************* **//** ************************************************************************* **  ** forward declarations ** ************************************************************************* **/void *pthread_manager(void *args){	PTHREAD_ID		start_id = 0;	PTHREAD_BUF		signal;	m_DEBUG("\t!!! pthread MANAGER  !!!\n");	while (1) {		/* waiting signal from input thread */		pthread_read_signal(&signal, PTHREAD_MANAGER, TRUE); 		m_MSG("\tsignal> [manager][id:%02d][value:0x%04x]\n", signal.start_id, signal.m_value);		switch (signal.start_id) {			case PTHREAD_MAIN :				switch (signal.m_value) {					case REC :						if (!gp_state_thread->state_enc.manual_rec) {							if (gp_state_thread->state_enc.state == IDLE) {								/* when the not overwrite and disk fulled */    								if(gp_state_thread->state_diskm.state == FULL) {								    	m_MSG("\n\t!!!!  All Disk Fulled !!!!");								    	m_MSG("\n\t!!! MPEG4 Encoding Stop !!!\n");								    	break;								}								/* start Manual ENC */								gp_state_thread->state_enc.state = ALIVE;																					if (pthread_create_enc() == FALSE) {									m_ERROR("main.c:error: In function 'pthread_create_setup'\n");								} 														}							gp_state_thread->state_enc.manual_rec = 1;							/* display REC osd */							signal.start_id = PTHREAD_MANAGER;							signal.m_signal = SIGNAL_0;							if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {								m_ERROR("main.c:error: In function 'pthread_send_signal'\n");							}																	} else {							if (!gp_state_thread->state_enc.schedule_rec) {								gp_state_thread->state_enc.manual_rec = 0;								/* clear REC osd */								signal.start_id = PTHREAD_MANAGER;								signal.m_signal = SIGNAL_1;								if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {									m_ERROR("main.c:error: In function 'pthread_send_signal'\n");								}								/* stop Manual ENC */								gp_state_thread->state_enc.state = IDLE;							} else {								gp_state_thread->state_enc.manual_rec = 0;																/* display REC osd */								signal.start_id = PTHREAD_MANAGER;								signal.m_signal = SIGNAL_0;								if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {									m_ERROR("main.c:error: In function 'pthread_send_signal'\n");								}							}						}												break;					default :						break;				}				break;			case PTHREAD_SCHEDULE :				switch (signal.m_signal) {					case SIGNAL_0 :						/* display REC osd */						signal.start_id = PTHREAD_MANAGER;						signal.m_signal = SIGNAL_0;						if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {							m_ERROR("main.c:error: In function 'pthread_send_signal'\n");						}													if (gp_state_thread->state_enc.state == IDLE) {										/* start Schedule ENC */														gp_state_thread->state_enc.state = ALIVE;												if (pthread_create_enc() == FALSE) {								m_ERROR("main.c:error: In function 'pthread_create_setup'\n");							} 													} 						break;					case SIGNAL_1 :						if (gp_state_thread->state_enc.state != IDLE) {	// REC state							if (!gp_state_thread->state_enc.manual_rec) {	// No Manual REC state								if (!gp_state_thread->state_enc.schedule_rec) {	// No Schedule REC state									/* clear REC osd */									signal.start_id = PTHREAD_MANAGER;									signal.m_signal = SIGNAL_1;									if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {										m_ERROR("main.c:error: In function 'pthread_send_signal'\n");									}									/* stop Schedule ENC */																	gp_state_thread->state_enc.state = IDLE;								} else {									/* clear REC osd to the channel */									signal.start_id = PTHREAD_MANAGER;									signal.m_signal = SIGNAL_0;									if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {										m_ERROR("main.c:error: In function 'pthread_send_signal'\n");									}								}							}						}						break;					default :						break;				}				break;							case PTHREAD_SEARCH :				if (gp_state_thread->state_dec.state == IDLE) {					gp_state_thread->state_dec.state = ALIVE;					if (pthread_create_dec() == FALSE) {						m_ERROR("main.c:error: In function 'pthread_create_setup'\n");					} 									}				break;			default :				break;		}		 	} /* end of while (!QUIT_SDVR_MAIN) */	return 0;}/* end of pthread_manager.c */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -