📄 umc_avs_dec_thread.cpp
字号:
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_DECODER)
#include "umc_avs_dec_thread.h"
#include "umc_avs_dec_fussion_core.h"
#include "umc_avs_dec_processing_unit.h"
#include "umc_event.h"
#include "vm_time.h"
namespace UMC
{
AVSThread::AVSThread(void)
{
m_bQuit = false;
m_bSleep = false;
m_threadNum = 0;
} // AVSThread::AVSThread(void)
AVSThread::~AVSThread(void)
{
// Release the object
Close();
} // AVSThread::~AVSThread(void)
Status AVSThread::Close(void)
{
// stop running thread
if (IsValid())
{
m_bQuit = true;
Wait();
}
// call the parent's method
Thread::Close();
m_bQuit = false;
m_threadNum = 0;
return UMC_OK;
} // Status AVSThread::Close(void)
Status AVSThread::Init(AVSFussionCore *pCore, Ipp32s iNumber)
{
// check error(s)
if (NULL == pCore)
return UMC_ERR_NULL_PTR;
// release object before initialization
AVSThread::Close();
// there is no parent's Init method, so we call nothing
// do all custom initializations
m_pCore = pCore;
m_threadNum = iNumber;
// run the thread
if (m_threadNum)
{
if (UMC_OK != Thread::Create(ThreadProc, this))
return UMC_ERR_FAILED;
}
return UMC_OK;
} // Status AVSThread::Init(AVSPictureBuffer *pPicBuffer, Ipp32s iNumber)
void AVSThread::GoSleep(Event &done)
{
// set the sleep flag & sync object
m_bSleep = true;
m_pSignal = &done;
// wait for the thread
done.Wait();
} // void AVSThread::GoSleep(Event &done)
void AVSThread::WakeUp(Event &done)
{
// set the sleep flag & sync object
m_bSleep = false;
m_pSignal = &done;
// wait for the thread
done.Wait();
} // void AVSThread::WakeUp(Event &done)
Status AVSThread::DoJob(void)
{
while (false == m_bQuit)
{
AVSProcessingUnit *pPerformer;
// get the next task
pPerformer = m_pCore->GetTask(m_threadNum);
try
{
// do the job
pPerformer->DoJob();
}
catch(...)
{
// in case of error,
// we need additional action
pPerformer->HandleError();
}
// there is a single quit condition for main thread.
// all other threads quit by flag.
if (AVS_TASK_COLOR_CONVERSION == pPerformer->GetTaskID())
break;
// sleep handling
if (m_bSleep)
{
// let the main thread know I am sleeping
m_pSignal->Set();
// sleep while flag is set
while (m_bSleep)
vm_time_sleep(5);
// let the main thread know I have woken up
m_pSignal->Set();
}
}
return UMC_OK;
} // Status AVSThread::DoJob(void)
Ipp32u AVSThread::ThreadProc(void *pParam)
{
AVSThread *pOwner = (AVSThread *) pParam;
// check error(s)
if (NULL == pOwner)
return 0x05decbad;
// drop into the working cicle
pOwner->DoJob();
return 0x05dec000 + pOwner->m_threadNum;
} // Ipp32u AVSThread::ThreadProc(void *pParam)
} // namespace UMC
#endif // #if defined(UMC_ENABLE_AVS_VIDEO_DECODER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -