mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-30 23:54:13 +08:00
android/hal-audio: Fix invalid memory access when downmixing to mono
While iterating over input buffer frame's size was not correctly taken into account. Input buffer is always PCM 16bit stereo (4 bytes per frame).
This commit is contained in:
parent
56a9685d81
commit
510aae0f8e
@ -527,9 +527,12 @@ static void downmix_to_mono(struct a2dp_stream_out *out, const uint8_t *buffer,
|
||||
{
|
||||
const int16_t *input = (const void *) buffer;
|
||||
int16_t *output = (void *) out->downmix_buf;
|
||||
size_t i;
|
||||
size_t i, frames;
|
||||
|
||||
for (i = 0; i < bytes / 2; i++) {
|
||||
/* PCM 16bit stereo */
|
||||
frames = bytes / (2 * sizeof(int16_t));
|
||||
|
||||
for (i = 0; i < frames; i++) {
|
||||
int16_t l = le16_to_cpu(get_unaligned(&input[i * 2]));
|
||||
int16_t r = le16_to_cpu(get_unaligned(&input[i * 2 + 1]));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user