diff --git a/shared-module/audiodelays/Echo.c b/shared-module/audiodelays/Echo.c index 3f45162cb5e9..a0c34c6540d8 100644 --- a/shared-module/audiodelays/Echo.c +++ b/shared-module/audiodelays/Echo.c @@ -342,7 +342,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t * } else { // For unsigned samples set to the middle which is "quiet" if (MP_LIKELY(self->bits_per_sample == 16)) { - memset(word_buffer, 32768, length * (self->bits_per_sample / 8)); + uint16_t *uword_buffer = (uint16_t *)word_buffer; + while (length--) { + *uword_buffer++ = 32768; + } } else { memset(hword_buffer, 128, length * (self->bits_per_sample / 8)); } diff --git a/shared-module/audiofilters/Filter.c b/shared-module/audiofilters/Filter.c index 86edb6cb0418..d7ee30e8ea66 100644 --- a/shared-module/audiofilters/Filter.c +++ b/shared-module/audiofilters/Filter.c @@ -240,8 +240,24 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o } } - // If we have a sample, filter it - if (self->sample != NULL) { + if (self->sample == NULL) { + if (self->samples_signed) { + memset(word_buffer, 0, length * (self->bits_per_sample / 8)); + } else { + // For unsigned samples set to the middle which is "quiet" + if (MP_LIKELY(self->bits_per_sample == 16)) { + uint16_t *uword_buffer = (uint16_t *)word_buffer; + while (length--) { + *uword_buffer++ = 32768; + } + } else { + memset(hword_buffer, 128, length * (self->bits_per_sample / 8)); + } + } + + length = 0; + } else { + // we have a sample to play and filter // Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining uint32_t n = MIN(self->sample_buffer_length, length);