summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.txt2
-rw-r--r--audio.c49
2 files changed, 39 insertions, 12 deletions
diff --git a/README.txt b/README.txt
index 108cb10..b80cb6f 100644
--- a/README.txt
+++ b/README.txt
@@ -88,6 +88,8 @@ Setup: environment
only if oss is configured
OSS_AUDIODEV=/dev/dsp
oss dsp device name
+ OSS_AC3_AUDIODEV=
+ oss AC3/pass-though device name
OSS_MIXERDEV=/dev/mixer
oss mixer device name
OSS_MIXER_CHANNEL=pcm
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)
{