Commit 08ce24ec authored by Max Kellermann's avatar Max Kellermann

audio_format: basic support for DSD-over-USB

parent 281b8714
......@@ -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 */
......
......@@ -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:
......
......@@ -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;
......
......@@ -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);
......
......@@ -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:
......
......@@ -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:
......
......@@ -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;
......
......@@ -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));
......
......@@ -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:
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment