Index: libmpdemux/tvi_v4l.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v retrieving revision 1.50 diff -u -3 -p -u -r1.50 tvi_v4l.c --- libmpdemux/tvi_v4l.c 1 Jan 2003 20:21:45 -0000 1.50 +++ libmpdemux/tvi_v4l.c 4 Jan 2003 10:48:01 -0000 @@ -499,7 +499,20 @@ static int init(priv_t *priv) /* init v4l audio even when we don't capture */ init_v4l_audio(priv); - if (!priv->capability.audios && !tv_param_force_audio) tv_param_noaudio = 1; + if (tv_param_force_audio) { + /* if the audio was explicitly requested and we have some, + * then use it. Also disable tv_immediate_mode as we probably + * really want the sound if we asked for it + */ + if (priv->capability.audios) { + tv_param_noaudio = 0; + tv_param_immediate = 0; + } + } else { + if (!priv->capability.audios) { + tv_param_noaudio = 1; + } + } /* audio init */ if (!tv_param_noaudio) { @@ -1375,14 +1388,30 @@ static void *video_grabber(void *data) return NULL; } -static double grab_video_frame(priv_t *priv, char *buffer, int len) -{ - double interval; - +/** This function is called from grab_video_frame and + * grab_audio_frame to make sure that the video grabber + * thread is running. Because if it is not, then the + * audio thread cannot run, it is locked waiting for + * pthread_mutex_lock(&priv->audio_starter) + * + * It seems to be fine to leave this function unsynchronized + * because it is only called from the mplayer/mencoder core + * which is singlethreaded. Thus video_grabber_thread shall + * be started just once. + */ +void ensure_video_grabber_thread_is_running (priv_t *priv) { if (priv->first) { pthread_create(&priv->video_grabber_thread, NULL, video_grabber, priv); priv->first = 0; } +} + +static double grab_video_frame(priv_t *priv, char *buffer, int len) +{ + double interval; + + ensure_video_grabber_thread_is_running (priv); + while (priv->video_cnt == 0) { usleep(10000); @@ -1473,6 +1502,8 @@ static double grab_audio_frame(priv_t *p { mp_dbg(MSGT_TV, MSGL_DBG2, "grab_audio_frame(priv=%p, buffer=%p, len=%d)\n", priv, buffer, len); + + ensure_video_grabber_thread_is_running (priv); // compensate for dropped audio frames if (priv->audio_drop && (priv->audio_head == priv->audio_tail)) {