88
99#include <pthread.h>
1010#include <signal.h>
11+ #include <stdatomic.h>
12+ #include <stdbool.h>
1113
1214#include "common.h"
1315#include "settings.h"
@@ -23,11 +25,11 @@ Thread athread = {0, -1}, vthread = {0, -1}, dthread = {0, -1};
2325
2426char * v4l2_dev = 0 ;
2527unsigned v4l2_width = 0 , v4l2_height = 0 ;
26- volatile int a_active = 0 ;
27- volatile int v_active = 0 ;
28- volatile int v_running = 0 ;
29- volatile int a_running = 0 ;
30- volatile int thread_cmd = 0 ;
28+ volatile bool a_active = false ;
29+ volatile bool v_active = false ;
30+ volatile bool v_running = false ;
31+ volatile bool a_running = false ;
32+ volatile char thread_cmd = 0 ;
3133int no_controls = 0 ;
3234struct settings g_settings = {0 };
3335
@@ -39,8 +41,8 @@ void * VideoThreadProc(void * args);
3941void * DecodeThreadProc (void * args );
4042
4143void sig_handler (__attribute__((__unused__ )) int sig ) {
42- a_running = 0 ;
43- v_running = 0 ;
44+ a_running = false ;
45+ v_running = false ;
4446 return ;
4547}
4648
@@ -113,7 +115,7 @@ static void parse_args(int argc, char *argv[]) {
113115 continue ;
114116 }
115117 if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'v' ) {
116- v_running = 1 ;
118+ v_running = true ;
117119 continue ;
118120 }
119121
@@ -142,8 +144,8 @@ static void parse_args(int argc, char *argv[]) {
142144 if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'l' ) {
143145 g_settings .port = strtoul (argv [i + 1 ], NULL , 10 );
144146 g_settings .connection = CB_WIFI_SRVR ;
145- a_running = 0 ;
146- v_running = 1 ;
147+ a_running = false ;
148+ v_running = true ;
147149 return ;
148150 }
149151
@@ -235,7 +237,7 @@ int main(int argc, char *argv[]) {
235237 parse_args (argc , argv );
236238
237239 if (!v_running && !a_running )
238- v_running = 1 ;
240+ v_running = true ;
239241
240242 if (!decoder_init (v4l2_dev , v4l2_width , v4l2_height )) {
241243 return 2 ;
@@ -264,7 +266,7 @@ int main(int argc, char *argv[]) {
264266 videoSocket = rc ;
265267 }
266268 else {
267- char * errmsg = NULL ;
269+ const char * errmsg = NULL ;
268270 videoSocket = Connect (g_settings .ip , g_settings .port , & errmsg );
269271 if (videoSocket == INVALID_SOCKET ) {
270272 errprint ("Video: Connect failed to %s:%d\n" , g_settings .ip , g_settings .port );
0 commit comments