From 5080a9cf2110bc3903ae11d14b379d88b1cf8991 Mon Sep 17 00:00:00 2001 From: hungrymonkey Date: Sun, 8 Oct 2017 15:11:29 -0700 Subject: Fix data alignment issues in get_data() in AudioStreamSample I am fixing the issue by adding DATA_PAD to the return pointer as suggested by hi-ogawa When using set_data in AudioStreamSample in PoolByteArray, the data is set using a DATA_PAD to pad the pointer to the correct place as such uint8_t *dataptr = (uint8_t *)data; copymem(dataptr + DATA_PAD, r.ptr(), datalen); data_bytes = datalen; godot/scene/resources/audio_stream_sample.cpp#L473 All I am doing is adding a DATA_PAD to the return pointer to get_data() in AudioStreamSample to change godot/scene/resources/audio_stream_sample.cpp#L48 PoolVector::Write w = pv.write(); copymem(w.ptr(), data, data_bytes); to PoolVector::Write w = pv.write(); uint8_t *dataptr = (uint8_t *)data; copymem(w.ptr(), dataptr + DATA_PAD, data_bytes); Please review whether or not set or get is correct. Because this issue seems to be fixable by removing DATA_PAD in set_data() instead of adding DATA_PAD to get_data(). I have not tested the latter fix Fixes #issue, 11873 --- scene/resources/audio_stream_sample.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index 1fd84a860e..fdc3b79db6 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -486,7 +486,8 @@ PoolVector AudioStreamSample::get_data() const { { PoolVector::Write w = pv.write(); - copymem(w.ptr(), data, data_bytes); + uint8_t *dataptr = (uint8_t *)data; + copymem(w.ptr(), dataptr + DATA_PAD, data_bytes); } } -- cgit v1.2.3