[PATCH 1/5] android/client: Simplify PCM handling function in SCO HAL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Those functions operates on aligned buffers so there is no need for
unaligned memory access helpers.
---
 android/client/if-sco.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index 7a89692..e7197b2 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -19,7 +19,6 @@
 #include <unistd.h>
 #include <math.h>
 
-#include "../src/shared/util.h"
 #include "if-main.h"
 #include "../hal-utils.h"
 
@@ -176,14 +175,11 @@ static void prepare_sample(void)
 
 static void mono_to_stereo_pcm16(const int16_t *in, int16_t *out, size_t samples)
 {
-	int16_t mono;
 	size_t i;
 
 	for (i = 0; i < samples; i++) {
-		mono = get_unaligned(&in[i]);
-
-		put_unaligned(mono, &out[2 * i]);
-		put_unaligned(mono, &out[2 * i + 1]);
+		out[2 * i] = in[i];
+		out[2 * i + 1] = in[i];
 	}
 }
 
@@ -267,17 +263,14 @@ static void *playback_thread(void *data)
 	return NULL;
 }
 
-static void write_stereo_pcm16(char *buffer, size_t len, FILE *out)
+static void write_stereo_pcm16(const short *input, size_t len, FILE *out)
 {
-	const int16_t *input = (const void *) buffer;
-	int16_t sample[2];
+	short sample[2];
 	size_t i;
 
 	for (i = 0; i < len / 2; i++) {
-		int16_t mono = get_unaligned(&input[i]);
-
-		put_unaligned(mono, &sample[0]);
-		put_unaligned(mono, &sample[1]);
+		sample[0] = input[i];
+		sample[1] = input[i];
 
 		fwrite(sample, sizeof(sample), 1, out);
 	}
@@ -319,7 +312,7 @@ static void *read_thread(void *data)
 		haltest_info("Read %zd bytes\n", len);
 
 		if (out) {
-			write_stereo_pcm16((char *) buffer, len, out);
+			write_stereo_pcm16(buffer, len, out);
 			haltest_info("Written %zd bytes\n", len * 2);
 		}
 	} while (len);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux