Commit cd541665 authored by Antoine Cellerier's avatar Antoine Cellerier

Don't compile any of the alsa audio input code if HAVE_ALSA isn't defined....

Don't compile any of the alsa audio input code if HAVE_ALSA isn't defined. This mainly removes the --v4l2-alsa option if alsa devlopement headers aren't available.
parent 78d1dbe5
...@@ -176,8 +176,10 @@ vlc_module_begin(); ...@@ -176,8 +176,10 @@ vlc_module_begin();
add_integer( "v4l2-hue", -1, NULL, HUE_TEXT, add_integer( "v4l2-hue", -1, NULL, HUE_TEXT,
HUE_LONGTEXT, VLC_TRUE ); HUE_LONGTEXT, VLC_TRUE );
add_float( "v4l2-fps", 0, NULL, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE ); add_float( "v4l2-fps", 0, NULL, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE );
#ifdef HAVE_ALSA
add_bool( "v4l2-alsa", VLC_FALSE, NULL, ALSA_TEXT, ALSA_LONGTEXT, add_bool( "v4l2-alsa", VLC_FALSE, NULL, ALSA_TEXT, ALSA_LONGTEXT,
VLC_TRUE ); VLC_TRUE );
#endif
add_bool( "v4l2-stereo", VLC_TRUE, NULL, STEREO_TEXT, STEREO_LONGTEXT, add_bool( "v4l2-stereo", VLC_TRUE, NULL, STEREO_TEXT, STEREO_LONGTEXT,
VLC_TRUE ); VLC_TRUE );
add_integer( "v4l2-samplerate", 48000, NULL, SAMPLERATE_TEXT, add_integer( "v4l2-samplerate", 48000, NULL, SAMPLERATE_TEXT,
...@@ -304,9 +306,9 @@ struct demux_sys_t ...@@ -304,9 +306,9 @@ struct demux_sys_t
block_t *p_block_audio; block_t *p_block_audio;
es_out_id_t *p_es_audio; es_out_id_t *p_es_audio;
#ifdef HAVE_ALSA
/* ALSA Audio */ /* ALSA Audio */
vlc_bool_t b_use_alsa; vlc_bool_t b_use_alsa;
#ifdef HAVE_ALSA
snd_pcm_t *p_alsa_pcm; snd_pcm_t *p_alsa_pcm;
int i_alsa_frame_size; int i_alsa_frame_size;
int i_alsa_chunk_size; int i_alsa_chunk_size;
...@@ -367,9 +369,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -367,9 +369,11 @@ static int Open( vlc_object_t *p_this )
p_sys->psz_requested_chroma = var_CreateGetString( p_demux, "v4l2-chroma" ); p_sys->psz_requested_chroma = var_CreateGetString( p_demux, "v4l2-chroma" );
#ifdef HAVE_ALSA
var_Create( p_demux, "v4l2-alsa", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_demux, "v4l2-alsa", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_demux, "v4l2-alsa", &val ); var_Get( p_demux, "v4l2-alsa", &val );
p_sys->b_use_alsa = val.b_bool; p_sys->b_use_alsa = val.b_bool;
#endif
var_Create( p_demux, "v4l2-stereo", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_demux, "v4l2-stereo", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Get( p_demux, "v4l2-stereo", &val ); var_Get( p_demux, "v4l2-stereo", &val );
...@@ -386,8 +390,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -386,8 +390,8 @@ static int Open( vlc_object_t *p_this )
ParseMRL( p_demux ); ParseMRL( p_demux );
/* Alsa support available? */
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
/* Alsa support available? */
msg_Dbg( p_demux, "ALSA input support available" ); msg_Dbg( p_demux, "ALSA input support available" );
#endif #endif
...@@ -653,11 +657,13 @@ static void ParseMRL( demux_t *p_demux ) ...@@ -653,11 +657,13 @@ static void ParseMRL( demux_t *p_demux )
strtol( psz_parser + strlen( "samplerate=" ), strtol( psz_parser + strlen( "samplerate=" ),
&psz_parser, 0 ); &psz_parser, 0 );
} }
#ifdef HAVE_ALSA
else if( !strncmp( psz_parser, "alsa", strlen( "alsa" ) ) ) else if( !strncmp( psz_parser, "alsa", strlen( "alsa" ) ) )
{ {
psz_parser += strlen( "alsa" ); psz_parser += strlen( "alsa" );
p_sys->b_use_alsa = VLC_TRUE; p_sys->b_use_alsa = VLC_TRUE;
} }
#endif
else if( !strncmp( psz_parser, "stereo", strlen( "stereo" ) ) ) else if( !strncmp( psz_parser, "stereo", strlen( "stereo" ) ) )
{ {
psz_parser += strlen( "stereo" ); psz_parser += strlen( "stereo" );
...@@ -769,13 +775,13 @@ static void Close( vlc_object_t *p_this ) ...@@ -769,13 +775,13 @@ static void Close( vlc_object_t *p_this )
/* Close */ /* Close */
if( p_sys->i_fd_video >= 0 ) close( p_sys->i_fd_video ); if( p_sys->i_fd_video >= 0 ) close( p_sys->i_fd_video );
#ifdef HAVE_ALSA
if( p_sys->b_use_alsa ) if( p_sys->b_use_alsa )
{ {
#ifdef HAVE_ALSA
if( p_sys->p_alsa_pcm ) snd_pcm_close( p_sys->p_alsa_pcm ); if( p_sys->p_alsa_pcm ) snd_pcm_close( p_sys->p_alsa_pcm );
#endif
} }
else else
#endif
{ {
if( p_sys->i_fd_audio >= 0 ) close( p_sys->i_fd_audio ); if( p_sys->i_fd_audio >= 0 ) close( p_sys->i_fd_audio );
} }
...@@ -1041,17 +1047,15 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1041,17 +1047,15 @@ static block_t* GrabAudio( demux_t *p_demux )
p_sys->p_block_audio = p_block; p_sys->p_block_audio = p_block;
#ifdef HAVE_ALSA
if( p_sys->b_use_alsa ) if( p_sys->b_use_alsa )
{ {
/* ALSA */ /* ALSA */
#ifdef HAVE_ALSA
i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size ); i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size );
/* TODO: ALSA ERROR HANDLING?? xrun?? */ /* TODO: ALSA ERROR HANDLING?? xrun?? */
#else
i_read = 0;
#endif
} }
else else
#endif
{ {
/* OSS */ /* OSS */
i_read = read( p_sys->i_fd_audio, p_block->p_buffer, i_read = read( p_sys->i_fd_audio, p_block->p_buffer,
...@@ -1065,16 +1069,18 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1065,16 +1069,18 @@ static block_t* GrabAudio( demux_t *p_demux )
/* Correct the date because of kernel buffering */ /* Correct the date because of kernel buffering */
i_correct = i_read; i_correct = i_read;
#ifdef HAVE_ALSA
if( !p_sys->b_use_alsa ) if( !p_sys->b_use_alsa )
#endif
{ {
if( ioctl( p_sys->i_fd_audio, SNDCTL_DSP_GETISPACE, &buf_info ) == 0 ) if( ioctl( p_sys->i_fd_audio, SNDCTL_DSP_GETISPACE, &buf_info ) == 0 )
{ {
i_correct += buf_info.bytes; i_correct += buf_info.bytes;
} }
} }
#ifdef HAVE_ALSA
else else
{ {
#ifdef HAVE_ALSA
/* TODO: ALSA timing */ /* TODO: ALSA timing */
/* Very experimental code... */ /* Very experimental code... */
int i_err; int i_err;
...@@ -1097,8 +1103,8 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1097,8 +1103,8 @@ static block_t* GrabAudio( demux_t *p_demux )
msg_Warn( p_demux, "ALSA snd_pcm_delay failed (%s)", snd_strerror( i_err ) ); msg_Warn( p_demux, "ALSA snd_pcm_delay failed (%s)", snd_strerror( i_err ) );
snd_pcm_prepare( p_sys->p_alsa_pcm ); snd_pcm_prepare( p_sys->p_alsa_pcm );
} }
#endif
} }
#endif
/* Timestamp */ /* Timestamp */
p_block->i_pts = p_block->i_dts = p_block->i_pts = p_block->i_dts =
...@@ -1705,6 +1711,7 @@ open_failed: ...@@ -1705,6 +1711,7 @@ open_failed:
} }
#ifdef HAVE_ALSA
/***************************************************************************** /*****************************************************************************
* ResolveALSADeviceName: Change any . to : in the ALSA device name * ResolveALSADeviceName: Change any . to : in the ALSA device name
*****************************************************************************/ *****************************************************************************/
...@@ -1717,6 +1724,7 @@ char* ResolveALSADeviceName( char *psz_device ) ...@@ -1717,6 +1724,7 @@ char* ResolveALSADeviceName( char *psz_device )
} }
return psz_alsa_name; return psz_alsa_name;
} }
#endif
/***************************************************************************** /*****************************************************************************
* OpenAudioDev: open and set up the audio device and probe for capabilities * OpenAudioDev: open and set up the audio device and probe for capabilities
...@@ -1734,11 +1742,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -1734,11 +1742,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device )
snd_pcm_uframes_t chunk_size; snd_pcm_uframes_t chunk_size;
#endif #endif
#ifdef HAVE_ALSA
if( p_sys->b_use_alsa ) if( p_sys->b_use_alsa )
{ {
/* ALSA */ /* ALSA */
#ifdef HAVE_ALSA
int i_err; int i_err;
if( ( i_err = snd_pcm_open( &p_sys->p_alsa_pcm, psz_alsa_device_name, if( ( i_err = snd_pcm_open( &p_sys->p_alsa_pcm, psz_alsa_device_name,
...@@ -1790,11 +1798,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -1790,11 +1798,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device )
} }
/* Set sample rate */ /* Set sample rate */
#ifdef HAVE_ALSA_NEW_API #ifdef HAVE_ALSA_NEW_API
i_err = snd_pcm_hw_params_set_rate_near( p_sys->p_alsa_pcm, p_hw_params, &p_sys->i_sample_rate, NULL ); i_err = snd_pcm_hw_params_set_rate_near( p_sys->p_alsa_pcm, p_hw_params, &p_sys->i_sample_rate, NULL );
#else #else
i_err = snd_pcm_hw_params_set_rate_near( p_sys->p_alsa_pcm, p_hw_params, p_sys->i_sample_rate, NULL ); i_err = snd_pcm_hw_params_set_rate_near( p_sys->p_alsa_pcm, p_hw_params, p_sys->i_sample_rate, NULL );
#endif #endif
if( i_err < 0 ) if( i_err < 0 )
{ {
msg_Err( p_demux, "ALSA: cannot set sample rate (%s)", msg_Err( p_demux, "ALSA: cannot set sample rate (%s)",
...@@ -1831,11 +1839,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -1831,11 +1839,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device )
/* Set period time */ /* Set period time */
unsigned int period_time = buffer_time / 4; unsigned int period_time = buffer_time / 4;
#ifdef HAVE_ALSA_NEW_API #ifdef HAVE_ALSA_NEW_API
i_err = snd_pcm_hw_params_set_period_time_near( p_sys->p_alsa_pcm, p_hw_params, &period_time, 0 ); i_err = snd_pcm_hw_params_set_period_time_near( p_sys->p_alsa_pcm, p_hw_params, &period_time, 0 );
#else #else
i_err = snd_pcm_hw_params_set_period_time_near( p_sys->p_alsa_pcm, p_hw_params, period_time, 0 ); i_err = snd_pcm_hw_params_set_period_time_near( p_sys->p_alsa_pcm, p_hw_params, period_time, 0 );
#endif #endif
if( i_err < 0 ) if( i_err < 0 )
{ {
msg_Err( p_demux, "ALSA: cannot set period time (%s)", msg_Err( p_demux, "ALSA: cannot set period time (%s)",
...@@ -1844,11 +1852,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -1844,11 +1852,11 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device )
} }
/* Set buffer time */ /* Set buffer time */
#ifdef HAVE_ALSA_NEW_API #ifdef HAVE_ALSA_NEW_API
i_err = snd_pcm_hw_params_set_buffer_time_near( p_sys->p_alsa_pcm, p_hw_params, &buffer_time, 0 ); i_err = snd_pcm_hw_params_set_buffer_time_near( p_sys->p_alsa_pcm, p_hw_params, &buffer_time, 0 );
#else #else
i_err = snd_pcm_hw_params_set_buffer_time_near( p_sys->p_alsa_pcm, p_hw_params, buffer_time, 0 ); i_err = snd_pcm_hw_params_set_buffer_time_near( p_sys->p_alsa_pcm, p_hw_params, buffer_time, 0 );
#endif #endif
if( i_err < 0 ) if( i_err < 0 )
{ {
msg_Err( p_demux, "ALSA: cannot set buffer time (%s)", msg_Err( p_demux, "ALSA: cannot set buffer time (%s)",
...@@ -1895,9 +1903,9 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -1895,9 +1903,9 @@ int OpenAudioDev( demux_t *p_demux, char *psz_device )
/* Return a fake handle so other tests work */ /* Return a fake handle so other tests work */
i_fd = 1; i_fd = 1;
#endif
} }
else else
#endif /* HAVE_ALSA */
{ {
/* OSS */ /* OSS */
...@@ -2265,13 +2273,14 @@ vlc_bool_t ProbeAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -2265,13 +2273,14 @@ vlc_bool_t ProbeAudioDev( demux_t *p_demux, char *psz_device )
{ {
int i_fd = 0; int i_fd = 0;
int i_caps; int i_caps;
#ifdef HAVE_ALSA
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
if( p_sys->b_use_alsa ) if( p_sys->b_use_alsa )
{ {
/* ALSA */ /* ALSA */
#ifdef HAVE_ALSA
int i_err; int i_err;
snd_pcm_t *p_alsa_pcm; snd_pcm_t *p_alsa_pcm;
char* psz_alsa_device_name = ResolveALSADeviceName( psz_device ); char* psz_alsa_device_name = ResolveALSADeviceName( psz_device );
...@@ -2285,12 +2294,9 @@ vlc_bool_t ProbeAudioDev( demux_t *p_demux, char *psz_device ) ...@@ -2285,12 +2294,9 @@ vlc_bool_t ProbeAudioDev( demux_t *p_demux, char *psz_device )
snd_pcm_close( p_alsa_pcm ); snd_pcm_close( p_alsa_pcm );
free( psz_alsa_device_name ); free( psz_alsa_device_name );
#else
msg_Err( p_demux, "ALSA support not available" );
goto open_failed;
#endif
} }
else else
#endif /* HAVE_ALSA */
{ {
/* OSS */ /* OSS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment