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 <tobias.johansson@sony.com>
This commit is contained in:
Tobias Johansson 2021-11-17 14:48:29 +01:00 committed by Xiang Xiao
parent 6735cf412e
commit 6f579b8118
2 changed files with 8 additions and 49 deletions

View File

@ -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;

View File

@ -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,52 +46,8 @@
# 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
****************************************************************************/