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/06/17 05:04:36 UTC

[incubator-nuttx-apps] branch master updated: system: nxrecorder: Refactor nxrecorder.c

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 fed7a53  system: nxrecorder: Refactor nxrecorder.c
fed7a53 is described below

commit fed7a53ef54980ddcb9263bd9cf2a43e5b8b8d9e
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Wed Jun 17 10:22:37 2020 +0900

    system: nxrecorder: Refactor nxrecorder.c
    
    NOTE: Remove redundant code regarding audio buffer configuration
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 system/nxrecorder/nxrecorder.c | 50 +-----------------------------------------
 1 file changed, 1 insertion(+), 49 deletions(-)

diff --git a/system/nxrecorder/nxrecorder.c b/system/nxrecorder/nxrecorder.c
index 1768c16..170e9e0 100644
--- a/system/nxrecorder/nxrecorder.c
+++ b/system/nxrecorder/nxrecorder.c
@@ -64,14 +64,6 @@
 #define NXRECORDER_STATE_RECORDING 1
 #define NXRECORDER_STATE_PAUSED    2
 
-#ifndef CONFIG_AUDIO_NUM_BUFFERS
-#  define CONFIG_AUDIO_NUM_BUFFERS  2
-#endif
-
-#ifndef CONFIG_AUDIO_BUFFER_NUMBYTES
-#  define CONFIG_AUDIO_BUFFER_NUMBYTES  8192
-#endif
-
 #ifndef CONFIG_NXRECORDER_MSG_PRIO
 #  define CONFIG_NXRECORDER_MSG_PRIO  1
 #endif
@@ -253,12 +245,8 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
   bool                        running = true;
   bool                        streaming = true;
   bool                        failed = false;
-#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
   struct ap_buffer_info_s     buf_info;
   FAR struct ap_buffer_s      **pbuffers;
-#else
-  FAR struct ap_buffer_s      *pbuffers[CONFIG_AUDIO_NUM_BUFFERS];
-#endif
   unsigned int                prio;
 #ifdef CONFIG_DEBUG_FEATURES
   int                         outstanding = 0;
@@ -270,7 +258,6 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
 
   /* Query the audio device for it's preferred buffer size / qty */
 
-#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
   if ((ret = ioctl(precorder->dev_fd, AUDIOIOC_GETBUFFERINFO,
           (unsigned long) &buf_info)) != OK)
     {
@@ -301,26 +288,14 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
     }
 
   for (x = 0; x < buf_info.nbuffers; x++)
-#else /* CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFER */
-
-  for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
-    {
-      pbuffers[x] = NULL;
-    }
-
-  for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
-#endif /* CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFER */
     {
       /* Fill in the buffer descriptor struct to issue an alloc request */
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
       buf_desc.session = precorder->session;
 #endif
-#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
+
       buf_desc.numbytes = buf_info.buffer_size;
-#else
-      buf_desc.numbytes = CONFIG_AUDIO_BUFFER_NUMBYTES;
-#endif
       buf_desc.u.pbuffer = &pbuffers[x];
 
       ret = ioctl(precorder->dev_fd, AUDIOIOC_ALLOCBUFFER,
@@ -337,11 +312,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
 
   /* Fill up the pipeline with enqueued buffers */
 
-#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
   for (x = 0; x < buf_info.nbuffers; x++)
-#else
-  for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
-#endif
     {
       /* Write the next buffer of data */
 
@@ -563,7 +534,6 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
 err_out:
   audinfo("Clean-up and exit\n");
 
-#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
   if (pbuffers != NULL)
     {
       audinfo("Freeing buffers\n");
@@ -587,24 +557,6 @@ err_out:
 
       free(pbuffers);
     }
-#else
-    audinfo("Freeing buffers\n");
-    for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
-      {
-        /* Fill in the buffer descriptor struct to issue a free request */
-
-        if (pbuffers[x] != NULL)
-          {
-#ifdef CONFIG_AUDIO_MULTI_SESSION
-            buf_desc.session = pplayer->session;
-#endif
-            buf_desc.u.pbuffer = pbuffers[x];
-            ioctl(precorder->dev_fd,
-                  AUDIOIOC_FREEBUFFER,
-                  (unsigned long) &buf_desc);
-          }
-      }
-#endif
 
   /* Unregister the message queue and release the session */