Skip to content

Commit

Permalink
shrecord: signal main thread to call cleanup()
Browse files Browse the repository at this point in the history
Don't call shrecord_cleanup() from the signal handler directly, but
instead flag to the shrecord_main thread to clean itself up.
  • Loading branch information
kfish committed Apr 16, 2010
1 parent 55d1d13 commit c304db3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ usage (const char * progname)
void sig_handler(int sig)
{
#ifdef HAVE_SHCODECS
shrecord_cleanup ();
shrecord_sighandler ();
#endif

#ifdef DEBUG
Expand Down
13 changes: 12 additions & 1 deletion src/shrecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ static int write_output(SHCodecs_Encoder *encoder,
return (alive?0:1);
}

void shrecord_cleanup (void)
static void
shrecord_cleanup (void)
{
double time;
struct private_data *pvt = &pvt_data;
Expand Down Expand Up @@ -335,6 +336,16 @@ void shrecord_cleanup (void)
uiomux_close (pvt->uiomux);
}

void
shrecord_sighandler (void)
{
struct private_data *pvt = &pvt_data;

alive = 0;

pthread_join (pvt->main_thread, NULL);
}

struct camera_data * get_camera (char * devicename, int width, int height)
{
struct private_data *pvt = &pvt_data;
Expand Down
2 changes: 1 addition & 1 deletion src/shrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ list_t * shrecord_resources (Dictionary * config);

int shrecord_init (void);
int shrecord_run (void);
void shrecord_cleanup (void);
void shrecord_sighandler (void);

#endif /* __SHRECORD_H__ */

0 comments on commit c304db3

Please sign in to comment.