You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/19 13:56:26 UTC

[incubator-nuttx-apps] branch master updated: system: enable O_CLOEXEC when openning audio device

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f210010  system: enable O_CLOEXEC when openning audio device
f210010 is described below

commit f2100104663704be498179f06bd78adcbe62a809
Author: danguanghua <da...@xiaomi.com>
AuthorDate: Thu Dec 17 20:14:08 2020 +0800

    system: enable O_CLOEXEC when openning audio device
    
    N/A
    
    to avoid multiple open operations of audio_open
    
    Change-Id: Id283def4811c71f3c0bd38dc1a480afce303c4c3
    Signed-off-by: danguanghua <da...@xiaomi.com>
---
 system/nxplayer/nxplayer.c     | 6 +++---
 system/nxrecorder/nxrecorder.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c
index a959b94..d362624 100644
--- a/system/nxplayer/nxplayer.c
+++ b/system/nxplayer/nxplayer.c
@@ -310,7 +310,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
 
       /* Device supports the format.  Open the device file. */
 
-      pplayer->dev_fd = open(pplayer->prefdevice, O_RDWR);
+      pplayer->dev_fd = open(pplayer->prefdevice, O_RDWR | O_CLOEXEC);
       if (pplayer->dev_fd == -1)
         {
           int errcode = errno;
@@ -380,7 +380,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
           snprintf(path,  sizeof(path), "/dev/audio/%s", pdevice->d_name);
 #endif /* CONFIG_AUDIO_CUSTOM_DEV_PATH */
 
-          if ((pplayer->dev_fd = open(path, O_RDWR)) != -1)
+          if ((pplayer->dev_fd = open(path, O_RDWR | O_CLOEXEC)) != -1)
             {
               /* We have the device file open.  Now issue an AUDIO ioctls to
                * get the capabilities
@@ -2367,7 +2367,7 @@ int nxplayer_systemreset(FAR struct nxplayer_s *pplayer)
 #else
       snprintf(path,  sizeof(path), "/dev/audio/%s", pdevice->d_name);
 #endif
-      if ((pplayer->dev_fd = open(path, O_RDWR)) != -1)
+      if ((pplayer->dev_fd = open(path, O_RDWR | O_CLOEXEC)) != -1)
         {
           /* We have the device file open.  Now issue an
            * AUDIO ioctls to perform a HW reset
diff --git a/system/nxrecorder/nxrecorder.c b/system/nxrecorder/nxrecorder.c
index 06f29c2..e60762f 100644
--- a/system/nxrecorder/nxrecorder.c
+++ b/system/nxrecorder/nxrecorder.c
@@ -88,7 +88,7 @@ static int nxrecorder_opendevice(FAR struct nxrecorder_s *precorder)
 
       /* Device supports the format.  Open the device file. */
 
-      precorder->dev_fd = open(precorder->device, O_RDWR);
+      precorder->dev_fd = open(precorder->device, O_RDWR | O_CLOEXEC);
       if (precorder->dev_fd == -1)
         {
           int errcode = errno;