mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
spark audio: add support for channel specific volume
This commit is contained in:
@@ -37,6 +37,9 @@ cAudio::cAudio(void *, void *, void *)
|
||||
mixer_fd = -1;
|
||||
openDevice();
|
||||
Muted = false;
|
||||
#ifdef MARTII
|
||||
percent = 100;
|
||||
#endif
|
||||
}
|
||||
|
||||
cAudio::~cAudio(void)
|
||||
@@ -108,7 +111,11 @@ int cAudio::setVolume(unsigned int left, unsigned int right)
|
||||
lt_debug("%s(%d, %d)\n", __func__, left, right);
|
||||
|
||||
volume = (left + right) / 2;
|
||||
#ifdef MARTII
|
||||
int v = map_volume((volume * percent)/100);
|
||||
#else
|
||||
int v = map_volume(volume);
|
||||
#endif
|
||||
if (clipfd != -1 && mixer_fd != -1) {
|
||||
int tmp = 0;
|
||||
/* not sure if left / right is correct here, but it is always the same anyways ;-) */
|
||||
@@ -119,11 +126,13 @@ int cAudio::setVolume(unsigned int left, unsigned int right)
|
||||
lt_info("%s: MIXER_WRITE(%d),%04x: %m\n", __func__, mixer_num, tmp);
|
||||
return ret;
|
||||
}
|
||||
#ifndef MARTII
|
||||
/* compensate for different decoding volume of mpeg and ac3 streams
|
||||
* TODO: check if this is correct for all channels
|
||||
* and if we need to do something with DTS? */
|
||||
if (StreamType == AUDIO_FMT_MPEG)
|
||||
v = map_volume(volume * 30 / 53);
|
||||
#endif
|
||||
|
||||
char str[4];
|
||||
sprintf(str, "%d", v);
|
||||
@@ -144,10 +153,18 @@ int cAudio::Stop(void)
|
||||
return ioctl(fd, AUDIO_STOP);
|
||||
}
|
||||
|
||||
#ifdef MARTII
|
||||
bool cAudio::Pause(bool Pcm)
|
||||
{
|
||||
ioctl(fd, Pcm ? AUDIO_PAUSE : AUDIO_CONTINUE, 1);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool cAudio::Pause(bool /*Pcm*/)
|
||||
{
|
||||
return true;
|
||||
};
|
||||
#endif
|
||||
|
||||
void cAudio::SetSyncMode(AVSYNC_TYPE Mode)
|
||||
{
|
||||
@@ -167,7 +184,9 @@ void cAudio::SetSyncMode(AVSYNC_TYPE Mode)
|
||||
void cAudio::SetStreamType(AUDIO_FORMAT type)
|
||||
{
|
||||
int bypass = AUDIO_STREAMTYPE_MPEG;
|
||||
#ifndef MARTII
|
||||
bool update_volume = (StreamType != type);
|
||||
#endif
|
||||
lt_debug("%s %d\n", __FUNCTION__, type);
|
||||
StreamType = type;
|
||||
|
||||
@@ -175,7 +194,7 @@ void cAudio::SetStreamType(AUDIO_FORMAT type)
|
||||
{
|
||||
case AUDIO_FMT_DOLBY_DIGITAL:
|
||||
bypass = AUDIO_STREAMTYPE_AC3;
|
||||
break;
|
||||
break;
|
||||
case AUDIO_FMT_DTS:
|
||||
bypass = AUDIO_STREAMTYPE_DTS;
|
||||
break;
|
||||
@@ -188,8 +207,10 @@ void cAudio::SetStreamType(AUDIO_FORMAT type)
|
||||
// But as we implemented the behavior to bypass (cause of e2) this is correct here
|
||||
if (ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass) < 0)
|
||||
lt_info("%s: AUDIO_SET_BYPASS_MODE failed (%m)\n", __func__);
|
||||
#ifndef MARTII
|
||||
if (update_volume)
|
||||
setVolume(volume, volume);
|
||||
#endif
|
||||
};
|
||||
|
||||
int cAudio::setChannel(int channel)
|
||||
@@ -411,3 +432,20 @@ void cAudio::setBypassMode(bool disable)
|
||||
lt_debug("%s %d\n", __func__, disable);
|
||||
proc_put("/proc/stb/audio/ac3", opt[disable], strlen(opt[disable]));
|
||||
}
|
||||
|
||||
#ifdef MARTII
|
||||
int cAudio::getPercent(void) {
|
||||
return percent;
|
||||
}
|
||||
|
||||
int cAudio::setPercent(int perc) {
|
||||
lt_debug("%s %d (muted: %d)\n", __func__, perc, Muted);
|
||||
int old_percent = percent;
|
||||
percent = perc;
|
||||
if (percent < 0 || percent > 999)
|
||||
percent = 100;
|
||||
if(!Muted)
|
||||
setVolume(volume, volume);
|
||||
return old_percent;
|
||||
}
|
||||
#endif
|
||||
|
@@ -56,6 +56,9 @@ class cAudio
|
||||
|
||||
int do_mute(bool enable, bool remember);
|
||||
void setBypassMode(bool disable);
|
||||
#ifdef MARTII
|
||||
int percent;
|
||||
#endif
|
||||
public:
|
||||
/* construct & destruct */
|
||||
cAudio(void *, void *, void *);
|
||||
@@ -91,6 +94,10 @@ class cAudio
|
||||
void SetSpdifDD(bool enable);
|
||||
void ScheduleMute(bool On);
|
||||
void EnableAnalogOut(bool enable);
|
||||
#ifdef MARTII
|
||||
int getPercent(void);
|
||||
int setPercent(int perc);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user