mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
azbox: add O_CLOEXEC to open()
This commit is contained in:
@@ -39,9 +39,8 @@ void cAudio::openDevice(void)
|
|||||||
lt_debug("%s\n", __func__);
|
lt_debug("%s\n", __func__);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0)
|
if ((fd = open(AUDIO_DEVICE, O_RDONLY|O_CLOEXEC)) < 0)
|
||||||
lt_info("openDevice: open failed (%m)\n");
|
lt_info("openDevice: open failed (%m)\n");
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
do_mute(true, false);
|
do_mute(true, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,12 +210,11 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
|
|||||||
}
|
}
|
||||||
lt_info("%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */
|
lt_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. */
|
/* the tdoss dsp driver seems to work only on the second open(). really. */
|
||||||
clipfd = open(dsp_dev, O_WRONLY);
|
clipfd = open(dsp_dev, O_WRONLY|O_CLOEXEC);
|
||||||
if (clipfd < 0) {
|
if (clipfd < 0) {
|
||||||
lt_info("%s open %s: %m\n", dsp_dev, __FUNCTION__);
|
lt_info("%s open %s: %m\n", dsp_dev, __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fcntl(clipfd, F_SETFD, FD_CLOEXEC);
|
|
||||||
/* no idea if we ever get little_endian == 0 */
|
/* no idea if we ever get little_endian == 0 */
|
||||||
if (little_endian)
|
if (little_endian)
|
||||||
fmt = AFMT_S16_BE;
|
fmt = AFMT_S16_BE;
|
||||||
@@ -234,7 +232,7 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
|
|||||||
if (!mix_dev)
|
if (!mix_dev)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mixer_fd = open(mix_dev, O_RDWR);
|
mixer_fd = open(mix_dev, O_RDWR|O_CLOEXEC);
|
||||||
if (mixer_fd < 0) {
|
if (mixer_fd < 0) {
|
||||||
lt_info("%s: open mixer %s failed (%m)\n", __func__, mix_dev);
|
lt_info("%s: open mixer %s failed (%m)\n", __func__, mix_dev);
|
||||||
/* not a real error */
|
/* not a real error */
|
||||||
|
@@ -114,7 +114,7 @@ cDemux::~cDemux()
|
|||||||
bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize)
|
bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize)
|
||||||
{
|
{
|
||||||
int devnum = num;
|
int devnum = num;
|
||||||
int flags = O_RDWR;
|
int flags = O_RDWR|O_CLOEXEC;
|
||||||
if (fd > -1)
|
if (fd > -1)
|
||||||
lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
|
lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
|
||||||
|
|
||||||
@@ -127,7 +127,6 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
|
|||||||
lt_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
lt_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
lt_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
|
lt_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
|
||||||
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ cVideo::cVideo(int, void *, void *)
|
|||||||
|
|
||||||
blank_data = NULL; /* initialize */
|
blank_data = NULL; /* initialize */
|
||||||
blank_size = 0;
|
blank_size = 0;
|
||||||
blankfd = open(blankname, O_RDONLY);
|
blankfd = open(blankname, O_RDONLY|O_CLOEXEC);
|
||||||
if (blankfd < 0)
|
if (blankfd < 0)
|
||||||
lt_info("%s cannot open %s: %m", __func__, blankname);
|
lt_info("%s cannot open %s: %m", __func__, blankname);
|
||||||
else
|
else
|
||||||
@@ -129,7 +129,7 @@ void cVideo::openDevice(void)
|
|||||||
if (fd != -1) /* already open */
|
if (fd != -1) /* already open */
|
||||||
return;
|
return;
|
||||||
retry:
|
retry:
|
||||||
if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0)
|
if ((fd = open(VIDEO_DEVICE, O_RDWR|O_CLOEXEC)) < 0)
|
||||||
{
|
{
|
||||||
if (errno == EBUSY)
|
if (errno == EBUSY)
|
||||||
{
|
{
|
||||||
@@ -140,8 +140,6 @@ retry:
|
|||||||
}
|
}
|
||||||
lt_info("%s cannot open %s: %m, retries %d\n", __func__, VIDEO_DEVICE, n);
|
lt_info("%s cannot open %s: %m, retries %d\n", __func__, VIDEO_DEVICE, n);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
|
||||||
playstate = VIDEO_STOPPED;
|
playstate = VIDEO_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +385,7 @@ void cVideo::ShowPicture(const char * fname)
|
|||||||
what we want. the mutex ensures proper ordering. */
|
what we want. the mutex ensures proper ordering. */
|
||||||
pthread_mutex_lock(&stillp_mutex);
|
pthread_mutex_lock(&stillp_mutex);
|
||||||
|
|
||||||
mfd = open(destname, O_RDONLY);
|
mfd = open(destname, O_RDONLY|O_CLOEXEC);
|
||||||
if (mfd < 0)
|
if (mfd < 0)
|
||||||
{
|
{
|
||||||
lt_info("%s cannot open %s: %m", __func__, destname);
|
lt_info("%s cannot open %s: %m", __func__, destname);
|
||||||
|
Reference in New Issue
Block a user