summaryrefslogtreecommitdiff
path: root/audio.c
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-01-23 20:23:05 +0100
committerJohns <johns98@gmx.net>2012-01-23 20:23:05 +0100
commit217545542d79137d9ce42ad8fed8376db682feba (patch)
tree818ac4f57d8ebbaa00ce54b70c59dcd0bdb47d13 /audio.c
parent5f43803236e9ce08dba301bbdea67fb88c208950 (diff)
downloadvdr-plugin-softhddevice-217545542d79137d9ce42ad8fed8376db682feba.tar.gz
vdr-plugin-softhddevice-217545542d79137d9ce42ad8fed8376db682feba.tar.bz2
Add ac3 pass-through device to OSS module.
Diffstat (limited to 'audio.c')
-rw-r--r--audio.c49
1 files changed, 37 insertions, 12 deletions
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)
{