Don't try setting the audio input source if the v4l2 device doesn't have any.
authorAntoine Cellerier <dionoea@videolan.org>
Sun, 13 Jan 2008 01:01:49 +0000 (01:01 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 13 Jan 2008 01:01:49 +0000 (01:01 +0000)
modules/access/v4l2.c

index 0531e4e..cb22530 100644 (file)
@@ -1897,16 +1897,23 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, vlc_bool_t b_d
         goto open_failed;
     }
 
-    if( p_sys->i_selected_audio_input >= p_sys->i_audio )
-    {
-        msg_Warn( p_obj, "invalid audio input. Using the default one" );
-        p_sys->i_selected_audio_input = 0;
-    }
+    /* Set audio input */
 
-    if( ioctl( i_fd, VIDIOC_S_AUDIO, &p_sys->p_audios[p_sys->i_selected_audio_input] ) < 0 )
+    if( p_sys->i_audio > 0 )
     {
-        msg_Err( p_obj, "cannot set audio input (%m)" );
-        goto open_failed;
+        if( p_sys->i_selected_audio_input < 0
+         || p_sys->i_selected_audio_input >= p_sys->i_audio )
+        {
+            msg_Warn( p_obj, "invalid audio input. Using the default one" );
+            p_sys->i_selected_audio_input = 0;
+        }
+
+        if( ioctl( i_fd, VIDIOC_S_AUDIO, &p_sys->p_audios[p_sys->i_selected_audio_input] ) < 0 )
+        {
+            msg_Err( p_obj, "cannot set audio input (%m)" );
+            goto open_failed;
+        }
+        msg_Dbg( p_obj, "Audio input set to %d", p_sys->i_selected_audio_input );
     }