diff options
Diffstat (limited to 'src/liblpcm/xine_decoder.c')
-rw-r--r-- | src/liblpcm/xine_decoder.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c index f2063ed6a..cd3e33b45 100644 --- a/src/liblpcm/xine_decoder.c +++ b/src/liblpcm/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.4 2001/08/31 01:07:55 jcdutton Exp $ + * $Id: xine_decoder.c,v 1.5 2001/08/31 17:57:54 jkeil Exp $ * * 31-8-2001 Added LPCM rate sensing. * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -48,11 +48,14 @@ typedef struct lpcm_decoder_s { ao_instance_t *audio_out; int output_open; - + int cpu_be; /* TRUE, if we're a Big endian CPU */ } lpcm_decoder_t; int lpcm_can_handle (audio_decoder_t *this_gen, int buf_type) { - return ((buf_type & 0xFFFF0000) == BUF_AUDIO_LPCM) ; + buf_type &= 0xFFFF0000; + + return ( buf_type == BUF_AUDIO_LPCM_BE || + buf_type == BUF_AUDIO_LPCM_LE ); } @@ -66,6 +69,8 @@ void lpcm_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { this->last_pts = 0; this->last_size = 0; this->rate = 0; + + this->cpu_be = ( htons(1) == 1 ); } @@ -73,8 +78,10 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; int16_t *sample_buffer=(int16_t *)buf->content; - this->last_pts=this->pts; - this->pts = buf->PTS; + int stream_be; + + this->last_pts=this->pts; + this->pts = buf->PTS; if (buf->decoder_info[0] == 0) return; if ((this->last_pts > 0) && (this->pts > 0) && (this->rate == 0)) { @@ -90,6 +97,12 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } if (!this->output_open) return; + + /* Swap LPCM samples into native byte order, if necessary */ + stream_be = ( buf->type == BUF_AUDIO_LPCM_BE ); + if (stream_be != this->cpu_be) + swab(sample_buffer, sample_buffer, buf->size); + this->audio_out->write (this->audio_out, sample_buffer, buf->size/4, |