mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
Merge remote-tracking branch 'martiis-libstb-hal/master'
Origin commit data
------------------
Branch: master
Commit: 29a5800ff9
Author: max_10 <max_10@gmx.de>
Date: 2014-06-29 (Sun, 29 Jun 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/dvb/audio.h>
|
||||
#include "audio_lib.h"
|
||||
#include "audio_mixer.h"
|
||||
#include "lt_debug.h"
|
||||
|
||||
#define AUDIO_DEVICE "/dev/dvb/adapter0/audio0"
|
||||
@@ -35,17 +37,25 @@ cAudio::cAudio(void *, void *, void *)
|
||||
fd = -1;
|
||||
clipfd = -1;
|
||||
mixer_fd = -1;
|
||||
|
||||
mixerAnalog = mixerHDMI = mixerSPDIF = NULL;
|
||||
volumeAnalog = volumeHDMI = volumeSPDIF = 0;
|
||||
mixersMuted = false;
|
||||
|
||||
openDevice();
|
||||
Muted = false;
|
||||
}
|
||||
|
||||
cAudio::~cAudio(void)
|
||||
{
|
||||
closeMixers();
|
||||
closeDevice();
|
||||
}
|
||||
|
||||
void cAudio::openDevice(void)
|
||||
{
|
||||
openMixers();
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
||||
@@ -59,6 +69,8 @@ void cAudio::openDevice(void)
|
||||
|
||||
void cAudio::closeDevice(void)
|
||||
{
|
||||
closeMixers();
|
||||
|
||||
if (fd > -1) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
@@ -414,3 +426,55 @@ void cAudio::setBypassMode(bool disable)
|
||||
lt_debug("%s %d\n", __func__, disable);
|
||||
proc_put("/proc/stb/audio/ac3", opt[disable], strlen(opt[disable]));
|
||||
}
|
||||
|
||||
void cAudio::openMixers(void)
|
||||
{
|
||||
if (!mixerAnalog)
|
||||
mixerAnalog = new mixerVolume("Analog", "1");
|
||||
if (!mixerHDMI)
|
||||
mixerHDMI = new mixerVolume("HDMI", "1");
|
||||
if (!mixerSPDIF)
|
||||
mixerSPDIF = new mixerVolume("SPDIF", "1");
|
||||
}
|
||||
|
||||
void cAudio::closeMixers(void)
|
||||
{
|
||||
delete mixerAnalog;
|
||||
delete mixerHDMI;
|
||||
delete mixerSPDIF;
|
||||
mixerAnalog = mixerHDMI = mixerSPDIF = NULL;
|
||||
}
|
||||
|
||||
void cAudio::setMixerVolume(const char *name, long value, bool remember)
|
||||
{
|
||||
if (!strcmp(name, "Analog")) {
|
||||
mixerAnalog->setVolume(value);
|
||||
if (remember)
|
||||
volumeAnalog = value;
|
||||
}
|
||||
if (!strcmp(name, "HDMI")) {
|
||||
mixerHDMI->setVolume(value);
|
||||
if (remember)
|
||||
volumeHDMI = value;
|
||||
}
|
||||
if (!strcmp(name, "SPDIF")) {
|
||||
mixerSPDIF->setVolume(value);
|
||||
if (remember)
|
||||
volumeSPDIF = value;
|
||||
}
|
||||
}
|
||||
|
||||
void cAudio::muteMixers(bool m)
|
||||
{
|
||||
if (m && !mixersMuted) {
|
||||
mixersMuted = true;
|
||||
setMixerVolume("Analog", 0, false);
|
||||
setMixerVolume("HDMI", 0, false);
|
||||
setMixerVolume("SPDIF", 0, false);
|
||||
} else if (!m && mixersMuted) {
|
||||
mixersMuted = false;
|
||||
setMixerVolume("Analog", volumeAnalog, false);
|
||||
setMixerVolume("HDMI", volumeHDMI, false);
|
||||
setMixerVolume("SPDIF", volumeSPDIF, false);
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ typedef enum
|
||||
AUDIO_FMT_ADVANCED = AUDIO_FMT_MLP
|
||||
} AUDIO_FORMAT;
|
||||
|
||||
class mixerVolume;
|
||||
|
||||
class cAudio
|
||||
{
|
||||
friend class cPlayback;
|
||||
@@ -57,6 +59,11 @@ class cAudio
|
||||
|
||||
int do_mute(bool enable, bool remember);
|
||||
void setBypassMode(bool disable);
|
||||
|
||||
mixerVolume *mixerAnalog, *mixerHDMI, *mixerSPDIF;
|
||||
int volumeAnalog, volumeHDMI, volumeSPDIF;
|
||||
bool mixersMuted;
|
||||
|
||||
public:
|
||||
/* construct & destruct */
|
||||
cAudio(void *, void *, void *);
|
||||
@@ -92,7 +99,11 @@ class cAudio
|
||||
void SetSpdifDD(bool enable);
|
||||
void ScheduleMute(bool On);
|
||||
void EnableAnalogOut(bool enable);
|
||||
|
||||
void openMixers(void);
|
||||
void closeMixers(void);
|
||||
void setMixerVolume(const char *name, long value, bool remember = true);
|
||||
void muteMixers(bool m = true);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user