LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gamix-disconnect-redraw.diff of Package gamix (Project openSUSE:Factory)

--- gamix2/catch.c-dist	2007-02-14 18:05:19.000000000 +0100
+++ gamix2/catch.c	2007-02-14 18:23:52.000000000 +0100
@@ -120,6 +120,7 @@ int time_init(void) {
 gint time_callback(gpointer data) {
 	int i,n,err;
 	unsigned int mask;
+	int disconnected = 0;
 
 	for( i=0 ; i<card_last ; i++ ) {
 		if( cards[i].handle == NULL ) continue;
@@ -136,6 +137,11 @@ gint time_callback(gpointer data) {
 #endif
 		while((n=poll(&cards[i].pfd,1,0))> 0 ) {
 			if( (err=snd_ctl_read(cards[i].handle,ev))<0 ) {
+				if (err == -ENODEV) { /* disconnected */
+					cards[i].enable = 0;
+					disconnected = 1;
+					break;
+				}
 				printf("hoe %d: %s\n",err,snd_strerror(err));
 				continue;
 			}
@@ -153,5 +159,12 @@ gint time_callback(gpointer data) {
 		}
 	}
 	
+	if (disconnected) {
+		extern GtkWidget *main_vbox;
+		extern GtkWidget *mixer_container;
+		gtk_container_remove(GTK_CONTAINER(main_vbox), mixer_container);
+		disp_mixer();
+	}
+
 	return 1;
 }