mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
formatting code using astyle
Origin commit data
------------------
Branch: master
Commit: bc17c13de4
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-05-17 (Mon, 17 May 2021)
Origin message was:
------------------
- formatting code using astyle
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -14,18 +14,19 @@
|
||||
#include "audio_mixer.h"
|
||||
#include "hal_debug.h"
|
||||
|
||||
#define AUDIO_DEVICE "/dev/dvb/adapter0/audio0"
|
||||
#define AUDIO_DEVICE "/dev/dvb/adapter0/audio0"
|
||||
#define hal_debug(args...) _hal_debug(HAL_DEBUG_AUDIO, this, args)
|
||||
#define hal_info(args...) _hal_info(HAL_DEBUG_AUDIO, this, args)
|
||||
|
||||
#include <linux/soundcard.h>
|
||||
|
||||
enum
|
||||
{ ENCODER,
|
||||
{
|
||||
ENCODER,
|
||||
AUX
|
||||
};
|
||||
|
||||
cAudio * audioDecoder = NULL;
|
||||
cAudio *audioDecoder = NULL;
|
||||
|
||||
cAudio::cAudio(void *, void *, void *)
|
||||
{
|
||||
@@ -66,15 +67,18 @@ void cAudio::closeDevice(void)
|
||||
{
|
||||
closeMixers();
|
||||
|
||||
if (fd > -1) {
|
||||
if (fd > -1)
|
||||
{
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
if (clipfd > -1) {
|
||||
if (clipfd > -1)
|
||||
{
|
||||
close(clipfd);
|
||||
clipfd = -1;
|
||||
}
|
||||
if (mixer_fd > -1) {
|
||||
if (mixer_fd > -1)
|
||||
{
|
||||
close(mixer_fd);
|
||||
mixer_fd = -1;
|
||||
}
|
||||
@@ -124,7 +128,8 @@ int cAudio::setVolume(unsigned int left, unsigned int right)
|
||||
volume = (left + right) / 2;
|
||||
int v = map_volume(volume);
|
||||
#if 0
|
||||
if (clipfd != -1 && mixer_fd != -1) {
|
||||
if (clipfd != -1 && mixer_fd != -1)
|
||||
{
|
||||
int tmp = 0;
|
||||
/* not sure if left / right is correct here, but it is always the same anyways ;-) */
|
||||
if (! Muted)
|
||||
@@ -190,7 +195,8 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
|
||||
const char *dsp_dev = getenv("DSP_DEVICE");
|
||||
const char *mix_dev = getenv("MIX_DEVICE");
|
||||
hal_debug("%s ch %d srate %d bits %d le %d\n", __FUNCTION__, ch, srate, bits, little_endian);
|
||||
if (clipfd > -1) {
|
||||
if (clipfd > -1)
|
||||
{
|
||||
hal_info("%s: clipfd already opened (%d)\n", __FUNCTION__, clipfd);
|
||||
return -1;
|
||||
}
|
||||
@@ -203,16 +209,18 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
|
||||
* export MIX_DEVICE=/dev/sound/mixer2
|
||||
* neutrino
|
||||
*/
|
||||
if ((!dsp_dev) || (access(dsp_dev, W_OK))) {
|
||||
if ((!dsp_dev) || (access(dsp_dev, W_OK)))
|
||||
{
|
||||
if (dsp_dev)
|
||||
hal_info("%s: DSP_DEVICE is set (%s) but cannot be opened,"
|
||||
" fall back to /dev/dsp1\n", __func__, dsp_dev);
|
||||
" fall back to /dev/dsp1\n", __func__, dsp_dev);
|
||||
dsp_dev = "/dev/dsp1";
|
||||
}
|
||||
hal_info("%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */
|
||||
/* the tdoss dsp driver seems to work only on the second open(). really. */
|
||||
clipfd = open(dsp_dev, O_WRONLY);
|
||||
if (clipfd < 0) {
|
||||
if (clipfd < 0)
|
||||
{
|
||||
hal_info("%s open %s: %m\n", dsp_dev, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
@@ -235,42 +243,50 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
|
||||
return 0;
|
||||
|
||||
mixer_fd = open(mix_dev, O_RDWR);
|
||||
if (mixer_fd < 0) {
|
||||
if (mixer_fd < 0)
|
||||
{
|
||||
hal_info("%s: open mixer %s failed (%m)\n", __func__, mix_dev);
|
||||
/* not a real error */
|
||||
return 0;
|
||||
}
|
||||
if (ioctl(mixer_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) {
|
||||
if (ioctl(mixer_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1)
|
||||
{
|
||||
hal_info("%s: SOUND_MIXER_READ_DEVMASK %m\n", __func__);
|
||||
devmask = 0;
|
||||
}
|
||||
if (ioctl(mixer_fd, SOUND_MIXER_READ_STEREODEVS, &stereo) == -1) {
|
||||
if (ioctl(mixer_fd, SOUND_MIXER_READ_STEREODEVS, &stereo) == -1)
|
||||
{
|
||||
hal_info("%s: SOUND_MIXER_READ_STEREODEVS %m\n", __func__);
|
||||
stereo = 0;
|
||||
}
|
||||
usable = devmask & stereo;
|
||||
if (usable == 0) {
|
||||
if (usable == 0)
|
||||
{
|
||||
hal_info("%s: devmask: %08x stereo: %08x, no usable dev :-(\n",
|
||||
__func__, devmask, stereo);
|
||||
__func__, devmask, stereo);
|
||||
close(mixer_fd);
|
||||
mixer_fd = -1;
|
||||
return 0; /* TODO: should we treat this as error? */
|
||||
}
|
||||
/* __builtin_popcount needs GCC, it counts the set bits... */
|
||||
if (__builtin_popcount (usable) != 1) {
|
||||
if (__builtin_popcount(usable) != 1)
|
||||
{
|
||||
/* TODO: this code is not yet tested as I have only single-mixer devices... */
|
||||
hal_info("%s: more than one mixer control: devmask %08x stereo %08x\n"
|
||||
"%s: querying MIX_NUMBER environment variable...\n",
|
||||
__func__, devmask, stereo, __func__);
|
||||
"%s: querying MIX_NUMBER environment variable...\n",
|
||||
__func__, devmask, stereo, __func__);
|
||||
const char *tmp = getenv("MIX_NUMBER");
|
||||
if (tmp)
|
||||
mixer_num = atoi(tmp);
|
||||
hal_info("%s: mixer_num is %d -> device %08x\n",
|
||||
__func__, mixer_num, (mixer_num >= 0) ? (1 << mixer_num) : 0);
|
||||
__func__, mixer_num, (mixer_num >= 0) ? (1 << mixer_num) : 0);
|
||||
/* no error checking, you'd better know what you are doing... */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mixer_num = 0;
|
||||
while (!(usable & 0x01)) {
|
||||
while (!(usable & 0x01))
|
||||
{
|
||||
mixer_num++;
|
||||
usable >>= 1;
|
||||
}
|
||||
@@ -284,7 +300,8 @@ int cAudio::WriteClip(unsigned char *buffer, int size)
|
||||
{
|
||||
int ret;
|
||||
// hal_debug("cAudio::%s\n", __FUNCTION__);
|
||||
if (clipfd < 0) {
|
||||
if (clipfd < 0)
|
||||
{
|
||||
hal_info("%s: clipfd not yet opened\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
@@ -297,13 +314,15 @@ int cAudio::WriteClip(unsigned char *buffer, int size)
|
||||
int cAudio::StopClip()
|
||||
{
|
||||
hal_debug("%s\n", __FUNCTION__);
|
||||
if (clipfd < 0) {
|
||||
if (clipfd < 0)
|
||||
{
|
||||
hal_info("%s: clipfd not yet opened\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
close(clipfd);
|
||||
clipfd = -1;
|
||||
if (mixer_fd > -1) {
|
||||
if (mixer_fd > -1)
|
||||
{
|
||||
close(mixer_fd);
|
||||
mixer_fd = -1;
|
||||
}
|
||||
@@ -331,24 +350,24 @@ void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &m
|
||||
|
||||
type = atype;
|
||||
#if 0
|
||||
/* this does not work, some of the values are negative?? */
|
||||
/* this does not work, some of the values are negative?? */
|
||||
AMPEGStatus A;
|
||||
memcpy(&A, &i.word00, sizeof(i.word00));
|
||||
layer = A.audio_mpeg_layer;
|
||||
mode = A.audio_mpeg_mode;
|
||||
bitrate = A.audio_mpeg_bitrate;
|
||||
switch(A.audio_mpeg_frequency)
|
||||
switch (A.audio_mpeg_frequency)
|
||||
#endif
|
||||
/* layer and bitrate are not used anyway... */
|
||||
layer = 0; //(i.word00 >> 17) & 3;
|
||||
/* layer and bitrate are not used anyway... */
|
||||
layer = 0; //(i.word00 >> 17) & 3;
|
||||
bitrate = 0; //(i.word00 >> 12) & 3;
|
||||
switch (type)
|
||||
{
|
||||
case 0: /* MPEG */
|
||||
case 0: /* MPEG */
|
||||
mode = (i.word00 >> 6) & 3;
|
||||
freq = freq_mpg[(i.word00 >> 10) & 3];
|
||||
break;
|
||||
case 1: /* AC3 */
|
||||
case 1: /* AC3 */
|
||||
mode = (i.word00 >> 28) & 7;
|
||||
freq = freq_ac3[(i.word00 >> 16) & 3];
|
||||
break;
|
||||
@@ -417,17 +436,20 @@ void cAudio::closeMixers(void)
|
||||
|
||||
void cAudio::setMixerVolume(const char *name, long value, bool remember)
|
||||
{
|
||||
if (!strcmp(name, "Analog")) {
|
||||
if (!strcmp(name, "Analog"))
|
||||
{
|
||||
mixerAnalog->setVolume(value);
|
||||
if (remember)
|
||||
volumeAnalog = value;
|
||||
}
|
||||
if (!strcmp(name, "HDMI")) {
|
||||
if (!strcmp(name, "HDMI"))
|
||||
{
|
||||
mixerHDMI->setVolume(value);
|
||||
if (remember)
|
||||
volumeHDMI = value;
|
||||
}
|
||||
if (!strcmp(name, "SPDIF")) {
|
||||
if (!strcmp(name, "SPDIF"))
|
||||
{
|
||||
mixerSPDIF->setVolume(value);
|
||||
if (remember)
|
||||
volumeSPDIF = value;
|
||||
@@ -436,12 +458,15 @@ void cAudio::setMixerVolume(const char *name, long value, bool remember)
|
||||
|
||||
void cAudio::muteMixers(bool m)
|
||||
{
|
||||
if (m && !mixersMuted) {
|
||||
if (m && !mixersMuted)
|
||||
{
|
||||
mixersMuted = true;
|
||||
setMixerVolume("Analog", 0, false);
|
||||
setMixerVolume("HDMI", 0, false);
|
||||
setMixerVolume("SPDIF", 0, false);
|
||||
} else if (!m && mixersMuted) {
|
||||
}
|
||||
else if (!m && mixersMuted)
|
||||
{
|
||||
mixersMuted = false;
|
||||
setMixerVolume("Analog", volumeAnalog, false);
|
||||
setMixerVolume("HDMI", volumeHDMI, false);
|
||||
|
Reference in New Issue
Block a user