Skip to content

Commit

Permalink
pcm_converter: do nothing when there are no samples
Browse files Browse the repository at this point in the history
HiFi3 version of PCM converter can corrupt data or go into
endless loop, when called with samples = 0. Make sure
the processing functions return immediately if that happens.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
  • Loading branch information
tlauda committed Mar 9, 2020
1 parent 90f83af commit 0996f79
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/audio/pcm_converter/pcm_converter_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ static void pcm_convert_s16_to_s24(const struct audio_stream *source,
ae_int32x2 *out32x2;
int i = 0;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L16X4_XC */
while (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down Expand Up @@ -153,6 +157,10 @@ static void pcm_convert_s24_to_s16(const struct audio_stream *source,
int i = 0;
int leftover;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L32X2_XC */
if (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down Expand Up @@ -257,6 +265,10 @@ static void pcm_convert_s16_to_s32(const struct audio_stream *source,
ae_int32x2 *out32x2;
int i = 0;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L16X4_XC */
while (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down Expand Up @@ -338,6 +350,10 @@ static void pcm_convert_s32_to_s16(const struct audio_stream *source,
int i = 0;
int leftover;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L32X2_XC */
if (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down Expand Up @@ -436,6 +452,10 @@ static void pcm_convert_s24_to_s32(const struct audio_stream *source,
ae_valign align_out = AE_ZALIGN64();
int i;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L32X2_XC */
if (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down Expand Up @@ -522,6 +542,10 @@ static void pcm_convert_s32_to_s24(const struct audio_stream *source,
ae_valign align_out = AE_ZALIGN64();
int i;

/* nothing to do */
if (!samples)
return;

/* required alignment for AE_L32X2_XC */
if (!IS_ALIGNED((uintptr_t)in, 8)) {
/* set source as circular buffer */
Expand Down

0 comments on commit 0996f79

Please sign in to comment.