Commit 53d61587 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

OSS: remove variable callback (refs #5273) and factor error handling

parent 90cce4e0
...@@ -247,9 +247,6 @@ static void Probe( audio_output_t * p_aout ) ...@@ -247,9 +247,6 @@ static void Probe( audio_output_t * p_aout )
msg_Warn( p_aout, "S/PDIF not supported by card" ); msg_Warn( p_aout, "S/PDIF not supported by card" );
} }
} }
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart,
NULL );
} }
/***************************************************************************** /*****************************************************************************
...@@ -303,17 +300,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -303,17 +300,12 @@ static int Open( vlc_object_t *p_this )
p_aout->pf_flush = aout_PacketFlush; p_aout->pf_flush = aout_PacketFlush;
if ( var_Type( p_aout, "audio-device" ) == 0 ) if ( var_Type( p_aout, "audio-device" ) == 0 )
{
Probe( p_aout ); Probe( p_aout );
} var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
if ( var_Get( p_aout, "audio-device", &val ) < 0 ) if ( var_Get( p_aout, "audio-device", &val ) < 0 )
{
/* Probe() has failed. */ /* Probe() has failed. */
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
}
if ( val.i_int == AOUT_VAR_SPDIF ) if ( val.i_int == AOUT_VAR_SPDIF )
{ {
...@@ -350,9 +342,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -350,9 +342,7 @@ static int Open( vlc_object_t *p_this )
/* This should not happen ! */ /* This should not happen ! */
msg_Err( p_aout, "internal: can't find audio-device (%"PRId64")", msg_Err( p_aout, "internal: can't find audio-device (%"PRId64")",
val.i_int ); val.i_int );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
var_TriggerCallback( p_aout, "intf-change" ); var_TriggerCallback( p_aout, "intf-change" );
...@@ -361,9 +351,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -361,9 +351,7 @@ static int Open( vlc_object_t *p_this )
if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
{ {
msg_Err( p_aout, "cannot reset OSS audio device" ); msg_Err( p_aout, "cannot reset OSS audio device" );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
/* Set the output format */ /* Set the output format */
...@@ -375,9 +363,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -375,9 +363,7 @@ static int Open( vlc_object_t *p_this )
|| i_format != AFMT_AC3 ) || i_format != AFMT_AC3 )
{ {
msg_Err( p_aout, "cannot reset OSS audio device" ); msg_Err( p_aout, "cannot reset OSS audio device" );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
p_aout->format.i_format = VLC_CODEC_SPDIFL; p_aout->format.i_format = VLC_CODEC_SPDIFL;
...@@ -398,9 +384,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -398,9 +384,7 @@ static int Open( vlc_object_t *p_this )
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
{ {
msg_Err( p_aout, "cannot set audio output format" ); msg_Err( p_aout, "cannot set audio output format" );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
switch ( i_format ) switch ( i_format )
...@@ -426,9 +410,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -426,9 +410,7 @@ static int Open( vlc_object_t *p_this )
default: default:
msg_Err( p_aout, "OSS fell back to an unknown format (%d)", msg_Err( p_aout, "OSS fell back to an unknown format (%d)",
i_format ); i_format );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
i_nb_channels = aout_FormatNbChannels( &p_aout->format ); i_nb_channels = aout_FormatNbChannels( &p_aout->format );
...@@ -439,9 +421,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -439,9 +421,7 @@ static int Open( vlc_object_t *p_this )
{ {
msg_Err( p_aout, "cannot set number of audio channels (%s)", msg_Err( p_aout, "cannot set number of audio channels (%s)",
aout_FormatPrintChannels( &p_aout->format) ); aout_FormatPrintChannels( &p_aout->format) );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
/* Set the output rate */ /* Set the output rate */
...@@ -450,9 +430,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -450,9 +430,7 @@ static int Open( vlc_object_t *p_this )
{ {
msg_Err( p_aout, "cannot set audio output rate (%i)", msg_Err( p_aout, "cannot set audio output rate (%i)",
p_aout->format.i_rate ); p_aout->format.i_rate );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
if( i_rate != p_aout->format.i_rate ) if( i_rate != p_aout->format.i_rate )
...@@ -480,9 +458,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -480,9 +458,7 @@ static int Open( vlc_object_t *p_this )
if( ioctl( p_sys->i_fd, SNDCTL_DSP_GETOSPACE, &audio_buf ) < 0 ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_GETOSPACE, &audio_buf ) < 0 )
{ {
msg_Err( p_aout, "cannot get fragment size" ); msg_Err( p_aout, "cannot get fragment size" );
close( p_sys->i_fd ); goto error;
free( p_sys );
return VLC_EGENERIC;
} }
/* Number of fragments actually allocated */ /* Number of fragments actually allocated */
...@@ -505,13 +481,16 @@ static int Open( vlc_object_t *p_this ) ...@@ -505,13 +481,16 @@ static int Open( vlc_object_t *p_this )
VLC_THREAD_PRIORITY_OUTPUT ) ) VLC_THREAD_PRIORITY_OUTPUT ) )
{ {
msg_Err( p_aout, "cannot create OSS thread (%m)" ); msg_Err( p_aout, "cannot create OSS thread (%m)" );
close( p_sys->i_fd );
aout_PacketDestroy( p_aout ); aout_PacketDestroy( p_aout );
free( p_sys ); goto error;
return VLC_ENOMEM;
} }
return VLC_SUCCESS; return VLC_SUCCESS;
var_DelCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
close( p_sys->i_fd );
free( p_sys );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
...@@ -525,6 +504,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -525,6 +504,7 @@ static void Close( vlc_object_t * p_this )
vlc_cancel( p_sys->thread ); vlc_cancel( p_sys->thread );
vlc_join( p_sys->thread, NULL ); vlc_join( p_sys->thread, NULL );
p_aout->b_die = false; p_aout->b_die = false;
var_DelCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ); ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL );
close( p_sys->i_fd ); close( p_sys->i_fd );
......
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