aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoder/wave_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoder/wave_encoder.c')
-rw-r--r--src/encoder/wave_encoder.c29
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;