#define CYCTIME 2000
#define RESTORE_BUFFSIZE 4096
ULONG inbuffersize = RESTORE_BUFFSIZE;
BYTE1 *inbufferptr[CYCTIME];
BYTE1 *outbufferptr[CYCTIME/5];
void GetThread(void *param)
{
CFlyDemoDlg *pVideo = (CFlyDemoDlg *)param;
UINT GetNum = 0;
UINT tempres = 0;
UINT i = 0; for(i = 0; i < CYCTIME;i++)
{
inbufferptr[i] = (BYTE *)malloc(RESTORE_BUFFSIZE);
memset(inbufferptr[i],0,RESTORE_BUFFSIZE);
}
while (pVideo->m_RunMode==RUNMODE_PLAY)
{
tempres = GetNum % CYCTIME;
pVideo->m_pCFlyUSB->bGetUSBData(inbufferptr[tempres],inbuffersize); // CString ss;
// ss.Format("%d",inbufferptr[1][11]);
// AfxMessageBox(ss);
GetNum++;
}
SetEvent(pVideo->m_hGetUSBThreadEventDead);
_endthread();
//clear the state flag
}void DecThread(void *param)
{
CFlyDemoDlg *pVideo = (CFlyDemoDlg *)param;
UINT GetNum = 0;
UINT tempres = 0;
UINT i = 0;
int outbuffersize = (pVideo->CurrentSensor.width) * (pVideo->CurrentSensor.height) *(pVideo->CurrentSensor.type);
for(i = 0; i < CYCTIME/2;i++)
{
outbufferptr[i] = (BYTE *)malloc(outbuffersize);
memset(outbufferptr[i],0,outbuffersize);
}
while (pVideo->m_RunMode==RUNMODE_PLAY)
{
tempres = GetNum % CYCTIME;
if(inbufferptr[tempres] == NULL)
{
WaitForSingleObject(pVideo->m_hGetUSBThreadEventDead, INFINITE);
CloseHandle(pVideo->m_hGetUSBThreadEventDead);
}
// CString ss;
// ss.Format("%d",inbufferptr[0][10]);
// AfxMessageBox(ss);
pVideo->m_pCFlyUSB->bH264decoder(inbufferptr[tempres],inbuffersize,outbufferptr[tempres],outbuffersize);
if(!(outbufferptr[tempres] == NULL))
{;
}
GetNum ++ ;
} SetEvent(pVideo->m_hDecodeThreadEventDead);
_endthread();
}void DispThread(void *param)
{
CFlyDemoDlg *pVideo = (CFlyDemoDlg *)param;
UINT timeStart=0;
UINT timeStop = 0;
UINT FrameNum = 0;
float Framefps = 0.00;
UINT GetNum = 0;
UINT tempres = 0;
int ret = 0;
int outbuffersize = (pVideo->CurrentSensor.width) * (pVideo->CurrentSensor.height) *(pVideo->CurrentSensor.type);
while (pVideo->m_RunMode!=RUNMODE_STOP)
{
if(outbufferptr[tempres] == NULL)
{
WaitForSingleObject(pVideo->m_hDisplayThreadEventDead, INFINITE);
CloseHandle(pVideo->m_hDisplayThreadEventDead);
} pVideo->m_USBKey = pVideo->m_pCFlyUSB->GetKey(RUNMODE_STOP);
pVideo->m_pDD->bDisplayVideo(outbufferptr[tempres]);
}
SetEvent(pVideo->m_hDisplayThreadEventDead);
_endthread();
}为什么显示都是绿屏?前提:我顺序执行解码显示正确
是不是同步有问题?
另问:
多线程怎么调试,不小心就死机,找不到问题出在哪里?
解决方案 »
- 控件的BN_CLICKED事件求助(在线等)
- 团结就是力量 我不认输 进者给分 免费放送经典的娱乐搞笑 各位兄弟姐妹 你们辛苦了 工作之余 记得休息哦
- 我用MCI播放AVI媒体文件,如果获得该文件的播放时间长度?
- 请问有什么算法之类的书
- 急问;哪里有Microsoft MediaPlayer SDK(MMS)???
- 侯捷先生的c++ primer 国内有卖的吗?有简体中文版的吗?什么时候出啊?
- 女朋友重要,还是事业重要?
- 关于属性表的问题,回答一定给分,请各位高手帮帮忙
- 如何做个批处理连续打印
- 在worker thread中函數connect正在连接到server,怎么...?
- 连续写串口时出现的问题
- 关于对话框类和配置文件的问题
输出调用信息至输出窗口:trace atltrace OutPutDebugString ....
另外下面应该是m_hDecodeThreadEventDead?
void DispThread(void *param)
{
CFlyDemoDlg *pVideo = (CFlyDemoDlg *)param;
UINT timeStart=0;
UINT timeStop = 0;
UINT FrameNum = 0;
float Framefps = 0.00;
UINT GetNum = 0;
UINT tempres = 0;
int ret = 0;
int outbuffersize = (pVideo->CurrentSensor.width) * (pVideo->CurrentSensor.height) *(pVideo->CurrentSensor.type); while (pVideo->m_RunMode!=RUNMODE_STOP)
{
if(outbufferptr[tempres] == NULL)
{
WaitForSingleObject(pVideo->m_hDisplayThreadEventDead, INFINITE); 《------
CloseHandle(pVideo->m_hDisplayThreadEventDead); 《------------------------
} pVideo->m_USBKey = pVideo->m_pCFlyUSB->GetKey(RUNMODE_STOP);
pVideo->m_pDD->bDisplayVideo(outbufferptr[tempres]);
} SetEvent(pVideo->m_hDisplayThreadEventDead);
_endthread(); }
建议写LOG,或者TRACE吧。