Commit 88f10cc6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ALSA: use IEC958 device when applicable (and small simplification)

Probable regression from 95a18cc9
(9 months old, I guess no developers use S/PDIF)
parent 59444dc9
...@@ -159,12 +159,6 @@ static int Open (vlc_object_t *obj) ...@@ -159,12 +159,6 @@ static int Open (vlc_object_t *obj)
{ {
aout_instance_t * p_aout = (aout_instance_t *)obj; aout_instance_t * p_aout = (aout_instance_t *)obj;
/* Allocate structures */
aout_sys_t * p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL )
return VLC_ENOMEM;
p_aout->output.p_sys = p_sys;
/* Get device name */ /* Get device name */
char *psz_device; char *psz_device;
...@@ -172,23 +166,18 @@ static int Open (vlc_object_t *obj) ...@@ -172,23 +166,18 @@ static int Open (vlc_object_t *obj)
psz_device = var_GetString (p_aout, "audio-device"); psz_device = var_GetString (p_aout, "audio-device");
else else
psz_device = var_InheritString( p_aout, "alsa-audio-device" ); psz_device = var_InheritString( p_aout, "alsa-audio-device" );
if( unlikely(psz_device == NULL) ) if (unlikely(psz_device == NULL))
{
free( p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
}
/* Choose the IEC device for S/PDIF output: /* Choose the IEC device for S/PDIF output:
if the device is overridden by the user then it will be the one if the device is overridden by the user then it will be the one
otherwise we compute the default device based on the output format. */ otherwise we compute the default device based on the output format. */
char *psz_iec_device = NULL; if (AOUT_FMT_NON_LINEAR(&p_aout->output.output)
if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) && !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
{
if( !strcmp( psz_device, DEFAULT_ALSA_DEVICE ) )
{ {
unsigned aes3; unsigned aes3;
switch( p_aout->output.output.i_rate ) switch (p_aout->output.output.i_rate)
{ {
case 48000: case 48000:
aes3 = IEC958_AES3_CON_FS_48000; aes3 = IEC958_AES3_CON_FS_48000;
...@@ -201,20 +190,14 @@ static int Open (vlc_object_t *obj) ...@@ -201,20 +190,14 @@ static int Open (vlc_object_t *obj)
break; break;
} }
if( asprintf( &psz_iec_device, free (psz_device);
if (asprintf (&psz_device,
"iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO, IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER, IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
0, aes3 ) == -1 ) 0, aes3) == -1)
{
free( psz_device );
free( p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
}
else
psz_iec_device = strdup( psz_device );
}
snd_pcm_format_t pcm_format; /* ALSA sample format */ snd_pcm_format_t pcm_format; /* ALSA sample format */
vlc_fourcc_t fourcc = p_aout->output.output.i_format; vlc_fourcc_t fourcc = p_aout->output.output.i_format;
...@@ -285,6 +268,15 @@ static int Open (vlc_object_t *obj) ...@@ -285,6 +268,15 @@ static int Open (vlc_object_t *obj)
} }
} }
/* Allocate structures */
aout_sys_t *p_sys = malloc (sizeof (*p_sys));
if (unlikely(p_sys == NULL))
{
free (psz_device);
return VLC_ENOMEM;
}
p_aout->output.p_sys = p_sys;
#ifdef ALSA_DEBUG #ifdef ALSA_DEBUG
snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
#endif #endif
......
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