aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_jack.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-24 17:36:11 +0200
committerMax Kellermann <max@duempel.org>2008-10-24 17:36:11 +0200
commitf4e6bb2815ad78ff71adb5bfaa672d4c2088d15d (patch)
tree0a7194d8ed423a6e8f6a8af1f1bde1df3fc75d74 /src/audioOutputs/audioOutput_jack.c
parentb1adfaae439fd0e28724265d13aa5040afd51022 (diff)
downloadmpd-f4e6bb2815ad78ff71adb5bfaa672d4c2088d15d.tar.gz
mpd-f4e6bb2815ad78ff71adb5bfaa672d4c2088d15d.tar.xz
mpd-f4e6bb2815ad78ff71adb5bfaa672d4c2088d15d.zip
jack: support for 24 bit samples
When the audio source provides 24 bit samples, don't bother to convert (lossily) them to 16 bit before jack's floating point conversion - go directly from 24 bit to float.
Diffstat (limited to 'src/audioOutputs/audioOutput_jack.c')
-rw-r--r--src/audioOutputs/audioOutput_jack.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c
index b24ce77ee..6f2bcd3a1 100644
--- a/src/audioOutputs/audioOutput_jack.c
+++ b/src/audioOutputs/audioOutput_jack.c
@@ -165,7 +165,10 @@ set_audioformat(struct jack_data *jd, struct audio_format *audio_format)
audio_format->sample_rate = jack_get_sample_rate(jd->client);
DEBUG("samplerate = %u\n", audio_format->sample_rate);
audio_format->channels = 2;
- audio_format->bits = 16;
+
+ if (audio_format->bits != 16 && audio_format->bits != 24)
+ audio_format->bits = 24;
+
jd->bps = audio_format->channels
* sizeof(jack_default_audio_sample_t)
* audio_format->sample_rate;
@@ -379,6 +382,29 @@ mpd_jack_write_samples_16(struct jack_data *jd, const int16_t *src,
}
}
+static inline jack_default_audio_sample_t
+sample_24_to_jack(int32_t sample)
+{
+ return sample / (jack_default_audio_sample_t)(1 << (24 - 1));
+}
+
+static void
+mpd_jack_write_samples_24(struct jack_data *jd, const int32_t *src,
+ unsigned num_samples)
+{
+ jack_default_audio_sample_t sample;
+
+ while (num_samples-- > 0) {
+ sample = sample_24_to_jack(*src++);
+ jack_ringbuffer_write(jd->ringbuffer[0], (void*)&sample,
+ sizeof(sample));
+
+ sample = sample_24_to_jack(*src++);
+ jack_ringbuffer_write(jd->ringbuffer[1], (void*)&sample,
+ sizeof(sample));
+ }
+}
+
static void
mpd_jack_write_samples(struct jack_data *jd, const void *src,
unsigned num_samples)
@@ -389,6 +415,11 @@ mpd_jack_write_samples(struct jack_data *jd, const void *src,
num_samples);
break;
+ case 24:
+ mpd_jack_write_samples_24(jd, (const int32_t*)src,
+ num_samples);
+ break;
+
default:
assert(false);
}