spark audio: add support for channel specific volume

Origin commit data
------------------
Branch: master
Commit: d03f3c8fee
Author: martii <you@example.com>
Date: 2012-07-13 (Fri, 13 Jul 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2012-07-13 16:24:18 +02:00
parent cc553ad6bf
commit 87bb5d5410
2 changed files with 46 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ cAudio::cAudio(void *, void *, void *)
mixer_fd = -1; mixer_fd = -1;
openDevice(); openDevice();
Muted = false; Muted = false;
#ifdef MARTII
percent = 100;
#endif
} }
cAudio::~cAudio(void) 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); lt_debug("%s(%d, %d)\n", __func__, left, right);
volume = (left + right) / 2; volume = (left + right) / 2;
#ifdef MARTII
int v = map_volume((volume * percent)/100);
#else
int v = map_volume(volume); int v = map_volume(volume);
#endif
if (clipfd != -1 && mixer_fd != -1) { if (clipfd != -1 && mixer_fd != -1) {
int tmp = 0; int tmp = 0;
/* not sure if left / right is correct here, but it is always the same anyways ;-) */ /* 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); lt_info("%s: MIXER_WRITE(%d),%04x: %m\n", __func__, mixer_num, tmp);
return ret; return ret;
} }
#ifndef MARTII
/* compensate for different decoding volume of mpeg and ac3 streams /* compensate for different decoding volume of mpeg and ac3 streams
* TODO: check if this is correct for all channels * TODO: check if this is correct for all channels
* and if we need to do something with DTS? */ * and if we need to do something with DTS? */
if (StreamType == AUDIO_FMT_MPEG) if (StreamType == AUDIO_FMT_MPEG)
v = map_volume(volume * 30 / 53); v = map_volume(volume * 30 / 53);
#endif
char str[4]; char str[4];
sprintf(str, "%d", v); sprintf(str, "%d", v);
@@ -144,10 +153,18 @@ int cAudio::Stop(void)
return ioctl(fd, AUDIO_STOP); 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*/) bool cAudio::Pause(bool /*Pcm*/)
{ {
return true; return true;
}; };
#endif
void cAudio::SetSyncMode(AVSYNC_TYPE Mode) void cAudio::SetSyncMode(AVSYNC_TYPE Mode)
{ {
@@ -167,7 +184,9 @@ void cAudio::SetSyncMode(AVSYNC_TYPE Mode)
void cAudio::SetStreamType(AUDIO_FORMAT type) void cAudio::SetStreamType(AUDIO_FORMAT type)
{ {
int bypass = AUDIO_STREAMTYPE_MPEG; int bypass = AUDIO_STREAMTYPE_MPEG;
#ifndef MARTII
bool update_volume = (StreamType != type); bool update_volume = (StreamType != type);
#endif
lt_debug("%s %d\n", __FUNCTION__, type); lt_debug("%s %d\n", __FUNCTION__, type);
StreamType = type; StreamType = type;
@@ -175,7 +194,7 @@ void cAudio::SetStreamType(AUDIO_FORMAT type)
{ {
case AUDIO_FMT_DOLBY_DIGITAL: case AUDIO_FMT_DOLBY_DIGITAL:
bypass = AUDIO_STREAMTYPE_AC3; bypass = AUDIO_STREAMTYPE_AC3;
break; break;
case AUDIO_FMT_DTS: case AUDIO_FMT_DTS:
bypass = AUDIO_STREAMTYPE_DTS; bypass = AUDIO_STREAMTYPE_DTS;
break; 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 // But as we implemented the behavior to bypass (cause of e2) this is correct here
if (ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass) < 0) if (ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass) < 0)
lt_info("%s: AUDIO_SET_BYPASS_MODE failed (%m)\n", __func__); lt_info("%s: AUDIO_SET_BYPASS_MODE failed (%m)\n", __func__);
#ifndef MARTII
if (update_volume) if (update_volume)
setVolume(volume, volume); setVolume(volume, volume);
#endif
}; };
int cAudio::setChannel(int channel) int cAudio::setChannel(int channel)
@@ -411,3 +432,20 @@ 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]));
} }
#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

View File

@@ -56,6 +56,9 @@ class cAudio
int do_mute(bool enable, bool remember); int do_mute(bool enable, bool remember);
void setBypassMode(bool disable); void setBypassMode(bool disable);
#ifdef MARTII
int percent;
#endif
public: public:
/* construct & destruct */ /* construct & destruct */
cAudio(void *, void *, void *); cAudio(void *, void *, void *);
@@ -91,6 +94,10 @@ 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);
#ifdef MARTII
int getPercent(void);
int setPercent(int perc);
#endif
}; };
#endif #endif