fix mute, sound volume

This commit is contained in:
redblue-pkt
2018-10-04 00:55:37 +02:00
committed by Thilo Graf
parent 2cc698c3ec
commit 5c733a1ac1

View File

@@ -67,6 +67,7 @@ void cAudio::closeDevice(void)
int cAudio::do_mute(bool enable, bool remember) int cAudio::do_mute(bool enable, bool remember)
{ {
lt_debug("%s(%d, %d)\n", __FUNCTION__, enable, remember); lt_debug("%s(%d, %d)\n", __FUNCTION__, enable, remember);
char str[4]; char str[4];
if (remember) if (remember)
@@ -75,14 +76,12 @@ int cAudio::do_mute(bool enable, bool remember)
sprintf(str, "%d", Muted); sprintf(str, "%d", Muted);
proc_put("/proc/stb/audio/j1_mute", str, strlen(str)); proc_put("/proc/stb/audio/j1_mute", str, strlen(str));
if (!enable) if (fd > 0)
{ {
int f = open("/proc/stb/avs/0/volume", O_RDWR); if (ioctl(fd, AUDIO_SET_MUTE, enable) < 0)
read(f, str, 4); perror("AUDIO_SET_MUTE");
close(f);
str[3] = '\0';
proc_put("/proc/stb/avs/0/volume", str, strlen(str));
} }
return 0; return 0;
} }
@@ -102,23 +101,28 @@ int cAudio::setVolume(unsigned int left, unsigned int right)
volume = (left + right) / 2; volume = (left + right) / 2;
int v = map_volume(volume); int v = map_volume(volume);
#if 0
if (clipfd != -1 && mixer_fd != -1) { // convert to -1dB steps
int tmp = 0; left = map_volume(volume);
/* not sure if left / right is correct here, but it is always the same anyways ;-) */ right = map_volume(volume);
if (! Muted) //now range is 63..0, where 0 is loudest
tmp = left << 8 | right;
int ret = ioctl(mixer_fd, MIXER_WRITE(mixer_num), &tmp); audio_mixer_t mixer;
if (ret == -1)
lt_info("%s: MIXER_WRITE(%d),%04x: %m\n", __func__, mixer_num, tmp); mixer.volume_left = left;
return ret; mixer.volume_right = right;
if (fd > 0)
{
if (ioctl(fd, AUDIO_SET_MIXER, &mixer) < 0)
perror("AUDIO_SET_MIXER");
} }
#endif
char str[4]; char str[4];
sprintf(str, "%d", v); sprintf(str, "%d", v);
proc_put("/proc/stb/avs/0/volume", str, strlen(str)); proc_put("/proc/stb/avs/0/volume", str, strlen(str));
return 0; return 0;
} }