From 08ce24ec3fb094f653b3f3421388edec02f1dced Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Mar 2012 18:33:26 +0100 Subject: audio_format: basic support for DSD-over-USB --- src/audio_format.c | 3 +++ src/audio_format.h | 9 +++++++++ src/audio_parser.c | 6 ++++++ src/decoder/flac_pcm.c | 1 + src/output/alsa_output_plugin.c | 1 + src/output/oss_output_plugin.c | 1 + src/pcm_byteswap.c | 1 + src/pcm_convert.c | 1 + src/pcm_format.c | 4 ++++ src/pcm_mix.c | 2 ++ src/pcm_volume.c | 1 + 11 files changed, 30 insertions(+) (limited to 'src') diff --git a/src/audio_format.c b/src/audio_format.c index c9ee27fa1..8222f0a53 100644 --- a/src/audio_format.c +++ b/src/audio_format.c @@ -77,6 +77,9 @@ sample_format_to_string(enum sample_format format) case SAMPLE_FORMAT_DSD_LSBFIRST: return "dsdl"; + + case SAMPLE_FORMAT_DSD_OVER_USB: + return "dsdusb"; } /* unreachable */ diff --git a/src/audio_format.h b/src/audio_format.h index 2c86b70b9..5bb2ed9fb 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -61,6 +61,13 @@ enum sample_format { * comes first. */ SAMPLE_FORMAT_DSD_LSBFIRST, + + /** + * DSD packed in 24 bit samples (no padding), according to the + * dCS suggested standard: + * http://www.dcsltd.co.uk/page/assets/DSDoverUSB.pdf + */ + SAMPLE_FORMAT_DSD_OVER_USB, }; static const unsigned MAX_CHANNELS = 8; @@ -189,6 +196,7 @@ audio_valid_sample_format(enum sample_format format) case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: return true; case SAMPLE_FORMAT_UNDEFINED: @@ -258,6 +266,7 @@ sample_format_size(enum sample_format format) return 2; case SAMPLE_FORMAT_S24: + case SAMPLE_FORMAT_DSD_OVER_USB: return 3; case SAMPLE_FORMAT_S24_P32: diff --git a/src/audio_parser.c b/src/audio_parser.c index 7061e0e00..4ee2bda0c 100644 --- a/src/audio_parser.c +++ b/src/audio_parser.c @@ -87,6 +87,12 @@ parse_sample_format(const char *src, bool mask, return true; } + if (memcmp(src, "dsdusb", 6) == 0) { + *sample_format_r = SAMPLE_FORMAT_DSD_OVER_USB; + *endptr_r = src + 6; + return true; + } + if (memcmp(src, "dsd", 3) == 0) { if (src[3] == 'l') { *sample_format_r = SAMPLE_FORMAT_DSD_LSBFIRST; diff --git a/src/decoder/flac_pcm.c b/src/decoder/flac_pcm.c index 4d35b118e..5f7d382a1 100644 --- a/src/decoder/flac_pcm.c +++ b/src/decoder/flac_pcm.c @@ -105,6 +105,7 @@ flac_convert(void *dest, case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: case SAMPLE_FORMAT_UNDEFINED: /* unreachable */ assert(false); diff --git a/src/output/alsa_output_plugin.c b/src/output/alsa_output_plugin.c index 58f73d67d..4a51fcaed 100644 --- a/src/output/alsa_output_plugin.c +++ b/src/output/alsa_output_plugin.c @@ -196,6 +196,7 @@ get_bitformat(enum sample_format sample_format) case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: return SND_PCM_FORMAT_UNKNOWN; case SAMPLE_FORMAT_S8: diff --git a/src/output/oss_output_plugin.c b/src/output/oss_output_plugin.c index f98d01914..0868cf7e7 100644 --- a/src/output/oss_output_plugin.c +++ b/src/output/oss_output_plugin.c @@ -398,6 +398,7 @@ sample_format_to_oss(enum sample_format format) case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: return AFMT_QUERY; case SAMPLE_FORMAT_S8: diff --git a/src/pcm_byteswap.c b/src/pcm_byteswap.c index 741c6510f..f57957a94 100644 --- a/src/pcm_byteswap.c +++ b/src/pcm_byteswap.c @@ -70,6 +70,7 @@ pcm_byteswap(struct pcm_buffer *buffer, enum sample_format format, case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_S24: case SAMPLE_FORMAT_FLOAT: + case SAMPLE_FORMAT_DSD_OVER_USB: /* not implemented */ return NULL; diff --git a/src/pcm_convert.c b/src/pcm_convert.c index 62e36899a..2dfd3c734 100644 --- a/src/pcm_convert.c +++ b/src/pcm_convert.c @@ -82,6 +82,7 @@ pcm_convert_channels(struct pcm_buffer *buffer, enum sample_format format, case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: g_set_error(error_r, pcm_convert_quark(), 0, "Channel conversion not implemented for format '%s'", sample_format_to_string(format)); diff --git a/src/pcm_format.c b/src/pcm_format.c index c7cf910ed..ecc1ee1c9 100644 --- a/src/pcm_format.c +++ b/src/pcm_format.c @@ -149,6 +149,7 @@ pcm_convert_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither, case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: break; case SAMPLE_FORMAT_S8: @@ -269,6 +270,7 @@ pcm_convert_to_24(struct pcm_buffer *buffer, case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: break; case SAMPLE_FORMAT_S8: @@ -395,6 +397,7 @@ pcm_convert_to_32(struct pcm_buffer *buffer, case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: break; case SAMPLE_FORMAT_S8: @@ -532,6 +535,7 @@ pcm_convert_to_float(struct pcm_buffer *buffer, case SAMPLE_FORMAT_UNDEFINED: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: break; case SAMPLE_FORMAT_S8: diff --git a/src/pcm_mix.c b/src/pcm_mix.c index 84bb5526d..0fb7b6dcd 100644 --- a/src/pcm_mix.c +++ b/src/pcm_mix.c @@ -122,6 +122,7 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size, case SAMPLE_FORMAT_S24: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: /* not implemented */ return false; @@ -233,6 +234,7 @@ pcm_add(void *buffer1, const void *buffer2, size_t size, case SAMPLE_FORMAT_S24: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: /* not implemented */ return false; diff --git a/src/pcm_volume.c b/src/pcm_volume.c index d8da570aa..c83ee0f7f 100644 --- a/src/pcm_volume.c +++ b/src/pcm_volume.c @@ -161,6 +161,7 @@ pcm_volume(void *buffer, size_t length, case SAMPLE_FORMAT_S24: case SAMPLE_FORMAT_DSD: case SAMPLE_FORMAT_DSD_LSBFIRST: + case SAMPLE_FORMAT_DSD_OVER_USB: /* not implemented */ return false; -- cgit v1.2.3