summaryrefslogtreecommitdiff
path: root/src/combined/decoder_flac.c
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2010-01-17 03:10:22 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2010-01-17 03:10:22 +0000
commite890141a04b1e79feddf17b4db460050a25f613e (patch)
tree9711272317c20b5f9f387c9063f73beef76260c0 /src/combined/decoder_flac.c
parentf6456aeccb0e7a420aa25997d8fe6ee87da489a5 (diff)
downloadxine-lib-e890141a04b1e79feddf17b4db460050a25f613e.tar.gz
xine-lib-e890141a04b1e79feddf17b4db460050a25f613e.tar.bz2
"Fix" playback of 24-bit FLAC.
We pretend that it's 16-bit to avoid "audio device unavailable" (ALSA). Also, the clock is a bit fast.
Diffstat (limited to 'src/combined/decoder_flac.c')
-rw-r--r--src/combined/decoder_flac.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/combined/decoder_flac.c b/src/combined/decoder_flac.c
index b774e0b90..fe1822797 100644
--- a/src/combined/decoder_flac.c
+++ b/src/combined/decoder_flac.c
@@ -122,7 +122,7 @@ flac_write_callback (const FLAC__StreamDecoder *decoder,
flac_decoder_t *this = (flac_decoder_t *)client_data;
audio_buffer_t *audio_buffer = NULL;
int samples_left = frame->header.blocksize;
- int bytes_per_sample = (frame->header.bits_per_sample == 8)?1:2;
+ int bytes_per_sample = (frame->header.bits_per_sample <= 8) ? 1 : 2;
int buf_samples;
int8_t *data8;
int16_t *data16;
@@ -139,21 +139,31 @@ flac_write_callback (const FLAC__StreamDecoder *decoder,
else
buf_samples = samples_left;
-
- if( frame->header.bits_per_sample == 8 ) {
+ switch (frame->header.bits_per_sample) {
+ case 8:
data8 = (int8_t *)audio_buffer->mem;
for( j=0; j < buf_samples; j++ )
for( i=0; i < frame->header.channels; i++ )
*data8++ = buffer[i][j];
+ break;
- } else {
-
+ case 16:
data16 = (int16_t *)audio_buffer->mem;
for( j=0; j < buf_samples; j++ )
for( i=0; i < frame->header.channels; i++ )
*data16++ = buffer[i][j];
+ break;
+
+ case 24:
+ data16 = (int16_t *)audio_buffer->mem;
+
+ for( j=0; j < buf_samples; j++ )
+ for( i=0; i < frame->header.channels; i++ )
+ *data16++ = buffer[i][j] >> 8;
+ break;
+
}
audio_buffer->num_frames = buf_samples;
@@ -261,14 +271,13 @@ flac_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
if (!this->output_open)
{
+ const int bits = this->bits_per_sample;
this->output_open = (this->stream->audio_out->open) (
this->stream->audio_out,
this->stream,
- this->bits_per_sample,
+ bits > 16 ? 16 : bits,
this->sample_rate,
mode);
-
-
}
this->buf_pos = 0;
} else if (this->output_open)