[MPlayer-cvslog] r34995 - trunk/stream/tv.c

reimar subversion at mplayerhq.hu
Sat Jun 9 13:11:57 CEST 2012


Author: reimar
Date: Sat Jun  9 13:11:57 2012
New Revision: 34995

Log:
Reduce some code duplication.

Modified:
   trunk/stream/tv.c

Modified: trunk/stream/tv.c
==============================================================================
--- trunk/stream/tv.c	Sat Jun  9 08:46:00 2012	(r34994)
+++ trunk/stream/tv.c	Sat Jun  9 13:11:57 2012	(r34995)
@@ -403,6 +403,15 @@ static int tv_set_norm_i(tvi_handle_t *t
    return 1;
 }
 
+static void set_norm_and_freq(tvi_handle_t *tvh, tv_channels_t *chan)
+{
+    float freq = (float)chan->freq/1000;
+    mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, chan->number,
+           chan->name, freq);
+    tv_set_norm_i(tvh, chan->norm);
+    tv_set_freq(tvh, (unsigned long)(freq*16));
+}
+
 static int open_tv(tvi_handle_t *tvh)
 {
     int i;
@@ -589,10 +598,7 @@ static int open_tv(tvi_handle_t *tvh)
 			tv_channel_current = tv_channel_current->next;
 	}
 
-	mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
-			tv_channel_current->name, (float)tv_channel_current->freq/1000);
-	tv_set_norm_i(tvh, tv_channel_current->norm);
-	tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
+	set_norm_and_freq(tvh, tv_channel_current);
 	tv_channel_last = tv_channel_current;
     } else {
     /* we need to set frequency */
@@ -1020,11 +1026,7 @@ int tv_step_channel(tvi_handle_t *tvh, i
 				tv_channel_current = tv_channel_current->next;
 			else
 				tv_channel_current = tv_channel_list;
-
-				tv_set_norm_i(tvh, tv_channel_current->norm);
-				tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
-				mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
-			tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
+			set_norm_and_freq(tvh, tv_channel_current);
 		}
 		if (direction == TV_CHANNEL_LOWER) {
 			tv_channel_last = tv_channel_current;
@@ -1033,10 +1035,7 @@ int tv_step_channel(tvi_handle_t *tvh, i
 			else
 				while (tv_channel_current->next)
 					tv_channel_current = tv_channel_current->next;
-				tv_set_norm_i(tvh, tv_channel_current->norm);
-				tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
-				mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
-			tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
+			set_norm_and_freq(tvh, tv_channel_current);
 		}
 	} else tv_step_channel_real(tvh, direction);
 	return 1;
@@ -1076,10 +1075,7 @@ int tv_set_channel(tvi_handle_t *tvh, ch
 		for (i = 1; i < channel_int; i++)
 			if (tv_channel_current->next)
 				tv_channel_current = tv_channel_current->next;
-		mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
-				tv_channel_current->name, (float)tv_channel_current->freq/1000);
-		tv_set_norm_i(tvh, tv_channel_current->norm);
-		tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
+		set_norm_and_freq(tvh, tv_channel_current);
 	} else tv_set_channel_real(tvh, channel);
 	return 1;
 }
@@ -1094,10 +1090,7 @@ int tv_last_channel(tvi_handle_t *tvh) {
 		tv_channel_last = tv_channel_current;
 		tv_channel_current = tmp;
 
-		mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
-				tv_channel_current->name, (float)tv_channel_current->freq/1000);
-		tv_set_norm_i(tvh, tv_channel_current->norm);
-		tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
+		set_norm_and_freq(tvh, tv_channel_current);
 	} else {
 		int i;
 		struct CHANLIST cl;


More information about the MPlayer-cvslog mailing list