GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { case GF_TERM_EXT_INTERFACE: osd_delete(ifce); break; } }
/***************************************************************************** Prototype : vid_enc_thr Description : image encode thread Input : void *arg Output : None Return Value : void Calls : Called By : History : 1.Date : 2012/3/8 Author : Sun Modification : Created function *****************************************************************************/ void *vid_enc_thr(void *arg) { VidEncThrEnv env; CommonMsg msgBuf; Int32 ret; Int32 fdMsg, fdMax; fd_set rdSet; ret = vid_enc_thr_init((VidEncThrArg *)arg, (VidEncThrEnv *)&env); assert(ret == E_NO); if(ret) goto exit; fdMsg = msg_get_fd(env.hMsg); fdMax = fdMsg + 1; /* start main loop */ while(!env.exit) { /* wait data ready */ FD_ZERO(&rdSet); FD_SET(fdMsg, &rdSet); ret = select(fdMax, &rdSet, NULL, NULL, NULL); if(ret < 0 && errno != EINTR) { ERRSTR("select err"); break; } /* no data ready */ if(!ret) continue; if(FD_ISSET(fdMsg, &rdSet)) { /* process msg */ msg_process(&env, &msgBuf); } } exit: if(env.hH264Enc) h264_enc_delete(env.hH264Enc); if(env.hOsd) osd_delete(env.hOsd); if(env.hBufEnc) buffer_free(env.hBufEnc); if(env.hMsg) msg_delete(env.hMsg); INFO("vid encode thread exit..."); pthread_exit(0); }
/***************************************************************************** Prototype : encoder_delete Description : delete encoder module Input : EncoderHandle hEnc Output : None Return Value : Calls : Called By : History : 1.Date : 2012/3/17 Author : Sun Modification : Created function *****************************************************************************/ Int32 encoder_delete(EncoderHandle hEnc, MsgHandle hCurMsg) { if(!hEnc) return E_INVAL; /* ask thread to exit */ if(hEnc->pid > 0) { if(hCurMsg) { MsgHeader msg; /* send msg to our thread to exit */ msg.cmd = APPCMD_EXIT; msg.index = 0; msg.dataLen = 0; msg.type = MSG_TYPE_REQU; msg_send(hCurMsg, msg_get_name(hEnc->hMsg), &msg, 0); } /* set flag to exit */ hEnc->exit = TRUE; pthread_join(hEnc->pid, NULL); } /* delete modules used */ if(hEnc->hEncode) alg_delete(hEnc->hEncode); if(hEnc->hBufEnc) buffer_free(hEnc->hBufEnc); if(hEnc->hOsd) osd_delete(hEnc->hOsd); if(hEnc->hPoolEnc) buf_pool_delete(hEnc->hPoolEnc); if(hEnc->hMsg) msg_delete(hEnc->hMsg); if(hEnc->hPoolIn) buf_pool_free_all(hEnc->hPoolIn); free(hEnc); return E_NO; }