[MPlayer-dev-eng] [PATCH] 2 tv input patches, avoid hang and norm switch

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Nov 1 10:29:13 CET 2005


Hi,
the first attached patch keeps mplayer from hanging when the v4l2 does
not receive any frames by waiting at most half a second for a frame.
This seems resonable to me, and otherwise scanning channels for an
available station can be difficult for cards that do not produce frames
when they have not enough signal (e.g. saa7134).
The second patch implements norm switching, which is already documented
in the man page. Somebody should either implement or remove the
documentation of the chanlist switch key from the man page though.
I will apply soon.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/tvi_v4l2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l2.c,v
retrieving revision 1.32
diff -u -r1.32 tvi_v4l2.c
--- libmpdemux/tvi_v4l2.c	19 Sep 2005 22:47:16 -0000	1.32
+++ libmpdemux/tvi_v4l2.c	31 Oct 2005 14:12:25 -0000
@@ -1546,9 +1547,11 @@
     return NULL;
 }
 
+#define MAX_LOOP 50
 static double grab_video_frame(priv_t *priv, char *buffer, int len)
 {
     double interval;
+    int loop_cnt = 0;
 
     if (priv->first) {
 	pthread_create(&priv->video_grabber_thread, NULL, video_grabber, priv);
@@ -1557,6 +1560,7 @@
 
     while (priv->video_cnt == 0) {
 	usleep(10000);
+	if (loop_cnt++ > MAX_LOOP) return 0;
     }
 
     pthread_mutex_lock(&priv->video_buffer_mutex);
-------------- next part --------------
Index: libmpdemux/tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.74
diff -u -r1.74 tv.c
--- libmpdemux/tv.c	12 Sep 2005 22:48:14 -0000	1.74
+++ libmpdemux/tv.c	1 Nov 2005 09:10:36 -0000
@@ -836,6 +836,16 @@
 
 int tv_step_norm(tvi_handle_t *tvh)
 {
+  tvh->norm++;
+  if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
+                              &tvh->norm) != TVI_CONTROL_TRUE) {
+    tvh->norm = 0;
+    if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
+                                &tvh->norm) != TVI_CONTROL_TRUE) {
+      mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
+      return 0;
+    }
+  }
     return(1);
 }
 


More information about the MPlayer-dev-eng mailing list