You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lirc/0004-plugins-audio_alsa-Fix...

37 lines
1.2 KiB

From 5d933bee5c100e119c26476e45b69e019b392323 Mon Sep 17 00:00:00 2001
From: Alec Leamas <leamas.alec@gmail.com>
Date: Wed, 17 Aug 2016 21:28:00 +0200
Subject: [PATCH] plugins: audio_alsa: Fix byte truncating in 16-bit data
(#218):
This fixes a bug introduced in 82305c72 which basically was
about muting a "dereferencing type-punned pointer will break
strict-aliasing rules" compiler warning.
---
plugins/audio_alsa.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/plugins/audio_alsa.c b/plugins/audio_alsa.c
index 20022f3..ff0d8a9 100644
--- a/plugins/audio_alsa.c
+++ b/plugins/audio_alsa.c
@@ -436,11 +436,12 @@ var_reset: /* Reset variables */
for (i = 0; i < count; i++) {
/* cs == current sample */
unsigned char cs, as, sl, sz, xz;
- short stmp;
+ unsigned short stmp;
if (bytes_per_sample == 2) {
- stmp = buff[i * bytes_per_sample * alsa_hw.num_channels +
- bytes_per_sample * alsa_hw.channel];
+ int ix = i * bytes_per_sample * alsa_hw.num_channels +
+ bytes_per_sample * alsa_hw.channel;
+ memcpy(&stmp, &buff[ix], sizeof(stmp));
cs = stmp >> 8;
cs ^= 0x80;
} else {
--
2.5.5