#include "AtmoExternalCaptureInput.h"
#include "AtmoTools.h"
+#ifndef INT64_C
+#define INT64_C(c) c ## LL
+#endif
+
#if defined(_ATMO_VLC_PLUGIN_)
CAtmoExternalCaptureInput::CAtmoExternalCaptureInput(CAtmoDynData *pAtmoDynData) :
CThread(pAtmoDynData->getAtmoFilter())
{
m_pCurrentFramePixels = NULL;
- vlc_cond_init( this->m_pAtmoThread, &m_WakeupCond );
- vlc_mutex_init( m_pAtmoThread, &m_WakeupLock );
+ vlc_cond_init( &m_WakeupCond );
+ vlc_mutex_init( &m_WakeupLock );
msg_Dbg( m_pAtmoThread, "CAtmoExternalCaptureInput created.");
}
CAtmoExternalCaptureInput::~CAtmoExternalCaptureInput(void)
{
- /* if there is still an unprocessed bufferpicture do kill it */
- if(m_pCurrentFramePixels != NULL)
- free(m_pCurrentFramePixels);
+ /* if there is still an unprocessed bufferpicture do kill it */
+ free( m_pCurrentFramePixels );
#if defined(_ATMO_VLC_PLUGIN_)
vlc_cond_destroy( &m_WakeupCond );
memcpy(m_pCurrentFramePixels,pixelData,PixelDataSize);
}
#if defined(_ATMO_VLC_PLUGIN_)
+#error This makes no sense!
vlc_mutex_lock( &m_WakeupLock );
vlc_cond_signal( &m_WakeupCond );
vlc_mutex_unlock( &m_WakeupLock );
vlc_mutex_lock( &m_WakeupLock );
- while ((this->m_bTerminated == ATMO_FALSE) && (this->m_pAtmoThread->b_die == false)) {
- int value = vlc_cond_timedwait(&m_WakeupCond, &m_WakeupLock, mdate() + I64C(75000));
+ while ((this->m_bTerminated == ATMO_FALSE) && (!vlc_object_alive (this->m_pAtmoThread) == false)) {
+ int value = vlc_cond_timedwait(&m_WakeupCond, &m_WakeupLock, mdate() + INT64_C(75000));
if(!value) {
/* DeliverNewSourceDataPaket delivered new work for me... get it! */
CalcColors(); // read picture and calculate colors
i++;
if(i == 100) {
i = 0;
-#if !defined(WIN32)
-/* kludge for pthreads? using the same condition variable too often results in hanging the pthread
- call inside vlc_cond_timedwait...
-*/
-#ifdef _ATMO_KLUDGE_
- vlc_cond_destroy( &m_WakeupCond );
- vlc_cond_init( m_pAtmoThread, &m_WakeupCond );
-#endif
-#endif
}
}
vlc_mutex_unlock( &m_WakeupLock );
void CAtmoExternalCaptureInput::WaitForNextFrame(DWORD timeout)
{
this->m_FrameArrived = ATMO_FALSE;
+#error m_FrameArrived is not protected (no, volatile does not work)
for(DWORD i=0;(i<timeout) && !m_FrameArrived;i++)
#if defined (_ATMO_VLC_PLUGIN_)
+#error A condition variable or a semaphore is needed.
msleep(1000);
#else
Sleep(1);