mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libtriple: use AVS mute to avoid audio pop during boot
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <hardware/tddevices.h>
|
#include <hardware/tddevices.h>
|
||||||
|
#include <avs/avs_inf.h>
|
||||||
#define AUDIO_DEVICE "/dev/" DEVICE_NAME_AUDIO
|
#define AUDIO_DEVICE "/dev/" DEVICE_NAME_AUDIO
|
||||||
#include "audio_td.h"
|
#include "audio_td.h"
|
||||||
#include "lt_debug.h"
|
#include "lt_debug.h"
|
||||||
@@ -37,6 +38,7 @@ void cAudio::openDevice(void)
|
|||||||
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
||||||
lt_info("openDevice: open failed (%m)\n");
|
lt_info("openDevice: open failed (%m)\n");
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
do_mute(true, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lt_info("openDevice: already open (fd = %d)\n", fd);
|
lt_info("openDevice: already open (fd = %d)\n", fd);
|
||||||
@@ -58,6 +60,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);
|
||||||
|
int avsfd;
|
||||||
int ret;
|
int ret;
|
||||||
if (remember)
|
if (remember)
|
||||||
Muted = enable;
|
Muted = enable;
|
||||||
@@ -69,6 +72,15 @@ int cAudio::do_mute(bool enable, bool remember)
|
|||||||
if (clipfd != -1 || mixer_fd != -1)
|
if (clipfd != -1 || mixer_fd != -1)
|
||||||
setVolume(volume,volume); /* considers "Muted" variable, "remember"
|
setVolume(volume,volume); /* considers "Muted" variable, "remember"
|
||||||
is basically always true in this context */
|
is basically always true in this context */
|
||||||
|
avsfd = open("/dev/stb/tdsystem", O_RDONLY);
|
||||||
|
if (avsfd >= 0)
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
ioctl(avsfd, IOC_AVS_SET_VOLUME, 31);
|
||||||
|
else
|
||||||
|
ioctl(avsfd, IOC_AVS_SET_VOLUME, 0);
|
||||||
|
close(avsfd);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@ extern "C" {
|
|||||||
#include <hardware/avs/bios_system_config.h>
|
#include <hardware/avs/bios_system_config.h>
|
||||||
}
|
}
|
||||||
#include "lt_dfbinput.h"
|
#include "lt_dfbinput.h"
|
||||||
|
#include "pwrmngr.h"
|
||||||
|
|
||||||
#include "lt_debug.h"
|
#include "lt_debug.h"
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, NULL, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, NULL, args)
|
||||||
@@ -125,6 +126,9 @@ void init_td_api()
|
|||||||
lt_info("%s begin, initialized=%d, debug=0x%02x\n", __FUNCTION__, (int)initialized, debuglevel);
|
lt_info("%s begin, initialized=%d, debug=0x%02x\n", __FUNCTION__, (int)initialized, debuglevel);
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
|
/* leave standby early, this avoids popping noise on audio device */
|
||||||
|
cCpuFreqManager f;
|
||||||
|
f.SetCpuFreq(0); /* CPUFREQ == 0 is the trigger for leaving standby */
|
||||||
/* DirectFB does setpgid(0,0), which disconnects us from controlling terminal
|
/* DirectFB does setpgid(0,0), which disconnects us from controlling terminal
|
||||||
and thus disables e.g. ctrl-C. work around that. */
|
and thus disables e.g. ctrl-C. work around that. */
|
||||||
pid_t pid = getpgid(0);
|
pid_t pid = getpgid(0);
|
||||||
|
@@ -58,8 +58,10 @@ bool cCpuFreqManager::SetCpuFreq(unsigned long f)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ioctl(fd, IOC_AVS_SET_VOLUME, 31); /* mute AVS to avoid ugly noise */
|
||||||
ioctl(fd, IOC_AVS_STANDBY_LEAVE);
|
ioctl(fd, IOC_AVS_STANDBY_LEAVE);
|
||||||
ioctl(fd, IOC_AVS_SET_VOLUME, 0); /* max gain */
|
/* unmute will be done by cAudio::do_mute(). Ugly, but prevents pops */
|
||||||
|
// ioctl(fd, IOC_AVS_SET_VOLUME, 0); /* max gain */
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Reference in New Issue
Block a user