aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-03-21 22:15:45 +0100
committerMax Kellermann <max@duempel.org>2012-03-22 00:33:40 +0100
commit43774455cc3280e0e12ce744d734d3b1ae2e77db (patch)
tree65669ad67eace9576b45bf114af5c6d8e1db5859
parent5b61e077e0e3d84f17a410d7327e2a7a73613aad (diff)
downloadmpd-43774455cc3280e0e12ce744d734d3b1ae2e77db.tar.gz
mpd-43774455cc3280e0e12ce744d734d3b1ae2e77db.tar.xz
mpd-43774455cc3280e0e12ce744d734d3b1ae2e77db.zip
output/oss: use pcm_export to pack 24 bit samples
-rw-r--r--src/output/oss_output_plugin.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/output/oss_output_plugin.c b/src/output/oss_output_plugin.c
index 154930b38..4a0ea2470 100644
--- a/src/output/oss_output_plugin.c
+++ b/src/output/oss_output_plugin.c
@@ -434,6 +434,7 @@ sample_format_to_oss(enum sample_format format)
case SAMPLE_FORMAT_FLOAT:
case SAMPLE_FORMAT_DSD:
case SAMPLE_FORMAT_DSD_OVER_USB:
+ case SAMPLE_FORMAT_S24:
return AFMT_QUERY;
case SAMPLE_FORMAT_S8:
@@ -442,13 +443,6 @@ sample_format_to_oss(enum sample_format format)
case SAMPLE_FORMAT_S16:
return AFMT_S16_NE;
- case SAMPLE_FORMAT_S24:
-#ifdef AFMT_S24_PACKED
- return AFMT_S24_PACKED;
-#else
- return AFMT_QUERY;
-#endif
-
case SAMPLE_FORMAT_S24_P32:
#ifdef AFMT_S24_NE
return AFMT_S24_NE;
@@ -483,7 +477,7 @@ sample_format_from_oss(int format)
#ifdef AFMT_S24_PACKED
case AFMT_S24_PACKED:
- return SAMPLE_FORMAT_S24;
+ return SAMPLE_FORMAT_S24_P32;
#endif
#ifdef AFMT_S24_NE
@@ -524,6 +518,18 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
oss_try_ioctl_r(fd, SNDCTL_DSP_SAMPLESIZE,
&oss_format,
"Failed to set sample format", error_r);
+
+#ifdef AFMT_S24_PACKED
+ if (result == UNSUPPORTED && sample_format == SAMPLE_FORMAT_S24_P32) {
+ /* if the driver doesn't support padded 24 bit, try
+ packed 24 bit */
+ oss_format = AFMT_S24_PACKED;
+ result = oss_try_ioctl_r(fd, SNDCTL_DSP_SAMPLESIZE,
+ &oss_format,
+ "Failed to set sample format", error_r);
+ }
+#endif
+
if (result != SUCCESS)
return result;
@@ -536,7 +542,7 @@ oss_probe_sample_format(int fd, enum sample_format sample_format,
#ifdef AFMT_S24_PACKED
pcm_export_open(export, sample_format,
- false,
+ oss_format == AFMT_S24_PACKED,
oss_format == AFMT_S24_PACKED &&
G_BYTE_ORDER != G_LITTLE_ENDIAN);
#endif
@@ -585,7 +591,6 @@ oss_setup_sample_format(int fd, struct audio_format *audio_format,
static const enum sample_format sample_formats[] = {
SAMPLE_FORMAT_S24_P32,
SAMPLE_FORMAT_S32,
- SAMPLE_FORMAT_S24,
SAMPLE_FORMAT_S16,
SAMPLE_FORMAT_S8,
SAMPLE_FORMAT_UNDEFINED /* sentinel */