Exemple #1
0
void NLog::add_buffer( BufferNode* buffer )
{  
    {
        AutoLock( &mutex_ );
        list_add_tail( &(buffer->link_), &write_list_ );
    }

    {
        AutoLock( &buf_count_mtx_ );
        buf_count_++;
    }
}
Exemple #2
0
int NLog::get_write_buffer_list( list_head &_buf_list )
{
    int ret = -1;

    AutoLock( &mutex_ );
    if( !list_empty( &write_list_ ) ) {
        list_splice( &write_list_, &_buf_list );
        INIT_LIST_HEAD( &write_list_ );
        AutoLock( &buf_count_mtx_ );
        buf_count_ = 0;
        ret = 0;
    }
    return ret;
}
Exemple #3
0
INTATOMIC __FSAtomicAddSlow(INTATOMIC *pVar, INTATOMIC lAdd)
{
	static CFSMutex Mutex;
	CFSAutoLock AutoLock(&Mutex);
	(*pVar)+=lAdd;
	return *pVar;
}
Exemple #4
0
void NLog::process_timer( int frame )
{
	time_t tm_now;
	if( time( &tm_now ) == -1 )
    {
        ERR(2)( "[LOG] process_timer get time now is err. [%s]", strerror(errno) );
        return;
    }
	struct tm tm_time;
    localtime_r( &tm_now, &tm_time );   // Convert time to struct tm form 

	AutoLock( &mutex_ );
	time_len_ = strftime( time_str_, 256, "[%Y-%m-%d %H:%M:%S]", &tm_time );
    sprintf( time_str_, "%s[%08d] ", time_str_, frame );

    int min_5   = tm_time.tm_min / MAX_INTERVAL_TIME;
    if( min_5 != last_mod_min_ || last_mod_min_ == -1 ){
        last_mod_min_   = min_5; 
        switch_flag_    = 1;
        //对分钟进行圆整化处理
        int tmp_min = int(tm_time.tm_min / MAX_INTERVAL_TIME) * MAX_INTERVAL_TIME;
        tm_time.tm_min = tmp_min;
        strftime(time_file_name_, 256, "%Y%m%d%H%M", &tm_time);
    }
}
Exemple #5
0
bool CAudioDecFilter::SetDownMixSurround(bool bDownMix)
{
	CAutoLock AutoLock(&m_cPropLock);

	m_bDownMixSurround = bDownMix;
	return true;
}
Exemple #6
0
T* MemPooler<T>::alloc( )
{
	T* ret = NULL ;

	AutoLock( &mutex_ );
    // 尝试从现有的block中分配
    MemPoolBlock<T> *block = block_list_;
    while( block_list_ != block )
    {
        if( NULL != ( ret = block->alloc() ) )
        {
            break;
        }

        block = block->next;
    }

    // 尝试新分配一个block,然后分配T
    if( NULL == ret )
    {
        block = create_block();
        if( NULL == ( ret = block->alloc() ) )
        {
            return NULL;
        }
    }

    alloc_count_++;
	return ret;
}
Exemple #7
0
	bool DNSWorker::Request(std::string& strHostName,
		DNSWorkerCallBack callBack,
		void* pvUserData)
	{
		assert(!strHostName.empty());
		assert(callBack);
		assert(m_lpMsgHandler);


		DNSRequest* lpRequest = new DNSRequest();

		lpRequest->callBack = callBack;
		lpRequest->pvUserData = pvUserData;
		lpRequest->strHostName = strHostName;

		lpRequest->dwErrorCode = 0;
		lpRequest->m_recvWnd = m_lpMsgHandler->m_hWnd;


		do 
		{
			AutoCriticalSection AutoLock(m_cs);

			m_request.push_back(lpRequest);

			assert(m_waitObj);
			::SetEvent(m_waitObj);
		} while (false);
		return true;
	}
////////////////////////////////////////////////////////////////////////////
///
/// Get original PTS of currently visible buffer
///
/// \param Pts Pointer to Pts variable
///
/// \return Success if Pts value is available
///
ManifestorStatus_t Manifestor_Audio_c::GetNativeTimeOfCurrentlyManifestedFrame(unsigned long long *Time)
{
	BufferStatus_t BufferStatus;
	struct ParsedFrameParameters_s *FrameParameters;
	MANIFESTOR_DEBUG("\n");
	*Time = INVALID_TIME;
	OS_AutoLockMutex AutoLock(&BufferQueueLock);
	if (BufferQueueHead == INVALID_BUFFER_ID)
	{
		MANIFESTOR_DEBUG("No buffer on display.\n");
		return ManifestorError;
	}
	BufferStatus = StreamBuffer[BufferQueueHead].Buffer->ObtainMetaDataReference(
			       Player->MetaDataParsedFrameParametersReferenceType, (void **)&FrameParameters);
	if (BufferStatus != BufferNoError)
	{
		MANIFESTOR_ERROR("Unable to access buffer parsed frame parameters %x.\n", BufferStatus);
		return ManifestorError;
	}
	if (!ValidTime(FrameParameters->NativePlaybackTime))
	{
		MANIFESTOR_ERROR("Buffer on display does not have a valid native playback time\n");
		return ManifestorError;
	}
	MANIFESTOR_DEBUG("%lld\n", FrameParameters->NativePlaybackTime);
	*Time = FrameParameters->NativePlaybackTime;
	return ManifestorNoError;
}
Exemple #9
0
bool CAudioDecFilter::SetGainControl(bool bGainControl, float Gain, float SurroundGain)
{
	CAutoLock AutoLock(&m_cPropLock);

	m_bGainControl = bGainControl;
	m_Gain = Gain;
	m_SurroundGain = SurroundGain;
	return true;
}
Exemple #10
0
bool CAudioDecFilter::SetStreamCallback(StreamCallback pCallback, void *pParam)
{
	CAutoLock AutoLock(&m_cPropLock);

	m_pStreamCallback = pCallback;
	m_pStreamCallbackParam = pParam;

	return true;
}
Exemple #11
0
bool CAudioDecFilter::GetGainControl(float *pGain, float *pSurroundGain) const
{
	CAutoLock AutoLock(&m_cPropLock);

	if (pGain)
		*pGain = m_Gain;
	if (pSurroundGain)
		*pSurroundGain = m_SurroundGain;
	return m_bGainControl;
}
Exemple #12
0
HRESULT CAudioDecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
	HRESULT hr = __super::NewSegment(tStart, tStop, dRate);

	CAutoLock AutoLock(&m_cPropLock);

	ResetSync();

	return hr;
}
Exemple #13
0
BYTE CAudioDecFilter::GetCurrentChannelNum() const
{
	CAutoLock AutoLock(&m_cPropLock);

	if (m_CurChannelNum == 0)
		return CHANNEL_INVALID;
	if (m_bDualMono)
		return CHANNEL_DUALMONO;
	return m_CurChannelNum;
}
Exemple #14
0
bool CAudioDecFilter::GetSpdifOptions(SpdifOptions *pOptions) const
{
	if (!pOptions)
		return false;

	CAutoLock AutoLock(&m_cPropLock);

	*pOptions = m_SpdifOptions;

	return true;
}
Exemple #15
0
HRESULT CBonSrcPin::CheckMediaType(const CMediaType *pMediaType)
{
	CheckPointer(pMediaType, E_POINTER);
	CAutoLock AutoLock(&m_pFilter->m_cStateLock);

	// メディアタイプをチェックする
	CMediaType mt;
	GetMediaType(0, &mt);

	return (*pMediaType == mt) ? S_OK : E_FAIL;
}
Exemple #16
0
bool CAudioDecFilter::SetSpdifOptions(const SpdifOptions *pOptions)
{
	if (!pOptions)
		return false;

	CAutoLock AutoLock(&m_cPropLock);

	m_SpdifOptions = *pOptions;

	return true;
}
Exemple #17
0
bool CAudioDecFilter::SetJitterCorrection(bool bEnable)
{
	CAutoLock AutoLock(&m_cPropLock);

	m_bJitterCorrection = bEnable;

	m_StartTime = -1;
	m_SampleCount = 0;

	return true;
}
Exemple #18
0
bool CAudioDecFilter::SetDelay(LONGLONG Delay)
{
	CAutoLock AutoLock(&m_cPropLock);

	TRACE(TEXT("CAudioDecFilter::SetDelay() : %lld\n"), Delay);

	m_DelayAdjustment += Delay - m_Delay;
	m_Delay = Delay;

	return true;
}
Exemple #19
0
HRESULT CAudioDecFilter::StopStreaming()
{
	CAutoLock AutoLock(&m_cPropLock);

	if (m_pDecoder) {
		m_pDecoder->Close();
	}

	m_BitRateCalculator.Reset();

	return S_OK;
}
Exemple #20
0
void WINAPI CTNTServer::OnClose(const CONNECTION_ID& Connection, const DWORD& dwError)
{
	CAutoLock  AutoLock(&m_PeersLock);
	Trace(enTraceInfo, _T("Performing disconnection ..."));

	Trace(enTraceInfo, _T("[%s] %s"), m_mapPeers[Connection.m_Socket].m_sAddress.c_str(), 
		_T("Disconnected."));

	TMapPeers::iterator it = m_mapPeers.find(Connection.m_Socket);
	if(it != m_mapPeers.end())
		m_mapPeers.erase(it);
};
Exemple #21
0
DNS* DNS::GetInstance()
{
	static DNS* s_lpInstance = NULL;
	static CriticalSection cs;
	if (NULL == s_lpInstance)
	{
		AutoCriticalSection AutoLock(cs);
		s_lpInstance = new DNS();
		s_lpInstance->Init();
	}
	return s_lpInstance;
}
Exemple #22
0
bool CAudioDecFilter::SetSurroundMixingMatrix(const SurroundMixingMatrix *pMatrix)
{
	CAutoLock AutoLock(&m_cPropLock);

	if (pMatrix) {
		m_bEnableCustomMixingMatrix = true;
		m_MixingMatrix = *pMatrix;
	} else {
		m_bEnableCustomMixingMatrix = false;
	}

	return true;
}
Exemple #23
0
bool CAudioDecFilter::SetDownMixMatrix(const DownMixMatrix *pMatrix)
{
	CAutoLock AutoLock(&m_cPropLock);

	if (pMatrix) {
		m_bEnableCustomDownMixMatrix = true;
		m_DownMixMatrix = *pMatrix;
	} else {
		m_bEnableCustomDownMixMatrix = false;
	}

	return true;
}
Exemple #24
0
void NLog::delete_buffer( BufferNode* buffer )
{
    AutoLock( &mutex_ );
    int index = buffer - buf_mem_;
    if( index >= 0 && index < buf_max_ ) {
        list_add_tail( &(buffer->link_), &free_list_ );
    } else {
        SAFE_DELETE( buffer );
        --buf_new_;
        fprintf( fmem_check,"[NLOG] newed free_buffer be delete, buf_new: %d", buf_new_ );
        fflush( fmem_check );
    }
}
Exemple #25
0
CFSLockFreeFixAlloc *CFSThreadBasedFixAlloc::GetFixAlloc()
{
	FSTHREADID lThreadID=FSGetCurrentThreadID();
	for (CFixAllocChain *pChain=m_pFixAllocChain; pChain; pChain=pChain->m_pNext){
		if (lThreadID==pChain->m_lThreadID) {
			return &pChain->m_Alloc;
		}
	}
	CFSAutoLock AutoLock(&m_Mutex);
	CFixAllocChain *pElem=new CFixAllocChain(m_ipBlockSize, m_lCacheSpace);
	pElem->m_pNext=m_pFixAllocChain;
	m_pFixAllocChain=pElem;
	return &pElem->m_Alloc;
}
Exemple #26
0
	DNSWorker::DNSRequest* DNSWorker::PeekTask()
	{
		AutoCriticalSection AutoLock(m_cs);

		if (m_request.empty())
		{
			return NULL;
		}

		DNSRequest* lpRequest = m_request.front();
		m_request.pop_front();

		return lpRequest;
	}
Exemple #27
0
HRESULT CAudioDecFilter::GetMediaType(int iPosition, CMediaType *pMediaType)
{
	CheckPointer(pMediaType, E_POINTER);
	CAutoLock AutoLock(m_pLock);

	if (iPosition < 0)
		return E_INVALIDARG;
	if (iPosition > 0)
		return VFW_S_NO_MORE_ITEMS;

	*pMediaType = m_MediaType;

	return S_OK;
}
Exemple #28
0
HRESULT CAudioDecFilter::BeginFlush()
{
	HRESULT hr = __super::BeginFlush();

	CAutoLock AutoLock(&m_cPropLock);

	if (m_pDecoder) {
		m_pDecoder->Reset();
	}

	ResetSync();

	return hr;
}
Exemple #29
0
// <ICCIClient>
void AALBlock::OnWorkspaceAllocated(TransactionID const &TranID,
                                    btVirtAddr           WkspcVirt,
                                    btPhysAddr           WkspcPhys,
                                    btWSSize             WkspcSize)
{
   AutoLock(this);

   data_virt = WkspcVirt;
   data_phys = WkspcPhys;

   printf("Workspace allocated\n");

   m_Sem.Post(1);
}
Exemple #30
0
CThreadBase* CThreadPool::i_PopFromFreeList()
{
	CThreadBase* pThread = NULL;
	// 加锁列表
	CAutoLock AutoLock(&m_CsTFreeLock);
	// 验证列表是否为空
	if(false == m_TFreeList.empty())
	{
		// 获取线程池中线程对象
		pThread = m_TFreeList.front();
		m_TFreeList.pop_front();
	}
	// 返回获取到线程对象指针
	return pThread;
}