diff options
author | Max Kellermann <max@duempel.org> | 2009-11-10 17:11:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-02 22:29:50 +0100 |
commit | c412d6251e9cd3abe735b7622af4003502e54f72 (patch) | |
tree | 7344c13f62e4cc788c830c05d21bb7b5b47f5866 /src/encoder/wave_encoder.c | |
parent | 68c2cfbb4067b2292e1ff1d4e7716ff370903f84 (diff) | |
download | mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.gz mpd-c412d6251e9cd3abe735b7622af4003502e54f72.tar.xz mpd-c412d6251e9cd3abe735b7622af4003502e54f72.zip |
audio_format: changed "bits" to "enum sample_format"
This patch prepares support for floating point samples (and probably
other formats). It changes the meaning of the "bits" attribute from a
bit count to a symbolic value.
Diffstat (limited to '')
-rw-r--r-- | src/encoder/wave_encoder.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/encoder/wave_encoder.c b/src/encoder/wave_encoder.c index e66cc1917..f34ae0241 100644 --- a/src/encoder/wave_encoder.c +++ b/src/encoder/wave_encoder.c @@ -114,16 +114,39 @@ wave_encoder_open(struct encoder *_encoder, struct wave_encoder *encoder = (struct wave_encoder *)_encoder; void *buffer; - encoder->bits = audio_format->bits; + assert(audio_format_valid(audio_format)); + + switch (audio_format->format) { + case SAMPLE_FORMAT_S8: + encoder->bits = 8; + break; + + case SAMPLE_FORMAT_S16: + encoder->bits = 16; + break; + + case SAMPLE_FORMAT_S24_P32: + encoder->bits = 24; + break; + + case SAMPLE_FORMAT_S32: + encoder->bits = 32; + break; + + default: + audio_format->format = SAMPLE_FORMAT_S16; + encoder->bits = 16; + break; + } buffer = pcm_buffer_get(&encoder->buffer, sizeof(struct wave_header) ); /* create PCM wave header in initial buffer */ fill_wave_header((struct wave_header *) buffer, audio_format->channels, - audio_format->bits, + encoder->bits, audio_format->sample_rate, - (audio_format->bits / 8) * audio_format->channels ); + (encoder->bits / 8) * audio_format->channels ); encoder->buffer_length = sizeof(struct wave_header); return true; |