summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-09 01:30:02 +0100
committerwm4 <wm4@nowhere>2013-11-09 01:30:02 +0100
commit3af094062ef95b6fd004c58bd8cd9ea204f59105 (patch)
treecb0047624ccf124983065837c278ae454bb9c4c7 /audio
parentd240aa367ed308fdfbc1f5c6419ef4b1281fd1df (diff)
downloadmpv-3af094062ef95b6fd004c58bd8cd9ea204f59105.tar.bz2
mpv-3af094062ef95b6fd004c58bd8cd9ea204f59105.tar.xz
ao_alsa: add magic spdif parameters
I have no idea what these do, but apparently they are needed to inform ALSA about spdif configuration. First, replace the literal constant "6" for the AES0 parameter with the symbolic constants from the ALSA headers (the final value is the same). Second, copy paste some funky looking parameter setup from VLC's alsa output for setting the AES1, AES2, AES3 parameters. (The code is actually not literally copy-pasted, but does exactly the same.) My small but non-zero hope is that this could make DTS-HD work, or at least work into that direction. I can't test spdif stuff though, and for DTS-HD not even opening the ALSA device succeeds on my system.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_alsa.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 05f9e89803..2d8587a28c 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -304,6 +304,26 @@ static const char *select_chmap(struct ao *ao)
return "default";
}
+static int map_iec958_srate(int srate)
+{
+ switch (srate) {
+ case 192000: return IEC958_AES4_CON_ORIGFS_192000;
+ case 12000: return IEC958_AES4_CON_ORIGFS_12000;
+ case 176400: return IEC958_AES4_CON_ORIGFS_176400;
+ case 96000: return IEC958_AES4_CON_ORIGFS_96000;
+ case 8000: return IEC958_AES4_CON_ORIGFS_8000;
+ case 88200: return IEC958_AES4_CON_ORIGFS_88200;
+ case 16000: return IEC958_AES4_CON_ORIGFS_16000;
+ case 24000: return IEC958_AES4_CON_ORIGFS_24000;
+ case 11025: return IEC958_AES4_CON_ORIGFS_11025;
+ case 22050: return IEC958_AES4_CON_ORIGFS_22050;
+ case 32000: return IEC958_AES4_CON_ORIGFS_32000;
+ case 48000: return IEC958_AES4_CON_ORIGFS_48000;
+ case 44100: return IEC958_AES4_CON_ORIGFS_44100;
+ default: return IEC958_AES4_CON_ORIGFS_NOTID;
+ }
+}
+
static int try_open_device(struct ao *ao, const char *device, int open_mode)
{
struct priv *p = ao->priv;
@@ -311,7 +331,11 @@ static int try_open_device(struct ao *ao, const char *device, int open_mode)
if (AF_FORMAT_IS_IEC61937(ao->format)) {
void *tmp = talloc_new(NULL);
/* to set the non-audio bit, use AES0=6 */
- char *params = "AES0=6";
+ char *params = talloc_asprintf(tmp,
+ "AES0=%d,AES1=%d,AES2=0,AES3=%d",
+ IEC958_AES0_NONAUDIO | IEC958_AES0_PRO_EMPHASIS_NONE,
+ IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
+ map_iec958_srate(ao->samplerate));
const char *ac3_device = device;
int len = strlen(device);
char *end = strchr(device, ':');