Skip to content

Commit 3a0b97d

Browse files
authored
Merge pull request #9787 from relic-se/audiofilters_stopfix
2 parents 6cb7c82 + 0aab00d commit 3a0b97d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

shared-module/audiodelays/Echo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ audioio_get_buffer_result_t audiodelays_echo_get_buffer(audiodelays_echo_obj_t *
342342
} else {
343343
// For unsigned samples set to the middle which is "quiet"
344344
if (MP_LIKELY(self->bits_per_sample == 16)) {
345-
memset(word_buffer, 32768, length * (self->bits_per_sample / 8));
345+
uint16_t *uword_buffer = (uint16_t *)word_buffer;
346+
while (length--) {
347+
*uword_buffer++ = 32768;
348+
}
346349
} else {
347350
memset(hword_buffer, 128, length * (self->bits_per_sample / 8));
348351
}

shared-module/audiofilters/Filter.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,24 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o
240240
}
241241
}
242242

243-
// If we have a sample, filter it
244-
if (self->sample != NULL) {
243+
if (self->sample == NULL) {
244+
if (self->samples_signed) {
245+
memset(word_buffer, 0, length * (self->bits_per_sample / 8));
246+
} else {
247+
// For unsigned samples set to the middle which is "quiet"
248+
if (MP_LIKELY(self->bits_per_sample == 16)) {
249+
uint16_t *uword_buffer = (uint16_t *)word_buffer;
250+
while (length--) {
251+
*uword_buffer++ = 32768;
252+
}
253+
} else {
254+
memset(hword_buffer, 128, length * (self->bits_per_sample / 8));
255+
}
256+
}
257+
258+
length = 0;
259+
} else {
260+
// we have a sample to play and filter
245261
// Determine how many bytes we can process to our buffer, the less of the sample we have left and our buffer remaining
246262
uint32_t n = MIN(self->sample_buffer_length, length);
247263

0 commit comments

Comments
 (0)