[Spice-devel] [PATCH] sound: fix pointer arithmetic in snd_record_handle_write()
Frediano Ziglio
freddy77 at gmail.com
Mon Oct 24 10:21:08 UTC 2022
Il giorno sab 22 ott 2022 alle ore 12:51 Volker Rümelin
<vr_qemu at t-online.de> ha scritto:
>
> The variable 'now' counts in audio sample frames, but the variable
> 'data' is of type uint8_t *. Multiply 'now' by the size of an audio
> sample frame to get the correct source pointer.
>
> This improves the quality of audio recordings in QEMU a little bit.
>
> Fixes: 5d5a7bd181 ("sound: Avoid cast that could cause alignment problems")
> Signed-off-by: Volker Rümelin <vr_qemu at t-online.de>
> ---
> server/sound.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/server/sound.cpp b/server/sound.cpp
> index eca2706c..4909d158 100644
> --- a/server/sound.cpp
> +++ b/server/sound.cpp
> @@ -302,7 +302,7 @@ static bool snd_record_handle_write(RecordChannelClient *record_client, size_t s
> memcpy(record_client->samples + write_pos, data, now << 2);
>
> if (size) {
> - memcpy(record_client->samples, data + now, size << 2);
> + memcpy(record_client->samples, data + (now << 2), size << 2);
> }
>
> if (record_client->write_pos - record_client->read_pos > RECORD_SAMPLES_SIZE) {
Hi Volker,
merged.
Thanks,
Frediano
More information about the Spice-devel
mailing list