Commit 70f43de3 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

motion: do not use pf_run

parent 53828bd5
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include <assert.h>
#include <unistd.h> #include <unistd.h>
#include <vlc_common.h> #include <vlc_common.h>
...@@ -46,6 +47,7 @@ ...@@ -46,6 +47,7 @@
struct intf_sys_t struct intf_sys_t
{ {
motion_sensors_t *p_motion; motion_sensors_t *p_motion;
vlc_thread_t thread;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -54,7 +56,7 @@ struct intf_sys_t ...@@ -54,7 +56,7 @@ struct intf_sys_t
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static void RunIntf( intf_thread_t *p_intf ); static void *RunIntf( void * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -79,21 +81,26 @@ vlc_module_end () ...@@ -79,21 +81,26 @@ vlc_module_end ()
int Open ( vlc_object_t *p_this ) int Open ( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
intf_sys_t *p_sys = malloc( sizeof( *p_sys ) );
p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); if( unlikely(p_sys == NULL) )
if( p_intf->p_sys == NULL )
{
return VLC_ENOMEM; return VLC_ENOMEM;
}
p_intf->p_sys->p_motion = motion_create( VLC_OBJECT( p_intf ) ); p_sys->p_motion = motion_create( VLC_OBJECT( p_intf ) );
if( p_intf->p_sys->p_motion == NULL ) if( p_sys->p_motion == NULL )
{ {
free( p_intf->p_sys ); error:
free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_intf->pf_run = RunIntf; p_intf->pf_run = NULL;
p_intf->p_sys = p_sys;
if( vlc_clone( &p_sys->thread, RunIntf, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{
motion_destroy( p_sys->p_motion );
goto error;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -104,9 +111,12 @@ int Open ( vlc_object_t *p_this ) ...@@ -104,9 +111,12 @@ int Open ( vlc_object_t *p_this )
void Close ( vlc_object_t *p_this ) void Close ( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
intf_sys_t *p_sys = p_intf->p_sys;
motion_destroy( p_intf->p_sys->p_motion ); vlc_cancel( p_sys->thread );
free( p_intf->p_sys ); vlc_join( p_sys->thread, NULL );
motion_destroy( p_sys->p_motion );
free( p_sys );
} }
/***************************************************************************** /*****************************************************************************
...@@ -114,8 +124,9 @@ void Close ( vlc_object_t *p_this ) ...@@ -114,8 +124,9 @@ void Close ( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
#define LOW_THRESHOLD 800 #define LOW_THRESHOLD 800
#define HIGH_THRESHOLD 1000 #define HIGH_THRESHOLD 1000
static void RunIntf( intf_thread_t *p_intf ) static void *RunIntf( void *data )
{ {
intf_thread_t *p_intf = data;
int i_oldx = 0; int i_oldx = 0;
for( ;; ) for( ;; )
...@@ -179,7 +190,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -179,7 +190,7 @@ static void RunIntf( intf_thread_t *p_intf )
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
assert(0);
} }
#undef LOW_THRESHOLD #undef LOW_THRESHOLD
#undef HIGH_THRESHOLD #undef HIGH_THRESHOLD
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