xiaoxiang781216 commented on code in PR #7717: URL: https://github.com/apache/nuttx/pull/7717#discussion_r1036117919
########## arch/sim/src/sim/sim_alsa.c: ########## @@ -31,17 +31,31 @@ #include <debug.h> #include <alsa/asoundlib.h> +#include <mad.h> /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define AUDMIN(a,b) ((a) > (b) ? (b) : (a)) +#define AUDCODEC_DEC 0x01 +#define AUDCODEC_ENC 0x10 /**************************************************************************** * Private Types ****************************************************************************/ +struct sim_codec_ops_s +{ + uint8_t format; + uint8_t flags; + void *(*init)(void); + int (*get_samples)(void *handle); + int (*process)(void *handle, unsigned char *in, unsigned int insize, + unsigned char *out, unsigned int *outsize); Review Comment: let's process return out buffer instead caller allocate out buffer before call process: ``` unsigned char **out, unsigned int *outsize); ``` the benefit is that: 1. get_samples callback could be removed 2. pcm codec can save memcpy by assign in to out directly 3. mp3 decode can reuse the same out buffer instead allocate every time. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org