[MPlayer-cvslog] CVS: main/libmpdemux tvi_v4l2.c,1.24,1.25

Jindrich Makovicka CVS syncmail at mplayerhq.hu
Sat May 14 15:54:28 CEST 2005


CVS change done by Jindrich Makovicka CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv32733

Modified Files:
	tvi_v4l2.c 
Log Message:
do not modify tv_param_noaudio

Index: tvi_v4l2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l2.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- tvi_v4l2.c	14 May 2005 13:04:30 -0000	1.24
+++ tvi_v4l2.c	14 May 2005 13:54:25 -0000	1.25
@@ -117,6 +117,7 @@
     volatile int                audio_drop;
     volatile int                shutdown;
 
+    int                         audio_inited;
     double                      audio_secs_per_block;
     long long                   audio_usecs_per_block;
     long long                   audio_skew_total;
@@ -340,6 +341,45 @@
 	   priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt);
 }
 
+static void init_audio(priv_t *priv)
+{
+    if (priv->audio_inited) return;
+
+    if (!tv_param_noaudio) {
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
+	if (tv_param_alsa)
+	    audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
+	else
+	    audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
+#else
+	audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
+#endif
+
+	if (priv->audio_dev) {
+	    audio_in_set_device(&priv->audio_in, priv->audio_dev);
+	}
+
+	audio_in_set_samplerate(&priv->audio_in, 44100);
+	if (priv->capability.capabilities & V4L2_CAP_TUNER) {
+	    if (priv->tuner.audmode == V4L2_TUNER_MODE_STEREO) {
+		audio_in_set_channels(&priv->audio_in, 2);
+	    } else {
+		audio_in_set_channels(&priv->audio_in, 1);
+	    }
+	} else {
+	    if (tv_param_forcechan >= 0) {
+		audio_in_set_channels(&priv->audio_in, tv_param_forcechan);
+	    } else {
+		audio_in_set_channels(&priv->audio_in, 2);
+	    }
+	}
+
+	if (audio_in_setup(&priv->audio_in) < 0) return;
+
+	priv->audio_inited = 1;
+    }
+}
+
 #if 0
 /*
 ** the number of milliseconds elapsed between time0 and time1
@@ -737,26 +777,35 @@
 	}
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_GET_FORMAT:
+	init_audio(priv);
+	if (!priv->audio_inited) return TVI_CONTROL_FALSE;
 	*(int *)arg = AF_FORMAT_S16_LE;
 	mp_msg(MSGT_TV, MSGL_V, "%s: get audio format: %d\n",
 	       info.short_name, *(int *)arg);
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_GET_SAMPLERATE:
+	init_audio(priv);
+	if (!priv->audio_inited) return TVI_CONTROL_FALSE;
 	*(int *)arg = priv->audio_in.samplerate;
 	mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplerate: %d\n",
 	       info.short_name, *(int *)arg);
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_GET_SAMPLESIZE:
-	*(int *)arg = priv->audio_in.bytes_per_sample;;
+	init_audio(priv);
+	if (!priv->audio_inited) return TVI_CONTROL_FALSE;
+	*(int *)arg = priv->audio_in.bytes_per_sample;
 	mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplesize: %d\n",
 	       info.short_name, *(int *)arg);
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_GET_CHANNELS:
+	init_audio(priv);
+	if (!priv->audio_inited) return TVI_CONTROL_FALSE;
 	*(int *)arg = priv->audio_in.channels;
 	mp_msg(MSGT_TV, MSGL_V, "%s: get audio channels: %d\n",
 	       info.short_name, *(int *)arg);
 	return TVI_CONTROL_TRUE;
     case TVI_CONTROL_AUD_SET_SAMPLERATE:
+	init_audio(priv);
 	mp_msg(MSGT_TV, MSGL_V, "%s: set audio samplerate: %d\n",
 	       info.short_name, *(int *)arg);
 	if (audio_in_set_samplerate(&priv->audio_in, *(int*)arg) < 0) return TVI_CONTROL_FALSE;
@@ -893,13 +942,12 @@
 {
     int i;
 
-    if (tv_param_immediate == 1)
-	tv_param_noaudio = 1;
-
     priv->audio_ringbuffer = NULL;
     priv->audio_skew_buffer = NULL;
     priv->audio_skew_delta_buffer = NULL;
 
+    priv->audio_inited = 0;
+
     /* Open the video device. */
     priv->video_fd = open(priv->video_dev, O_RDWR);
     if (priv->video_fd < 0) {
@@ -1070,39 +1118,6 @@
 	    set_control(priv, &control, 0);
 	}
     }
-    
-    /* audio init */
-    if (!tv_param_noaudio) {
-#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
-	if (tv_param_alsa)
-	    audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
-	else
-	    audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
-#else
-	audio_in_init(&priv->audio_in, AUDIO_IN_OSS);
-#endif
-
-	if (priv->audio_dev) {
-	    audio_in_set_device(&priv->audio_in, priv->audio_dev);
-	}
-
-	audio_in_set_samplerate(&priv->audio_in, 44100);
-	if (priv->capability.capabilities & V4L2_CAP_TUNER) {
-	    if (priv->tuner.audmode == V4L2_TUNER_MODE_STEREO) {
-		audio_in_set_channels(&priv->audio_in, 2);
-	    } else {
-		audio_in_set_channels(&priv->audio_in, 1);
-	    }
-	} else {
-	    if (tv_param_forcechan >= 0) {
-		audio_in_set_channels(&priv->audio_in, tv_param_forcechan);
-	    } else {
-		audio_in_set_channels(&priv->audio_in, 2);
-	    }
-	}
-	if (audio_in_setup(&priv->audio_in) < 0) return 0;
-//	setup_audio_buffer_sizes(priv);
-    }
 
     return 1;
 }
@@ -1146,6 +1161,9 @@
 
     /* setup audio parameters */
 
+    init_audio(priv);
+    if (!tv_param_noaudio && !priv->audio_inited) return 0;
+
     /* we need this to size the audio buffer properly */
     if (priv->immediate_mode) {
 	priv->video_buffer_size_max = 2;




More information about the MPlayer-cvslog mailing list