aboutsummaryrefslogtreecommitdiff
path: root/src/pcm_dsd_usb.c
diff options
context:
space:
mode:
authorJurgen Kramer <gtmkramer@xs4all.nl>2012-04-01 11:10:12 +0200
committerMax Kellermann <max@duempel.org>2012-04-04 20:13:15 +0200
commitf930f37d35995f0fc07f70aefc41babc0db1757e (patch)
treeebb54621fef2c4c73ec5bcd760acaccdc91414bf /src/pcm_dsd_usb.c
parent4feb57e8953d114b85abd3910b477ef58ef171ae (diff)
Add support for DSD-over-USB version 1.0, remove pre-v1 support
Diffstat (limited to 'src/pcm_dsd_usb.c')
-rw-r--r--src/pcm_dsd_usb.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/pcm_dsd_usb.c b/src/pcm_dsd_usb.c
index 976420c0..4b5e39f3 100644
--- a/src/pcm_dsd_usb.c
+++ b/src/pcm_dsd_usb.c
@@ -24,11 +24,19 @@
G_GNUC_CONST
static inline uint32_t
-pcm_two_dsd_to_usb(uint8_t a, uint8_t b)
+pcm_two_dsd_to_usb_marker1(uint8_t a, uint8_t b)
{
- return 0xffaa0000 | (a << 8) | b;
+ return 0xff050000 | (a << 8) | b;
}
+G_GNUC_CONST
+static inline uint32_t
+pcm_two_dsd_to_usb_marker2(uint8_t a, uint8_t b)
+{
+ return 0xfffa0000 | (a << 8) | b;
+}
+
+
const uint32_t *
pcm_dsd_to_usb(struct pcm_buffer *buffer, unsigned channels,
const uint8_t *src, size_t src_size,
@@ -53,12 +61,27 @@ pcm_dsd_to_usb(struct pcm_buffer *buffer, unsigned channels,
uint32_t *const dest0 = pcm_buffer_get(buffer, dest_size),
*dest = dest0;
- for (unsigned i = num_frames; i > 0; --i) {
+ for (unsigned i = num_frames / 2; i > 0; --i) {
+ for (unsigned c = channels; c > 0; --c) {
+ /* each 24 bit sample has 16 DSD sample bits
+ plus the magic 0x05 marker */
+
+ *dest++ = pcm_two_dsd_to_usb_marker1(src[0], src[channels]);
+
+ /* seek the source pointer to the next
+ channel */
+ ++src;
+ }
+
+ /* skip the second byte of each channel, because we
+ have already copied it */
+ src += channels;
+
for (unsigned c = channels; c > 0; --c) {
/* each 24 bit sample has 16 DSD sample bits
- plus the magic 0xaa marker */
+ plus the magic 0xfa marker */
- *dest++ = pcm_two_dsd_to_usb(src[0], src[channels]);
+ *dest++ = pcm_two_dsd_to_usb_marker2(src[0], src[channels]);
/* seek the source pointer to the next
channel */