diff options
author | Mike Melanson <mike@multimedia.cx> | 2002-10-23 04:05:07 +0000 |
---|---|---|
committer | Mike Melanson <mike@multimedia.cx> | 2002-10-23 04:05:07 +0000 |
commit | d56492d8c02027780271ff4c253b7a8bc2618c5c (patch) | |
tree | 442eed74dd6d1cf12b61a1eada1df9bc22a8c72b | |
parent | a9421aeb3412500c17c63481cf0ec05aa0304232 (diff) | |
download | xine-lib-d56492d8c02027780271ff4c253b7a8bc2618c5c.tar.gz xine-lib-d56492d8c02027780271ff4c253b7a8bc2618c5c.tar.bz2 |
bring the log PCM decoder in line with the latest API revision
CVS patchset: 2952
CVS date: 2002/10/23 04:05:07
-rw-r--r-- | src/libxineadec/logpcm.c | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/src/libxineadec/logpcm.c b/src/libxineadec/logpcm.c index 499937be2..190879479 100644 --- a/src/libxineadec/logpcm.c +++ b/src/libxineadec/logpcm.c @@ -30,7 +30,7 @@ * http://sox.sourceforge.net/ * which listed the code as being lifted from Sun Microsystems. * - * $Id: logpcm.c,v 1.5 2002/09/05 22:19:01 mroi Exp $ + * $Id: logpcm.c,v 1.6 2002/10/23 04:05:07 tmmm Exp $ * */ @@ -51,14 +51,20 @@ #define AUDIOBUFSIZE 128*1024 #define LOGPCM_BITS_PER_SAMPLE 16 +typedef struct { + audio_decoder_class_t decoder_class; +} logpcm_class_t; + typedef struct logpcm_decoder_s { audio_decoder_t audio_decoder; + xine_stream_t *stream; + int64_t pts; - ao_instance_t *audio_out; int output_open; int output_channels; + int samplerate; unsigned char *buf; int bufsize; @@ -137,17 +143,6 @@ static int alaw2linear(unsigned char a_val) { } -static void logpcm_reset (audio_decoder_t *this_gen) { -} - -static void logpcm_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { - - logpcm_decoder_t *this = (logpcm_decoder_t *) this_gen; - - this->audio_out = audio_out; - this->output_open = 0; -} - static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { logpcm_decoder_t *this = (logpcm_decoder_t *) this_gen; @@ -158,6 +153,7 @@ static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (buf->decoder_flags & BUF_FLAG_HEADER) { + this->samplerate = buf->decoder_info[1]; this->output_channels = buf->decoder_info[3]; this->buf = xine_xmalloc(AUDIOBUFSIZE); this->bufsize = AUDIOBUFSIZE; @@ -175,9 +171,9 @@ static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } if (!this->output_open) { - this->output_open = this->audio_out->open(this->audio_out, - LOGPCM_BITS_PER_SAMPLE, buf->decoder_info[1], - (buf->decoder_info[3] == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO); + this->output_open = this->stream->audio_out->open(this->stream->audio_out, + LOGPCM_BITS_PER_SAMPLE, this->samplerate, + (this->output_channels == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO); } /* if the audio still isn't open, bail */ @@ -200,9 +196,9 @@ static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { in = 0; while (in < this->size) { - audio_buffer = this->audio_out->get_buffer (this->audio_out); + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); if (audio_buffer->mem_size == 0) { - printf ("adpcm: Help! Allocated audio buffer with nothing in it!\n"); + printf ("logpcm: Help! Allocated audio buffer with nothing in it!\n"); return; } @@ -219,7 +215,7 @@ static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { audio_buffer->num_frames = bytes_to_send / this->output_channels; audio_buffer->vpts = buf->pts; buf->pts = 0; /* only first buffer gets the real pts */ - this->audio_out->put_buffer (this->audio_out, audio_buffer); + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer); } /* reset internal accumulation buffer */ @@ -227,47 +223,74 @@ static void logpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } } -static void logpcm_close (audio_decoder_t *this_gen) { +static void logpcm_reset (audio_decoder_t *this_gen) { +} + +static void logpcm_dispose (audio_decoder_t *this_gen) { + logpcm_decoder_t *this = (logpcm_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 *logpcm_get_id(void) { - return "Logarithmic PCM"; -} - -static void logpcm_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) { - logpcm_decoder_t *this; + logpcm_decoder_t *this ; this = (logpcm_decoder_t *) malloc (sizeof (logpcm_decoder_t)); - this->audio_decoder.init = logpcm_init; this->audio_decoder.decode_data = logpcm_decode_data; this->audio_decoder.reset = logpcm_reset; - this->audio_decoder.close = logpcm_close; - this->audio_decoder.get_identifier = logpcm_get_id; this->audio_decoder.dispose = logpcm_dispose; - return (audio_decoder_t *) this; + this->output_open = 0; + this->output_channels = 0; + this->stream = stream; + this->buf = NULL; + this->size = 0; + + return &this->audio_decoder; +} + +static char *get_identifier (audio_decoder_class_t *this) { + return "Log PCM"; +} + +static char *get_description (audio_decoder_class_t *this) { + return "Logarithmic PCM audio format decoder plugin"; +} + +static void dispose_class (audio_decoder_class_t *this) { + free (this); +} + +static void *init_plugin (xine_t *xine, void *data) { + + logpcm_class_t *this ; + + this = (logpcm_class_t *) malloc (sizeof (logpcm_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; } static uint32_t audio_types[] = { BUF_AUDIO_MULAW, BUF_AUDIO_ALAW, 0 }; static decoder_info_t dec_info_audio = { audio_types, /* supported types */ - 5 /* priority */ + 9 /* priority */ }; plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_DECODER, 9, "Logarithmic PCM", XINE_VERSION_CODE, &dec_info_audio, &init_audio_decoder_plugin }, + { PLUGIN_AUDIO_DECODER, 10, "logpcm", XINE_VERSION_CODE, &dec_info_audio, &init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |