diff options
author | Mike Melanson <mike@multimedia.cx> | 2002-10-20 18:23:20 +0000 |
---|---|---|
committer | Mike Melanson <mike@multimedia.cx> | 2002-10-20 18:23:20 +0000 |
commit | b0709abfd430c9b4b763f7346c7c52fef6263a2f (patch) | |
tree | a054b667dc6df9f7c0d0c24fae21ee4ca5febbe0 | |
parent | 483d8d5ff1566e0d88d0c4eba1cc7d7029ab8a6d (diff) | |
download | xine-lib-b0709abfd430c9b4b763f7346c7c52fef6263a2f.tar.gz xine-lib-b0709abfd430c9b4b763f7346c7c52fef6263a2f.tar.bz2 |
bring the linear PCM decoder in line with the latest API revision
CVS patchset: 2885
CVS date: 2002/10/20 18:23:20
-rw-r--r-- | src/liblpcm/xine_decoder.c | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c index f525b6b69..950159178 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.34 2002/09/05 22:18:56 mroi Exp $ + * $Id: xine_decoder.c,v 1.35 2002/10/20 18:23:20 tmmm Exp $ * * 31-8-2001 Added LPCM rate sensing. * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -39,16 +39,20 @@ #include "audio_out.h" #include "buffer.h" +typedef struct { + audio_decoder_class_t decoder_class; +} lpcm_class_t; typedef struct lpcm_decoder_s { audio_decoder_t audio_decoder; + xine_stream_t *stream; + uint32_t rate; uint32_t bits_per_sample; uint32_t number_of_channels; uint32_t ao_cap_mode; - ao_instance_t *audio_out; int output_open; int cpu_be; /* TRUE, if we're a Big endian CPU */ } lpcm_decoder_t; @@ -59,20 +63,6 @@ void lpcm_reset (audio_decoder_t *this_gen) { } -void lpcm_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { - - lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; - - this->audio_out = audio_out; - this->output_open = 0; - this->rate = 0; - this->bits_per_sample=0; - this->number_of_channels=0; - this->ao_cap_mode=0; - - this->cpu_be = ( htons(1) == 1 ); -} - void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; @@ -123,11 +113,11 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { */ if ( format_changed ) { if (this->output_open) - this->audio_out->close (this->audio_out); + this->stream->audio_out->close (this->stream->audio_out); this->ao_cap_mode=(this->number_of_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO; - this->output_open = this->audio_out->open (this->audio_out, + this->output_open = this->stream->audio_out->open (this->stream->audio_out, (this->bits_per_sample>16)?16:this->bits_per_sample, this->rate, this->ao_cap_mode) ; @@ -136,7 +126,7 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) ) return; - audio_buffer = this->audio_out->get_buffer (this->audio_out); + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); /* Swap LPCM samples into native byte order, if necessary */ buf->type &= 0xffff0000; @@ -176,40 +166,65 @@ void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { audio_buffer->vpts = buf->pts; audio_buffer->num_frames = (((buf->size*8)/this->number_of_channels)/this->bits_per_sample); - this->audio_out->put_buffer (this->audio_out, audio_buffer); + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer); } -void lpcm_close (audio_decoder_t *this_gen) { - +static void lpcm_dispose (audio_decoder_t *this_gen) { lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; if (this->output_open) - this->audio_out->close (this->audio_out); + this->stream->audio_out->close (this->stream->audio_out); this->output_open = 0; -} -static char *lpcm_get_id(void) { - return "Linear PCM"; -} - -static void lpcm_dispose (audio_decoder_t *this_gen) { free (this_gen); } -static void *init_audio_decoder_plugin (xine_t *xine, void *data) { +static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) { lpcm_decoder_t *this ; this = (lpcm_decoder_t *) malloc (sizeof (lpcm_decoder_t)); - this->audio_decoder.init = lpcm_init; this->audio_decoder.decode_data = lpcm_decode_data; this->audio_decoder.reset = lpcm_reset; - this->audio_decoder.close = lpcm_close; - this->audio_decoder.get_identifier = lpcm_get_id; this->audio_decoder.dispose = lpcm_dispose; - + + this->output_open = 0; + this->rate = 0; + this->bits_per_sample=0; + this->number_of_channels=0; + this->ao_cap_mode=0; + this->stream = stream; + + this->cpu_be = ( htons(1) == 1 ); + + return &this->audio_decoder; +} + +static char *get_identifier (audio_decoder_class_t *this) { + return "Linear PCM"; +} + +static char *get_description (audio_decoder_class_t *this) { + return "Linear PCM audio decoder plugin"; +} + +static void dispose_class (audio_decoder_class_t *this) { + free (this); +} + +static void *init_plugin (xine_t *xine, void *data) { + + lpcm_class_t *this ; + + this = (lpcm_class_t *) malloc (sizeof (lpcm_class_t)); + + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; + return this; } @@ -224,6 +239,6 @@ static decoder_info_t dec_info_audio = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_DECODER, 9, "pcm", XINE_VERSION_CODE, &dec_info_audio, init_audio_decoder_plugin }, + { PLUGIN_AUDIO_DECODER, 10, "pcm", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |