mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	examples: add signal handlers to quit nicely
This commit is contained in:
		
							parent
							
								
									8e366a17ee
								
							
						
					
					
						commit
						8f8083b963
					
				
					 1 changed files with 10 additions and 1 deletions
				
			
		| 
						 | 
					@ -24,7 +24,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <sys/mman.h>
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <spa/utils/result.h>
 | 
					#include <spa/utils/result.h>
 | 
				
			||||||
#include <spa/param/video/format-utils.h>
 | 
					#include <spa/param/video/format-utils.h>
 | 
				
			||||||
| 
						 | 
					@ -397,6 +397,12 @@ static int build_format(struct data *data, struct spa_pod_builder *b, const stru
 | 
				
			||||||
	return 2;
 | 
						return 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void do_quit(void *userdata, int signal_number)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct data *data = userdata;
 | 
				
			||||||
 | 
						pw_main_loop_quit(data->loop);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[])
 | 
					int main(int argc, char *argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct data data = { 0, };
 | 
						struct data data = { 0, };
 | 
				
			||||||
| 
						 | 
					@ -410,6 +416,9 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	/* create a main loop */
 | 
						/* create a main loop */
 | 
				
			||||||
	data.loop = pw_main_loop_new(NULL);
 | 
						data.loop = pw_main_loop_new(NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGINT, do_quit, &data);
 | 
				
			||||||
 | 
						pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGTERM, do_quit, &data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* create a simple stream, the simple stream manages to core and remote
 | 
						/* create a simple stream, the simple stream manages to core and remote
 | 
				
			||||||
	 * objects for you if you don't need to deal with them
 | 
						 * objects for you if you don't need to deal with them
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue