[Mplayer-cvslog] CVS: main/libmpdemux tv.c,1.29,1.30 tv.h,1.15,1.16 tvi_v4l.c,1.26,1.27
Alex Beregszaszi
alex at mplayerhq.hu
Fri Aug 30 13:37:45 CEST 2002
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv21135/libmpdemux
Modified Files:
tv.c tv.h tvi_v4l.c
Log Message:
v4l audio fixes by Jindrich Makovicka <makovick at KMLinux.fjfi.cvut.cz>
Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- tv.c 21 Aug 2002 21:31:20 -0000 1.29
+++ tv.c 30 Aug 2002 11:37:42 -0000 1.30
@@ -52,8 +52,13 @@
char *tv_param_outfmt = "yv12";
float tv_param_fps = -1.0;
#ifdef HAVE_TV_V4L
-int tv_param_mono = 0;
+int tv_param_amode = -1;
int tv_param_audio_id = 0;
+int tv_param_volume = 60000;
+int tv_param_bass = -1;
+int tv_param_treble = -1;
+int tv_param_balance = -1;
+int tv_param_forcechan = -1;
#ifdef HAVE_ALSA9
int tv_param_alsa = 0;
#endif
Index: tv.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- tv.h 21 Aug 2002 21:31:20 -0000 1.15
+++ tv.h 30 Aug 2002 11:37:42 -0000 1.16
@@ -24,8 +24,13 @@
extern int tv_param_immediate;
extern int tv_param_audiorate;
#ifdef HAVE_TV_V4L
-extern int tv_param_mono;
+extern int tv_param_amode;
extern int tv_param_audio_id;
+extern int tv_param_volume;
+extern int tv_param_bass;
+extern int tv_param_treble;
+extern int tv_param_balance;
+extern int tv_param_forcechan;
#ifdef HAVE_ALSA9
extern int tv_param_alsa;
#endif
Index: tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- tvi_v4l.c 22 Aug 2002 23:05:58 -0000 1.26
+++ tvi_v4l.c 30 Aug 2002 11:37:42 -0000 1.27
@@ -144,8 +144,20 @@
};
#define PALETTE(x) ((x < sizeof(device_pal)/sizeof(char*)) ? device_pal[x] : "UNKNOWN")
-static const char *audio_mode2name[] = {
- "unknown", "mono", "stereo", "language1", "language2", NULL
+static const char *audio_mode2name(int mode)
+{
+ switch (mode) {
+ case VIDEO_SOUND_MONO:
+ return "mono";
+ case VIDEO_SOUND_STEREO:
+ return "stereo";
+ case VIDEO_SOUND_LANG1:
+ return "language1";
+ case VIDEO_SOUND_LANG2:
+ return "language2";
+ default:
+ return "unknown";
+ }
};
static void *audio_grabber(void *data);
@@ -262,6 +274,7 @@
static void init_v4l_audio(priv_t *priv)
{
int i;
+ int reqmode;
if (!priv->capability.audios) return;
@@ -289,15 +302,26 @@
/* mute all channels */
priv->audio[i].volume = 0;
priv->audio[i].flags |= VIDEO_AUDIO_MUTE;
- if (tv_param_mono) {
- priv->audio[i].mode = VIDEO_SOUND_MONO;
- ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]);
- } else {
- /* try to set stereo */
- priv->audio[i].mode = VIDEO_SOUND_STEREO;
- ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]);
+ if (tv_param_amode >= 0) {
+ switch (tv_param_amode) {
+ case 0:
+ reqmode = VIDEO_SOUND_MONO;
+ break;
+ case 1:
+ reqmode = VIDEO_SOUND_STEREO;
+ break;
+ case 2:
+ reqmode = VIDEO_SOUND_LANG1;
+ break;
+ case 3:
+ reqmode = VIDEO_SOUND_LANG2;
+ break;
+ }
}
+ priv->audio[i].mode = reqmode;
+ ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]);
+ // get the parameters back
if (ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno));
@@ -316,7 +340,15 @@
break;
}
+ if (tv_param_amode >= 0 && priv->audio[i].mode != reqmode) {
+ mp_msg(MSGT_TV, MSGL_ERR, "Audio mode setup warning!\n");
+ mp_msg(MSGT_TV, MSGL_ERR, "Requested mode was %s, but v4l still reports %s.\n",
+ audio_mode2name(reqmode), audio_mode2name(priv->audio[i].mode));
+ mp_msg(MSGT_TV, MSGL_ERR, "You may need \"forcechan\" option\nto force stereo/mono audio recording.\n");
+ }
+
/* display stuff */
+ mp_msg(MSGT_TV, MSGL_V, "Video capture card reports the audio setup as follows:\n");
mp_msg(MSGT_TV, MSGL_V, " %d: %s: ", priv->audio[i].audio,
priv->audio[i].name);
if (priv->audio[i].flags & VIDEO_AUDIO_MUTABLE) {
@@ -325,8 +357,17 @@
}
mp_msg(MSGT_TV, MSGL_V, "volume=%d bass=%d treble=%d balance=%d mode=%s\n",
priv->audio[i].volume, priv->audio[i].bass, priv->audio[i].treble,
- priv->audio[i].balance, audio_mode2name[priv->audio[i].mode]);
+ priv->audio[i].balance, audio_mode2name(priv->audio[i].mode));
mp_msg(MSGT_TV, MSGL_V, " channels: %d\n", priv->audio_channels[i]);
+
+ if (tv_param_forcechan >= 0)
+ priv->audio_channels[i] = tv_param_forcechan;
+
+ // we'll call VIDIOCSAUDIO again when starting capture
+ // let's set audio mode to requested mode again for the case
+ // when VIDIOCGAUDIO just cannot report the mode correctly
+ if (tv_param_amode >= 0)
+ priv->audio[i].mode = reqmode;
}
}
@@ -697,14 +738,20 @@
priv->first = 1;
/* enable audio */
- if (priv->audio[priv->audio_id].volume <= 0)
- priv->audio[priv->audio_id].volume = 100;
+ if (tv_param_volume >= 0)
+ priv->audio[priv->audio_id].volume = tv_param_volume;
+ if (tv_param_bass >= 0)
+ priv->audio[priv->audio_id].bass = tv_param_bass;
+ if (tv_param_treble >= 0)
+ priv->audio[priv->audio_id].treble = tv_param_treble;
+ if (tv_param_balance >= 0)
+ priv->audio[priv->audio_id].balance = tv_param_balance;
priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE;
- mp_msg(MSGT_TV, MSGL_V, "Starting audio capture\n");
+ mp_msg(MSGT_TV, MSGL_V, "Starting audio capture. Requested setup is:\n");
mp_msg(MSGT_TV, MSGL_V, "id=%d volume=%d bass=%d treble=%d balance=%d mode=%s\n",
priv->audio_id,
priv->audio[priv->audio_id].volume, priv->audio[priv->audio_id].bass, priv->audio[priv->audio_id].treble,
- priv->audio[priv->audio_id].balance, audio_mode2name[priv->audio[priv->audio_id].mode]);
+ priv->audio[priv->audio_id].balance, audio_mode2name(priv->audio[priv->audio_id].mode));
mp_msg(MSGT_TV, MSGL_V, " channels: %d\n", priv->audio_channels[priv->audio_id]);
ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]);
More information about the MPlayer-cvslog
mailing list