[asterisk-commits] rizzo: branch rizzo/video_console r125736 - /team/rizzo/video_console/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 27 06:37:28 CDT 2008


Author: rizzo
Date: Fri Jun 27 06:37:28 2008
New Revision: 125736

URL: http://svn.digium.com/view/asterisk?view=rev&rev=125736
Log:
collapse some common code sequences in a function.

Modified:
    team/rizzo/video_console/channels/console_gui.c

Modified: team/rizzo/video_console/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_console/channels/console_gui.c?view=diff&rev=125736&r1=125735&r2=125736
==============================================================================
--- team/rizzo/video_console/channels/console_gui.c (original)
+++ team/rizzo/video_console/channels/console_gui.c Fri Jun 27 06:37:28 2008
@@ -432,6 +432,14 @@
 	drag->drag_window = win;
 }
 
+static int update_device_info(struct video_desc *env, int i)
+{
+	reset_board(env->gui->bd_srcs_msg[i]);
+	print_message(env->gui->bd_srcs_msg[i],
+		src_msgs[env->out.devices[i].status_index]);
+	return 0;
+}
+
 /*! \brief Changes the video output (local video) source, controlling if
  * it is already using that video device, 
  * and switching the correct fields of env->out.
@@ -477,9 +485,7 @@
 			env->out.devices[*p].status_index &= ~IS_PRIMARY;
 		else
 			env->out.devices[*p].status_index &= ~IS_SECONDARY;
-		reset_board(env->gui->bd_srcs_msg[*p]);
-		print_message(env->gui->bd_srcs_msg[*p], 
-			src_msgs[env->out.devices[*p].status_index]);
+		update_device_info(env, *p);
 		/* update the index used as primary or secondary */
 		*p = index;
 		ast_log(LOG_WARNING, "done\n");
@@ -488,9 +494,7 @@
 			env->out.devices[*p].status_index |= IS_PRIMARY;
 		else
 			env->out.devices[*p].status_index |= IS_SECONDARY;
-		reset_board(env->gui->bd_srcs_msg[index]);
-		print_message(env->gui->bd_srcs_msg[index], 
-			src_msgs[env->out.devices[index].status_index]);
+		update_device_info(env, *p);
 		return 0;
 	}
 	/* device is off, just do nothing */
@@ -518,25 +522,21 @@
 		struct grab_desc *g;
 		int i;
 
-		/* see if we can open one of the grabbers XXX */
+		/* see if the device can be used by one of the existing drivers */
 		for (i = 0; (g = console_grabbers[i]); i++) {
-			if (g == NULL)
-				break;
-			/* the grabber is opened and the informations saved in the device table */
+			/* try open the device */
 			g_data = g->open(p->name, &env->out.loc_src_geometry, env->out.fps);
-			if (!g_data)
+			if (!g_data)	/* no luck, try the next driver */
 				continue;
 			p->grabber = g;
 			p->grabber_data = g_data;
 			/* update the status of the source */
 			p->status_index |= IS_ON;
 			/* print the new message in the message board */
-			reset_board(env->gui->bd_srcs_msg[index]);
-			print_message(env->gui->bd_srcs_msg[index],
-				src_msgs[p->status_index]);
+			update_device_info(env, index);
 			return 1; /* open succeded */
 		}
-		return 0; /* falure */
+		return 0; /* failure */
 	} else {
 		/* the grabber must be closed */
 		p->grabber_data = p->grabber->close(p->grabber_data);
@@ -548,9 +548,7 @@
 		/* update the status of the source */
 		p->status_index &= ~IS_ON;
 		/* print the new message in the message board */
-		reset_board(env->gui->bd_srcs_msg[index]);
-		print_message(env->gui->bd_srcs_msg[index], 
-			src_msgs[p->status_index]);
+		update_device_info(env, index);
 		return 2; /* closed */
 	}	
 }
@@ -738,9 +736,7 @@
 			this must be done here, otherwise the status of sources will not be
 			shown after sdl_setup */
 			for (i = 0; i < env->out.device_num; i++) {
-				reset_board(gui->bd_srcs_msg[i]);
-				print_message(gui->bd_srcs_msg[i],
-				  src_msgs[env->out.devices[i].status_index]);
+				update_device_info(env, i);
 			}
 			/* we also have to refresh other boards, 
 			to avoid messages to disappear after video resize */




More information about the asterisk-commits mailing list