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 2021/11/22 09:38:26 UTC

[incubator-nuttx] 06/07: drivers: audio: Use lib header for cxd56 SRC

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.git

commit 6f579b81183ef94ba9247c7494e98a250c1b1cba
Author: Tobias Johansson <to...@sony.com>
AuthorDate: Wed Nov 17 14:48:29 2021 +0100

    drivers: audio: Use lib header for cxd56 SRC
    
    Removes duplicate definitions in header cxd56_src.h and
    includeis the proper library header samplerate.h instead.
    Also corrects some related build issues.
    
    Signed-off-by: Tobias Johansson <to...@sony.com>
---
 drivers/audio/cxd56_src.c | 12 +++++++-----
 drivers/audio/cxd56_src.h | 45 +--------------------------------------------
 2 files changed, 8 insertions(+), 49 deletions(-)

diff --git a/drivers/audio/cxd56_src.c b/drivers/audio/cxd56_src.c
index 9438f3d..88b2031 100644
--- a/drivers/audio/cxd56_src.c
+++ b/drivers/audio/cxd56_src.c
@@ -22,6 +22,7 @@
  * Included Files
  ****************************************************************************/
 
+#include <debug.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <queue.h>
@@ -109,7 +110,7 @@ extern void src_float_to_short_array (const float *in, short *out, int len);
 extern void src_int_to_float_array (const int *in, float *out, int len);
 extern void src_float_to_int_array (const float *in, int *out, int len);
 
-static struct ap_buffer_s *cxd56_src_get_apb()
+static struct ap_buffer_s *cxd56_src_get_apb(void)
 {
   struct ap_buffer_s *src_apb;
   irqstate_t flags;
@@ -199,7 +200,7 @@ static int cxd56_src_process(FAR struct ap_buffer_s *apb)
       int float_in_left;
       int frames_in;
 
-      short *apb_addr = (const short *)(apb->samp + apb->curbyte);
+      const short *apb_addr = (const short *)(apb->samp + apb->curbyte);
 
       /* Fill up incoming float buffer */
 
@@ -426,7 +427,8 @@ int cxd56_src_init(FAR struct cxd56_dev_s *dev,
   g_src.bytewidth = dev->bitwidth / 8;
   g_src.channels = dev->channels;
   g_src.float_in_offset = 0;
-  snprintf(g_src.mqname, sizeof(g_src.mqname), "/tmp/%X", &g_src);
+  snprintf(g_src.mqname, sizeof(g_src.mqname), "/tmp/%X",
+           (unsigned int) &g_src);
 
   audinfo("SRC: Init (rate = %d, channels = %d, width = %d)\n",
           dev->samplerate, g_src.channels, g_src.bytewidth);
@@ -485,7 +487,7 @@ int cxd56_src_init(FAR struct cxd56_dev_s *dev,
   g_src.src_state = src_new(SRC_LINEAR, g_src.channels, &error);
   if (g_src.src_state == NULL)
     {
-      auderr("ERROR: Could not initialize SRC (%d)\n", src_strerror(error));
+      auderr("ERROR: Could not initialize SRC (%s)\n", src_strerror(error));
       ret = error;
     }
 
@@ -547,7 +549,7 @@ int cxd56_src_enqueue(FAR struct ap_buffer_s *apb)
   int ret;
   struct audio_msg_s msg;
 
-  audinfo("SRC: Enqueue %x\n", apb);
+  audinfo("SRC: Enqueue %x\n", (unsigned int) apb);
 
   msg.msg_id = AUDIO_MSG_ENQUEUE;
   msg.u.ptr = apb;
diff --git a/drivers/audio/cxd56_src.h b/drivers/audio/cxd56_src.h
index 03eacaa..70f1267 100644
--- a/drivers/audio/cxd56_src.h
+++ b/drivers/audio/cxd56_src.h
@@ -29,6 +29,7 @@
 #include <mqueue.h>
 
 #include <nuttx/audio/audio.h>
+#include <nuttx/audio/samplerate.h>
 #include <nuttx/config.h>
 
 #ifdef CONFIG_AUDIO
@@ -45,53 +46,9 @@
 #  define CONFIG_CXD56_SRC_MSG_PRIO  1
 #endif
 
-#ifndef SRC_SINC_BEST_QUALITY
-#  define SRC_SINC_BEST_QUALITY     0
-#endif
-
-#ifndef SRC_SINC_MEDIUM_QUALITY
-#  define SRC_SINC_MEDIUM_QUALITY   1
-#endif
-
-#ifndef SRC_SINC_FASTEST
-#  define SRC_SINC_FASTEST          2
-#endif
-
-#ifndef SRC_ZERO_ORDER_HOLD
-#  define SRC_ZERO_ORDER_HOLD       3
-#endif
-
-#ifndef SRC_LINEAR
-#  define SRC_LINEAR                4
-#endif
-
 #define AUDIO_APB_SRC_FINAL  (1 << 4) /* Last buffer in SRC processing */
 
 /****************************************************************************
- * Public Types
- ****************************************************************************/
-
-typedef struct SRC_STATE_TAG SRC_STATE;
-
-typedef struct
-{
-  const float *data_in;
-  float       *data_out;
-  long        input_frames;
-  long        output_frames;
-  long        input_frames_used;
-  long        output_frames_gen;
-  int         end_of_input;
-  double      src_ratio;
-} SRC_DATA;
-
-SRC_STATE *src_new (int converter_type, int channels, int *error);
-
-SRC_STATE *src_delete (SRC_STATE *state);
-
-int src_process (SRC_STATE *state, SRC_DATA *data);
-
-/****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/