Commit f83e0c96 authored by Laurent Aimar's avatar Laurent Aimar

Converted atmo filter to vlc_clone().

I have just modified it to remove the use of vlc_thread_create(). There is
a lot of improvement that can be done to the way the thread are handled.

I have not tested it for regressions.
parent 03718ff8
...@@ -29,6 +29,7 @@ CAtmoExternalCaptureInput::CAtmoExternalCaptureInput(CAtmoDynData *pAtmoDynData) ...@@ -29,6 +29,7 @@ CAtmoExternalCaptureInput::CAtmoExternalCaptureInput(CAtmoDynData *pAtmoDynData)
vlc_cond_init( &m_WakeupCond ); vlc_cond_init( &m_WakeupCond );
vlc_mutex_init( &m_WakeupLock ); vlc_mutex_init( &m_WakeupLock );
m_pCurrentFramePixels = NULL; m_pCurrentFramePixels = NULL;
m_pLog = pAtmoDynData->getAtmoFilter();
} }
#else #else
...@@ -97,7 +98,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI ...@@ -97,7 +98,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI
the test needs and malloc needs... the test needs and malloc needs...
*/ */
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
// msg_Dbg( m_pAtmoThread, "DeliverNewSourceDataPaket start..."); // msg_Dbg( m_pLog, "DeliverNewSourceDataPaket start...");
vlc_mutex_lock( &m_WakeupLock ); vlc_mutex_lock( &m_WakeupLock );
#else #else
EnterCriticalSection( &m_BufferLock ); EnterCriticalSection( &m_BufferLock );
...@@ -119,7 +120,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI ...@@ -119,7 +120,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
vlc_cond_signal( &m_WakeupCond ); vlc_cond_signal( &m_WakeupCond );
vlc_mutex_unlock( &m_WakeupLock ); vlc_mutex_unlock( &m_WakeupLock );
// msg_Dbg( m_pAtmoThread, "DeliverNewSourceDataPaket done."); // msg_Dbg( m_pLog, "DeliverNewSourceDataPaket done.");
#else #else
SetEvent(m_hWakeupEvent); SetEvent(m_hWakeupEvent);
LeaveCriticalSection( &m_BufferLock ); LeaveCriticalSection( &m_BufferLock );
...@@ -136,7 +137,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI ...@@ -136,7 +137,7 @@ void CAtmoExternalCaptureInput::DeliverNewSourceDataPaket(BITMAPINFOHEADER *bmpI
DWORD CAtmoExternalCaptureInput::Execute(void) DWORD CAtmoExternalCaptureInput::Execute(void)
{ {
while ((this->m_bTerminated == ATMO_FALSE) && !this->m_pAtmoThread->b_die) { while ((this->m_bTerminated == ATMO_FALSE)) {
vlc_mutex_lock( &m_WakeupLock ); vlc_mutex_lock( &m_WakeupLock );
vlc_cond_timedwait(&m_WakeupCond, &m_WakeupLock, mdate() + 75000 ); vlc_cond_timedwait(&m_WakeupCond, &m_WakeupLock, mdate() + 75000 );
...@@ -146,7 +147,7 @@ DWORD CAtmoExternalCaptureInput::Execute(void) ...@@ -146,7 +147,7 @@ DWORD CAtmoExternalCaptureInput::Execute(void)
vlc_mutex_unlock( &m_WakeupLock ); vlc_mutex_unlock( &m_WakeupLock );
} }
msg_Dbg( m_pAtmoThread, "DWORD CAtmoExternalCaptureInput::Execute(void) bailed out?"); msg_Dbg( m_pLog, "DWORD CAtmoExternalCaptureInput::Execute(void) bailed out?");
return 0; return 0;
} }
...@@ -185,7 +186,7 @@ void CAtmoExternalCaptureInput::CalcColors() ...@@ -185,7 +186,7 @@ void CAtmoExternalCaptureInput::CalcColors()
int srcIndex,index = 0; int srcIndex,index = 0;
memset(&HSV_Img,0,sizeof(HSV_Img)); memset(&HSV_Img,0,sizeof(HSV_Img));
// msg_Dbg( m_pAtmoThread, "CalcColors start..."); // msg_Dbg( m_pLog, "CalcColors start...");
if((m_CurrentFrameHeader.biWidth == CAP_WIDTH) && (m_CurrentFrameHeader.biHeight == CAP_HEIGHT)) if((m_CurrentFrameHeader.biWidth == CAP_WIDTH) && (m_CurrentFrameHeader.biHeight == CAP_HEIGHT))
{ {
...@@ -271,8 +272,8 @@ void CAtmoExternalCaptureInput::CalcColors() ...@@ -271,8 +272,8 @@ void CAtmoExternalCaptureInput::CalcColors()
(sorry I don't know how it exactly works because the formulas (sorry I don't know how it exactly works because the formulas
are done by some one else...) are done by some one else...)
*/ */
//msg_Dbg( m_pAtmoThread, "CalcColors ende AddPacket..."); //msg_Dbg( m_pLog, "CalcColors ende AddPacket...");
m_pAtmoDynData->getLivePacketQueue()->AddPacket( m_pAtmoColorCalculator->AnalyzeHSV( HSV_Img ) ); m_pAtmoDynData->getLivePacketQueue()->AddPacket( m_pAtmoColorCalculator->AnalyzeHSV( HSV_Img ) );
//msg_Dbg( m_pAtmoThread, "CalcColors ende AddPacket...done."); //msg_Dbg( m_pLog, "CalcColors ende AddPacket...done.");
} }
...@@ -30,6 +30,7 @@ protected: ...@@ -30,6 +30,7 @@ protected:
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
vlc_cond_t m_WakeupCond; vlc_cond_t m_WakeupCond;
vlc_mutex_t m_WakeupLock; vlc_mutex_t m_WakeupLock;
vlc_object_t *m_pLog;
#else #else
HANDLE m_hWakeupEvent; HANDLE m_hWakeupEvent;
CRITICAL_SECTION m_BufferLock; CRITICAL_SECTION m_BufferLock;
......
...@@ -53,6 +53,7 @@ CAtmoLiveView::~CAtmoLiveView(void) ...@@ -53,6 +53,7 @@ CAtmoLiveView::~CAtmoLiveView(void)
DWORD CAtmoLiveView::Execute(void) DWORD CAtmoLiveView::Execute(void)
{ {
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
vlc_object_t *m_pLog = m_pAtmoDynData->getAtmoFilter();
mtime_t ticks; mtime_t ticks;
mtime_t t; mtime_t t;
mtime_t packet_time; mtime_t packet_time;
...@@ -97,7 +98,7 @@ DWORD CAtmoLiveView::Execute(void) ...@@ -97,7 +98,7 @@ DWORD CAtmoLiveView::Execute(void)
if( frameDelay > 0 ) if( frameDelay > 0 )
do_sleep( frameDelay ); do_sleep( frameDelay );
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
msg_Dbg( m_pAtmoThread, "First Packet got %"PRId64" ms", (get_time - t) / 1000 ); msg_Dbg( m_pLog, "First Packet got %"PRId64" ms", (get_time - t) / 1000 );
#endif #endif
} }
...@@ -108,7 +109,7 @@ DWORD CAtmoLiveView::Execute(void) ...@@ -108,7 +109,7 @@ DWORD CAtmoLiveView::Execute(void)
/* grab current Packet from InputQueue (working as FIFO)! */ /* grab current Packet from InputQueue (working as FIFO)! */
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), m_pAtmoThread, packet_time); ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), m_pLog, packet_time);
#else #else
ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), packet_time); ColorPacket = pPacketQueue->GetNextPacket(get_time - frameDelay, (i_frame_counter == 0), packet_time);
#endif #endif
...@@ -130,7 +131,7 @@ DWORD CAtmoLiveView::Execute(void) ...@@ -130,7 +131,7 @@ DWORD CAtmoLiveView::Execute(void)
if(i_frame_counter == 0) if(i_frame_counter == 0)
{ {
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
msg_Dbg( m_pAtmoThread, "wait for delayed packet..." ); msg_Dbg( m_pLog, "wait for delayed packet..." );
#endif #endif
t = get_time; t = get_time;
if( pPacketQueue->WaitForNextPacket(200) ) if( pPacketQueue->WaitForNextPacket(200) )
...@@ -138,7 +139,7 @@ DWORD CAtmoLiveView::Execute(void) ...@@ -138,7 +139,7 @@ DWORD CAtmoLiveView::Execute(void)
if( frameDelay > 0 ) if( frameDelay > 0 )
do_sleep( frameDelay ); do_sleep( frameDelay );
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
msg_Dbg( m_pAtmoThread, "got delayed packet %"PRId64" ms", (mdate() - t) / 1000 ); msg_Dbg( m_pLog, "got delayed packet %"PRId64" ms", (mdate() - t) / 1000 );
#endif #endif
continue; continue;
} }
...@@ -191,8 +192,8 @@ DWORD CAtmoLiveView::Execute(void) ...@@ -191,8 +192,8 @@ DWORD CAtmoLiveView::Execute(void)
} }
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
msg_Dbg( m_pAtmoThread, "DWORD CAtmoLiveView::Execute(void) terminates"); msg_Dbg( m_pLog, "DWORD CAtmoLiveView::Execute(void) terminates");
pPacketQueue->ShowQueueStatus( m_pAtmoThread ); pPacketQueue->ShowQueueStatus( m_pLog );
#endif #endif
delete (char *)PreviousPacket; delete (char *)PreviousPacket;
......
...@@ -181,7 +181,7 @@ pColorPacket CAtmoPacketQueue::GetNextPacket() ...@@ -181,7 +181,7 @@ pColorPacket CAtmoPacketQueue::GetNextPacket()
} }
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
void CAtmoPacketQueue::ShowQueueStatus(atmo_thread_t *p_this) void CAtmoPacketQueue::ShowQueueStatus(vlc_object_t *p_this)
{ {
/* /*
show some statistics for the whole time... show some statistics for the whole time...
...@@ -198,7 +198,7 @@ void CAtmoPacketQueue::ShowQueueStatus(atmo_thread_t *p_this) ...@@ -198,7 +198,7 @@ void CAtmoPacketQueue::ShowQueueStatus(atmo_thread_t *p_this)
#endif #endif
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
pColorPacket CAtmoPacketQueue::GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, atmo_thread_t *p_this, mtime_t &packet_time) pColorPacket CAtmoPacketQueue::GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, vlc_object_t *p_this, mtime_t &packet_time)
#else #else
pColorPacket CAtmoPacketQueue::GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time) pColorPacket CAtmoPacketQueue::GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time)
#endif #endif
......
...@@ -87,8 +87,8 @@ public: ...@@ -87,8 +87,8 @@ public:
// timecode = GetTickCount() - framedelay; // timecode = GetTickCount() - framedelay;
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
void ShowQueueStatus(atmo_thread_t *p_this); void ShowQueueStatus(vlc_object_t *p_this);
pColorPacket GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, atmo_thread_t *p_this, mtime_t &packet_time ); pColorPacket GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, vlc_object_t *p_this, mtime_t &packet_time );
#else #else
pColorPacket GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time ); pColorPacket GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time );
#endif #endif
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <assert.h>
#include "AtmoThread.h" #include "AtmoThread.h"
...@@ -17,18 +18,10 @@ ...@@ -17,18 +18,10 @@
CThread::CThread(vlc_object_t *pOwner) CThread::CThread(vlc_object_t *pOwner)
{ {
m_bTerminated = ATMO_FALSE; m_bTerminated = ATMO_FALSE;
m_pAtmoThread = (atmo_thread_t *)vlc_object_create( pOwner, vlc_mutex_init( &m_TerminateLock );
sizeof(atmo_thread_t) ); vlc_cond_init( &m_TerminateCond );
if(m_pAtmoThread) m_pOwner = pOwner;
{ m_HasThread = ATMO_FALSE;
m_pAtmoThread->p_thread = this;
this->m_pOwner = pOwner;
vlc_object_attach( m_pAtmoThread, m_pOwner);
vlc_mutex_init( &m_TerminateLock );
vlc_cond_init( &m_TerminateCond );
}
} }
#else #else
...@@ -51,12 +44,9 @@ CThread::CThread(void) ...@@ -51,12 +44,9 @@ CThread::CThread(void)
CThread::~CThread(void) CThread::~CThread(void)
{ {
if(m_pAtmoThread) assert(m_HasThread == ATMO_FALSE);
{ vlc_mutex_destroy( &m_TerminateLock );
vlc_mutex_destroy( &m_TerminateLock ); vlc_cond_destroy( &m_TerminateCond );
vlc_cond_destroy( &m_TerminateCond );
vlc_object_release(m_pAtmoThread);
}
} }
#else #else
...@@ -71,17 +61,14 @@ CThread::~CThread(void) ...@@ -71,17 +61,14 @@ CThread::~CThread(void)
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
void *CThread::ThreadProc(vlc_object_t *obj) void *CThread::ThreadProc(void *obj)
{ {
atmo_thread_t *pAtmoThread = (atmo_thread_t *)obj; CThread *pThread = static_cast<CThread*>(obj);
CThread *pThread = (CThread *)pAtmoThread->p_thread;
if(pThread) { int canc = vlc_savecancel ();
int canc; pThread->Execute();
vlc_restorecancel (canc);
canc = vlc_savecancel ();
pThread->Execute();
vlc_restorecancel (canc);
}
return NULL; return NULL;
} }
...@@ -117,15 +104,15 @@ void CThread::Terminate(void) ...@@ -117,15 +104,15 @@ void CThread::Terminate(void)
// and wait for Termination // and wait for Termination
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
if(m_pAtmoThread) if(m_HasThread != ATMO_FALSE)
{ {
vlc_mutex_lock( &m_TerminateLock ); vlc_mutex_lock( &m_TerminateLock );
m_bTerminated = ATMO_TRUE; m_bTerminated = ATMO_TRUE;
vlc_cond_signal( &m_TerminateCond ); vlc_cond_signal( &m_TerminateCond );
vlc_mutex_unlock( &m_TerminateLock ); vlc_mutex_unlock( &m_TerminateLock );
vlc_object_kill( m_pAtmoThread ); vlc_cancel( m_Thread );
vlc_thread_join( m_pAtmoThread ); vlc_join( m_Thread, NULL );
} }
#else #else
m_bTerminated = ATMO_TRUE; m_bTerminated = ATMO_TRUE;
...@@ -139,12 +126,14 @@ void CThread::Run() ...@@ -139,12 +126,14 @@ void CThread::Run()
m_bTerminated = ATMO_FALSE; m_bTerminated = ATMO_FALSE;
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
m_pAtmoThread->b_die = false; if (vlc_clone( &m_Thread, CThread::ThreadProc, this, VLC_THREAD_PRIORITY_LOW))
if(vlc_thread_create( m_pAtmoThread, {
CThread::ThreadProc, m_HasThread = ATMO_FALSE;
VLC_THREAD_PRIORITY_LOW )) msg_Err( m_pOwner, "cannot launch one of the AtmoLight threads");
}
else
{ {
msg_Err( m_pOwner, "cannot launch one of the AtmoLight threads"); m_HasThread = ATMO_TRUE;;
} }
#else #else
......
...@@ -15,13 +15,6 @@ ...@@ -15,13 +15,6 @@
// use threading stuff from videolan! // use threading stuff from videolan!
# include <vlc_common.h> # include <vlc_common.h>
# include <vlc_threads.h> # include <vlc_threads.h>
typedef struct
{
VLC_COMMON_MEMBERS
void *p_thread; /* cast to CThread * */
} atmo_thread_t;
#else #else
# include <windows.h> # include <windows.h>
#endif #endif
...@@ -32,10 +25,11 @@ protected: ...@@ -32,10 +25,11 @@ protected:
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
atmo_thread_t *m_pAtmoThread;
vlc_mutex_t m_TerminateLock; vlc_mutex_t m_TerminateLock;
vlc_cond_t m_TerminateCond; vlc_cond_t m_TerminateCond;
vlc_object_t *m_pOwner; vlc_object_t *m_pOwner;
ATMO_BOOL m_HasThread;
vlc_thread_t m_Thread;
#else #else
...@@ -50,7 +44,7 @@ protected: ...@@ -50,7 +44,7 @@ protected:
private: private:
#if defined(_ATMO_VLC_PLUGIN_) #if defined(_ATMO_VLC_PLUGIN_)
static void *ThreadProc(vlc_object_t *); static void *ThreadProc(void *);
#else #else
static DWORD WINAPI ThreadProc(LPVOID lpParameter); static DWORD WINAPI ThreadProc(LPVOID lpParameter);
#endif #endif
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include <vlc_filter.h> #include <vlc_filter.h>
#include <vlc_atomic.h>
#include "filter_picture.h" #include "filter_picture.h"
...@@ -699,8 +700,10 @@ static const char *const ppsz_filter_options[] = { ...@@ -699,8 +700,10 @@ static const char *const ppsz_filter_options[] = {
*/ */
typedef struct typedef struct
{ {
VLC_COMMON_MEMBERS filter_t *p_filter;
filter_t *p_filter; vlc_thread_t thread;
vlc_atomic_t abort;
/* tell the thread which color should be the target of fading */ /* tell the thread which color should be the target of fading */
uint8_t ui_red; uint8_t ui_red;
uint8_t ui_green; uint8_t ui_green;
...@@ -710,7 +713,7 @@ typedef struct ...@@ -710,7 +713,7 @@ typedef struct
} fadethread_t; } fadethread_t;
static void *FadeToColorThread(vlc_object_t *); static void *FadeToColorThread(void *);
/***************************************************************************** /*****************************************************************************
...@@ -1105,9 +1108,7 @@ static void Atmo_Shutdown(filter_t *p_filter) ...@@ -1105,9 +1108,7 @@ static void Atmo_Shutdown(filter_t *p_filter)
p_sys->b_pause_live = true; p_sys->b_pause_live = true;
p_sys->p_fadethread = (fadethread_t *)vlc_object_create( p_filter, p_sys->p_fadethread = (fadethread_t *)calloc( 1, sizeof(fadethread_t) );
sizeof(fadethread_t) );
p_sys->p_fadethread->p_filter = p_filter; p_sys->p_fadethread->p_filter = p_filter;
p_sys->p_fadethread->ui_red = p_sys->ui_endcolor_red; p_sys->p_fadethread->ui_red = p_sys->ui_endcolor_red;
p_sys->p_fadethread->ui_green = p_sys->ui_endcolor_green; p_sys->p_fadethread->ui_green = p_sys->ui_endcolor_green;
...@@ -1116,13 +1117,15 @@ static void Atmo_Shutdown(filter_t *p_filter) ...@@ -1116,13 +1117,15 @@ static void Atmo_Shutdown(filter_t *p_filter)
p_sys->p_fadethread->i_steps = 1; p_sys->p_fadethread->i_steps = 1;
else else
p_sys->p_fadethread->i_steps = p_sys->i_endfadesteps; p_sys->p_fadethread->i_steps = p_sys->i_endfadesteps;
vlc_atomic_set(&p_sys->p_fadethread->abort, 0);
if( vlc_thread_create( p_sys->p_fadethread, if( vlc_clone( &p_sys->p_fadethread->thread,
FadeToColorThread, FadeToColorThread,
VLC_THREAD_PRIORITY_LOW ) ) p_sys->p_fadethread,
VLC_THREAD_PRIORITY_LOW ) )
{ {
msg_Err( p_filter, "cannot create FadeToColorThread" ); msg_Err( p_filter, "cannot create FadeToColorThread" );
vlc_object_release( p_sys->p_fadethread ); free( p_sys->p_fadethread );
p_sys->p_fadethread = NULL; p_sys->p_fadethread = NULL;
vlc_mutex_unlock( &p_sys->filter_lock ); vlc_mutex_unlock( &p_sys->filter_lock );
...@@ -1131,9 +1134,9 @@ static void Atmo_Shutdown(filter_t *p_filter) ...@@ -1131,9 +1134,9 @@ static void Atmo_Shutdown(filter_t *p_filter)
vlc_mutex_unlock( &p_sys->filter_lock ); vlc_mutex_unlock( &p_sys->filter_lock );
/* wait for the thread... */ /* wait for the thread... */
vlc_thread_join(p_sys->p_fadethread); vlc_join(p_sys->p_fadethread->thread, NULL);
vlc_object_release(p_sys->p_fadethread); free(p_sys->p_fadethread);
p_sys->p_fadethread = NULL; p_sys->p_fadethread = NULL;
} }
...@@ -2323,7 +2326,7 @@ static picture_t * Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -2323,7 +2326,7 @@ static picture_t * Filter( filter_t *p_filter, picture_t *p_pic )
* to a target color defined in p_fadethread struct * to a target color defined in p_fadethread struct
* use for: Fade to Pause Color, and Fade to End Color * use for: Fade to Pause Color, and Fade to End Color
*****************************************************************************/ *****************************************************************************/
static void *FadeToColorThread(vlc_object_t *obj) static void *FadeToColorThread(void *obj)
{ {
fadethread_t *p_fadethread = (fadethread_t *)obj; fadethread_t *p_fadethread = (fadethread_t *)obj;
filter_sys_t *p_sys = (filter_sys_t *)p_fadethread->p_filter->p_sys; filter_sys_t *p_sys = (filter_sys_t *)p_fadethread->p_filter->p_sys;
...@@ -2366,7 +2369,7 @@ static void *FadeToColorThread(vlc_object_t *obj) ...@@ -2366,7 +2369,7 @@ static void *FadeToColorThread(vlc_object_t *obj)
/* send the same pixel data again... to unlock the buffer! */ /* send the same pixel data again... to unlock the buffer! */
AtmoSendPixelData( p_fadethread->p_filter ); AtmoSendPixelData( p_fadethread->p_filter );
while( (vlc_object_alive (p_fadethread)) && while( (!vlc_atomic_get (&p_fadethread->abort)) &&
(i_steps_done < p_fadethread->i_steps)) (i_steps_done < p_fadethread->i_steps))
{ {
p_transfer = AtmoLockTransferBuffer( p_fadethread->p_filter ); p_transfer = AtmoLockTransferBuffer( p_fadethread->p_filter );
...@@ -2379,7 +2382,7 @@ static void *FadeToColorThread(vlc_object_t *obj) ...@@ -2379,7 +2382,7 @@ static void *FadeToColorThread(vlc_object_t *obj)
thread improvements wellcome! thread improvements wellcome!
*/ */
for(i_index = 0; for(i_index = 0;
(i_index < i_size) && (vlc_object_alive (p_fadethread)); (i_index < i_size) && (!vlc_atomic_get (&p_fadethread->abort));
i_index+=4) i_index+=4)
{ {
i_src_blue = p_source[i_index+0]; i_src_blue = p_source[i_index+0];
...@@ -2435,11 +2438,10 @@ static void CheckAndStopFadeThread(filter_t *p_filter) ...@@ -2435,11 +2438,10 @@ static void CheckAndStopFadeThread(filter_t *p_filter)
{ {
msg_Dbg(p_filter, "kill still running fadeing thread..."); msg_Dbg(p_filter, "kill still running fadeing thread...");
p_sys->p_fadethread->b_die = true; vlc_atomic_set(&p_sys->p_fadethread->abort, 1);
vlc_thread_join(p_sys->p_fadethread); vlc_join(p_sys->p_fadethread->thread, NULL);
free(p_sys->p_fadethread);
vlc_object_release(p_sys->p_fadethread);
p_sys->p_fadethread = NULL; p_sys->p_fadethread = NULL;
} }
vlc_mutex_unlock( &p_sys->filter_lock ); vlc_mutex_unlock( &p_sys->filter_lock );
...@@ -2478,22 +2480,21 @@ static int StateCallback( vlc_object_t *, char const *, ...@@ -2478,22 +2480,21 @@ static int StateCallback( vlc_object_t *, char const *,
*/ */
if(p_sys->p_fadethread == NULL) if(p_sys->p_fadethread == NULL)
{ {
p_sys->p_fadethread = (fadethread_t *)vlc_object_create( p_sys->p_fadethread = (fadethread_t *)calloc( 1, sizeof(fadethread_t) );
p_filter,
sizeof(fadethread_t) );
p_sys->p_fadethread->p_filter = p_filter; p_sys->p_fadethread->p_filter = p_filter;
p_sys->p_fadethread->ui_red = p_sys->ui_pausecolor_red; p_sys->p_fadethread->ui_red = p_sys->ui_pausecolor_red;
p_sys->p_fadethread->ui_green = p_sys->ui_pausecolor_green; p_sys->p_fadethread->ui_green = p_sys->ui_pausecolor_green;
p_sys->p_fadethread->ui_blue = p_sys->ui_pausecolor_blue; p_sys->p_fadethread->ui_blue = p_sys->ui_pausecolor_blue;
p_sys->p_fadethread->i_steps = p_sys->i_fadesteps; p_sys->p_fadethread->i_steps = p_sys->i_fadesteps;
vlc_atomic_set(&p_sys->p_fadethread->abort, 0);
if( vlc_thread_create( p_sys->p_fadethread, if( vlc_clone( &p_sys->p_fadethread->thread,
FadeToColorThread, FadeToColorThread,
VLC_THREAD_PRIORITY_LOW ) ) p_sys->p_fadethread,
VLC_THREAD_PRIORITY_LOW ) )
{ {
msg_Err( p_filter, "cannot create FadeToColorThread" ); msg_Err( p_filter, "cannot create FadeToColorThread" );
vlc_object_release( p_sys->p_fadethread ); free( p_sys->p_fadethread );
p_sys->p_fadethread = NULL; p_sys->p_fadethread = NULL;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment