diff options
author | Max Kellermann <max@duempel.org> | 2009-03-12 19:49:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-12 19:49:15 +0100 |
commit | 6352e75910f33273a04ce9b2c104af161e64a96f (patch) | |
tree | 43526448ec2c3a6fb392734426e7c2fd472242fb | |
parent | e3b9b57ecdf8c1396d120f1ccee0814a3e119511 (diff) | |
download | mpd-6352e75910f33273a04ce9b2c104af161e64a96f.tar.gz mpd-6352e75910f33273a04ce9b2c104af161e64a96f.tar.xz mpd-6352e75910f33273a04ce9b2c104af161e64a96f.zip |
crossfade: copy chunk.audio_format in !NDEBUG
When the destination chunk was empty in cross_fade_apply(), it had no
audio_format attached (an attribute which is only used for assertion
in the debug build). cross_fade_apply() should assign it the
audio_format of the second chunk (if available), otherwise MPD will
crash.
-rw-r--r-- | src/crossfade.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/crossfade.c b/src/crossfade.c index 2bac4a649..8d752cf5f 100644 --- a/src/crossfade.c +++ b/src/crossfade.c @@ -58,6 +58,10 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b, { size_t size; + assert(a != NULL); + assert(b != NULL); + assert(a->length == 0 || b->length == 0 || + audio_format_equals(&a->audio_format, b->audio_format)); assert(current_chunk <= num_chunks); if (a->tag == NULL && b->tag != NULL) @@ -79,6 +83,12 @@ void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b, there is unmixed rest at the end. Copy it over. The output buffer API guarantees that there is enough room in a->data. */ + +#ifndef NDEBUG + if (a->length == 0) + a->audio_format = b->audio_format; +#endif + memcpy(a->data + a->length, b->data + a->length, b->length - a->length); |