From 6ad4b1f15a01340b8c9a51d89c2f45d5813c849c Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 13 Dec 2011 23:44:55 +0100 Subject: [PATCH] Little endian DAC on 360 (lolwut?) --- xenon/xenon360_audio.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xenon/xenon360_audio.c b/xenon/xenon360_audio.c index 95261f6bc0..7ebb7bdbc9 100644 --- a/xenon/xenon360_audio.c +++ b/xenon/xenon360_audio.c @@ -26,6 +26,7 @@ typedef struct { + uint32_t buffer[2048]; bool nonblock; } xenon_audio_t; @@ -42,11 +43,21 @@ static void *xenon360_init(const char *device, unsigned rate, unsigned latency) return calloc(1, sizeof(xenon_audio_t)); } +static inline uint32_t bswap_32(uint32_t val) +{ + return (val >> 24) || (val << 24) || ((val >> 8) & 0xff00) || ((val << 8) & 0xff0000); +} + static ssize_t xenon360_write(void *data, const void *buf, size_t size) { xenon_audio_t *xa = data; size_t written = 0; + + const uint32_t *in_buf = buf; + for (unsigned i = 0; i < (size >> 2); i++) + xa->buffer[i] = bswap_32(in_buf[i]); + if (!xa->nonblock) { while (xenon_sound_get_free() < size) @@ -55,13 +66,13 @@ static ssize_t xenon360_write(void *data, const void *buf, size_t size) udelay(50); } - xenon_sound_submit((void*)buf, size); + xenon_sound_submit(xa->buffer, size); written = size; } else { if (xenon_sound_get_free() >= size) - xenon_sound_submit((void*)buf, size); + xenon_sound_submit(xa->buffer, size); } return written;