mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
libspark/audio: add mixer access methods
Origin commit data
------------------
Branch: master
Commit: 656aef8328
Author: martii <m4rtii@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 <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <algorithm>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <linux/dvb/audio.h>
|
#include <linux/dvb/audio.h>
|
||||||
#include "audio_lib.h"
|
#include "audio_lib.h"
|
||||||
|
#include "audio_mixer.h"
|
||||||
#include "lt_debug.h"
|
#include "lt_debug.h"
|
||||||
|
|
||||||
#define AUDIO_DEVICE "/dev/dvb/adapter0/audio0"
|
#define AUDIO_DEVICE "/dev/dvb/adapter0/audio0"
|
||||||
@@ -35,17 +37,25 @@ cAudio::cAudio(void *, void *, void *)
|
|||||||
fd = -1;
|
fd = -1;
|
||||||
clipfd = -1;
|
clipfd = -1;
|
||||||
mixer_fd = -1;
|
mixer_fd = -1;
|
||||||
|
|
||||||
|
mixerAnalog = mixerHDMI = mixerSPDIF = NULL;
|
||||||
|
volumeAnalog = volumeHDMI = volumeSPDIF = 0;
|
||||||
|
mixersMuted = false;
|
||||||
|
|
||||||
openDevice();
|
openDevice();
|
||||||
Muted = false;
|
Muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cAudio::~cAudio(void)
|
cAudio::~cAudio(void)
|
||||||
{
|
{
|
||||||
|
closeMixers();
|
||||||
closeDevice();
|
closeDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cAudio::openDevice(void)
|
void cAudio::openDevice(void)
|
||||||
{
|
{
|
||||||
|
openMixers();
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
||||||
@@ -59,6 +69,8 @@ void cAudio::openDevice(void)
|
|||||||
|
|
||||||
void cAudio::closeDevice(void)
|
void cAudio::closeDevice(void)
|
||||||
{
|
{
|
||||||
|
closeMixers();
|
||||||
|
|
||||||
if (fd > -1) {
|
if (fd > -1) {
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@@ -414,3 +426,55 @@ void cAudio::setBypassMode(bool disable)
|
|||||||
lt_debug("%s %d\n", __func__, disable);
|
lt_debug("%s %d\n", __func__, disable);
|
||||||
proc_put("/proc/stb/audio/ac3", opt[disable], strlen(opt[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_FMT_ADVANCED = AUDIO_FMT_MLP
|
||||||
} AUDIO_FORMAT;
|
} AUDIO_FORMAT;
|
||||||
|
|
||||||
|
class mixerVolume;
|
||||||
|
|
||||||
class cAudio
|
class cAudio
|
||||||
{
|
{
|
||||||
friend class cPlayback;
|
friend class cPlayback;
|
||||||
@@ -57,6 +59,11 @@ class cAudio
|
|||||||
|
|
||||||
int do_mute(bool enable, bool remember);
|
int do_mute(bool enable, bool remember);
|
||||||
void setBypassMode(bool disable);
|
void setBypassMode(bool disable);
|
||||||
|
|
||||||
|
mixerVolume *mixerAnalog, *mixerHDMI, *mixerSPDIF;
|
||||||
|
int volumeAnalog, volumeHDMI, volumeSPDIF;
|
||||||
|
bool mixersMuted;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* construct & destruct */
|
/* construct & destruct */
|
||||||
cAudio(void *, void *, void *);
|
cAudio(void *, void *, void *);
|
||||||
@@ -92,7 +99,11 @@ class cAudio
|
|||||||
void SetSpdifDD(bool enable);
|
void SetSpdifDD(bool enable);
|
||||||
void ScheduleMute(bool On);
|
void ScheduleMute(bool On);
|
||||||
void EnableAnalogOut(bool enable);
|
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
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user