From 217545542d79137d9ce42ad8fed8376db682feba Mon Sep 17 00:00:00 2001 From: Johns Date: Mon, 23 Jan 2012 20:23:05 +0100 Subject: Add ac3 pass-through device to OSS module. --- audio.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'audio.c') diff --git a/audio.c b/audio.c index 0b12610..0f27915 100644 --- a/audio.c +++ b/audio.c @@ -1442,25 +1442,41 @@ static void OssThreadFlushBuffers(void) //---------------------------------------------------------------------------- /** -** Initialize OSS pcm device. +** Open OSS pcm device. ** -** @see AudioPCMDevice +** @param use_ac3 use ac3/pass-through device */ -static void OssInitPCM(void) +static int OssOpenPCM(int use_ac3) { const char *device; int fildes; - if (!(device = AudioPCMDevice)) { - if (!(device = getenv("OSS_AUDIODEV"))) { - device = "/dev/dsp"; - } + // &&|| hell + if (!(use_ac3 && ((device = AudioAC3Device) + || (device = getenv("OSS_AC3_AUDIODEV")))) + && !(device = AudioPCMDevice) && !(device = getenv("OSS_AUDIODEV"))) { + device = "/dev/dsp"; } + Debug(3, "audio/oss: &&|| hell '%s'\n", device); + if ((fildes = open(device, O_WRONLY)) < 0) { Error(_("audio/oss: can't open dsp device '%s': %s\n"), device, strerror(errno)); - return; + return -1; } + return fildes; +} + +/** +** Initialize OSS pcm device. +** +** @see AudioPCMDevice +*/ +static void OssInitPCM(void) +{ + int fildes; + + fildes = OssOpenPCM(0); OssPcmFildes = fildes; } @@ -1601,8 +1617,7 @@ static uint64_t OssGetDelay(void) ** ** @todo audio changes must be queued and done when the buffer is empty */ -static int OssSetup(int *freq, int *channels, __attribute__ ((unused)) - int use_ac3) +static int OssSetup(int *freq, int *channels, int use_ac3) { int ret; int tmp; @@ -1613,6 +1628,18 @@ static int OssSetup(int *freq, int *channels, __attribute__ ((unused)) // flush any buffered data AudioFlushBuffers(); + if (1) { // close+open for pcm / ac3 + int fildes; + + fildes = OssPcmFildes; + OssPcmFildes = -1; + close(fildes); + if (!(fildes = OssOpenPCM(use_ac3))) { + return -1; + } + OssPcmFildes = fildes; + } + ret = 0; tmp = AFMT_S16_NE; // native 16 bits @@ -1701,8 +1728,6 @@ static int OssSetup(int *freq, int *channels, __attribute__ ((unused)) /** ** Initialize OSS audio output module. -** -** @param use_ac3 use ac3/pass-through device */ static void OssInit(void) { -- cgit v1.2.3