Commit 06ac7b77 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ALSA: only try S/PDIF default device if "spdif" is enabled

Otherwise, use the normal default device even if the audio input format
is non-linear (VLC does A/52, DTS and MPGA to linear decoding as audio
filter rather than decoder).
parent 3fb5c74c
...@@ -183,39 +183,10 @@ static int Open (vlc_object_t *obj) ...@@ -183,39 +183,10 @@ static int Open (vlc_object_t *obj)
if (unlikely(psz_device == NULL)) if (unlikely(psz_device == NULL))
return VLC_ENOMEM; return VLC_ENOMEM;
/* Choose the IEC device for S/PDIF output:
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. */
if (AOUT_FMT_NON_LINEAR(&p_aout->output.output)
&& !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
{
unsigned aes3;
switch (p_aout->output.output.i_rate)
{
#define FS(freq) \
case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
FS( 44100) /* def. */ FS( 48000) FS( 32000)
FS( 22050) FS( 24000)
FS( 88200) FS(768000) FS( 96000)
FS(176400) FS(192000)
#undef FS
default:
aes3 = IEC958_AES3_CON_FS_NOTID;
break;
}
free (psz_device);
if (asprintf (&psz_device,
"iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
0, aes3) == -1)
return VLC_ENOMEM;
}
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;
bool spdif = false;
switch (fourcc) switch (fourcc)
{ {
case VLC_CODEC_F64B: case VLC_CODEC_F64B:
...@@ -271,6 +242,8 @@ static int Open (vlc_object_t *obj) ...@@ -271,6 +242,8 @@ static int Open (vlc_object_t *obj)
pcm_format = SND_PCM_FORMAT_U8; pcm_format = SND_PCM_FORMAT_U8;
break; break;
default: default:
if (AOUT_FMT_NON_LINEAR(&p_aout->output.output))
spdif = var_InheritBool (p_aout, "spdif");
if (HAVE_FPU) if (HAVE_FPU)
{ {
fourcc = VLC_CODEC_FL32; fourcc = VLC_CODEC_FL32;
...@@ -283,6 +256,36 @@ static int Open (vlc_object_t *obj) ...@@ -283,6 +256,36 @@ static int Open (vlc_object_t *obj)
} }
} }
/* Choose the IEC device for S/PDIF output:
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. */
if (spdif && !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
{
unsigned aes3;
switch (p_aout->output.output.i_rate)
{
#define FS(freq) \
case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
FS( 44100) /* def. */ FS( 48000) FS( 32000)
FS( 22050) FS( 24000)
FS( 88200) FS(768000) FS( 96000)
FS(176400) FS(192000)
#undef FS
default:
aes3 = IEC958_AES3_CON_FS_NOTID;
break;
}
free (psz_device);
if (asprintf (&psz_device,
"iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
0, aes3) == -1)
return VLC_ENOMEM;
}
/* Allocate structures */ /* Allocate structures */
aout_sys_t *p_sys = malloc (sizeof (*p_sys)); aout_sys_t *p_sys = malloc (sizeof (*p_sys));
if (unlikely(p_sys == NULL)) if (unlikely(p_sys == NULL))
...@@ -339,7 +342,7 @@ static int Open (vlc_object_t *obj) ...@@ -339,7 +342,7 @@ static int Open (vlc_object_t *obj)
snd_pcm_uframes_t i_period_size; snd_pcm_uframes_t i_period_size;
int i_channels; int i_channels;
if (var_InheritBool (obj, "spdif")) if (spdif)
{ {
fourcc = VLC_CODEC_SPDIFL; fourcc = VLC_CODEC_SPDIFL;
i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; i_buffer_size = ALSA_SPDIF_BUFFER_SIZE;
......
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