Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/5] android/client: Simplify PCM handling function in SCO HAL
@ 2014-09-26 13:42 Szymon Janc
  2014-09-26 13:42 ` [PATCH 2/5] android/hal-audio: Remove use of shared queue code Szymon Janc
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Szymon Janc @ 2014-09-26 13:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-29 16:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-26 13:42 [PATCH 1/5] android/client: Simplify PCM handling function in SCO HAL Szymon Janc
2014-09-26 13:42 ` [PATCH 2/5] android/hal-audio: Remove use of shared queue code Szymon Janc
2014-09-26 13:42 ` [PATCH 3/5] android/hal: Add simple helpers for unaligned memory access Szymon Janc
2014-09-26 13:42 ` [PATCH 4/5] android/hal-sco: Use hal-utils helpers for unaligned access Szymon Janc
2014-09-26 13:42 ` [PATCH 5/5] android/hal-audio: " Szymon Janc
2014-09-29 16:13 ` [PATCH 1/5] android/client: Simplify PCM handling function in SCO HAL Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox