Sophie

Sophie

distrib > Arklinux > devel > i586 > by-pkgid > 9482443bfa78fcd0975e9204e634806b > files > 13

mplayer-1.0-0.svn34182.1ark.src.rpm

--- mplayer/stream/tvi_v4l.c.v4l2-4-v4l1~	2010-04-06 13:16:52.000000000 +0200
+++ mplayer/stream/tvi_v4l.c	2010-04-06 13:44:37.688598854 +0200
@@ -12,6 +12,9 @@
  * MJPEG hardware encoding support by
  *   Ivan Szanto <szivan@freemail.hu>
  *
+ * Basic video4linux2 support by
+ *   Bernhard Rosenkraenzer <bero@arklinux.org>
+ *
  * CODE IS UNDER DEVELOPMENT, NO FEATURE REQUESTS PLEASE!
  *
  * This file is part of MPlayer.
@@ -482,6 +485,15 @@ static int init(priv_t *priv)
             priv->video_device, strerror(errno));
         goto err;
     }
+#ifdef V4L2_CID_AUDIO_MUTE
+    /* V4L2's compat layer fails to report the correct number of audio devices */
+    struct v4l2_input input;
+    int index;
+    ioctl(priv->video_fd, VIDIOC_G_INPUT, &index);
+    input.index = index;
+    ioctl(priv->video_fd, VIDIOC_ENUMINPUT, &input);
+    priv->capability.audios = input.audioset;
+#endif
 
     /* check for v4l2 */
     if (ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) == 0) {
@@ -726,6 +738,14 @@ static int uninit(priv_t *priv)
         ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
     }
 
+#ifdef V4L2_CID_AUDIO_MUTE
+    /* v4l2's v4l1 emulation doesn't get audio right --> work around it */
+    struct v4l2_control ctrl;
+    ctrl.id = V4L2_CID_AUDIO_MUTE;
+    ctrl.value = 1;
+    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+#endif
+
     if ( priv->tv_param->mjpeg )
     {
         num = -1;
@@ -1127,6 +1147,37 @@ static int start(priv_t *priv)
         pthread_create(&priv->vbi_grabber_thread, NULL, vbi_grabber, priv);
     }
 
+#ifdef V4L2_CID_AUDIO_MUTE
+    /* v4l2's v4l1 emulation doesn't get audio right --> work around it */
+    struct v4l2_control ctrl;
+    ctrl.id = V4L2_CID_AUDIO_MUTE;
+    ctrl.value = 0;
+    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+    if(priv->tv_param->volume >= 0) {
+	    ctrl.id = V4L2_CID_AUDIO_VOLUME;
+	    ctrl.value = priv->tv_param->volume;
+	    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+    }
+
+    if(priv->tv_param->bass >= 0) {
+	    ctrl.id = V4L2_CID_AUDIO_BASS;
+	    ctrl.value = priv->tv_param->bass;
+	    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+    }
+
+    if(priv->tv_param->treble >= 0) {
+	    ctrl.id = V4L2_CID_AUDIO_TREBLE;
+	    ctrl.value = priv->tv_param->treble;
+	    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+    }
+
+    if(priv->tv_param->balance >= 0) {
+	    ctrl.id = V4L2_CID_AUDIO_BALANCE;
+	    ctrl.value = priv->tv_param->balance;
+	    ioctl(priv->video_fd, VIDIOC_S_CTRL, &ctrl);
+    }
+#endif
+
     /* launch capture threads */
     priv->shutdown = 0;
     if (!priv->tv_param->noaudio) {