summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_ac3.c75
-rw-r--r--src/demuxers/demux_aiff.c56
-rw-r--r--src/demuxers/demux_aud.c60
-rw-r--r--src/demuxers/demux_realaudio.c62
-rw-r--r--src/demuxers/demux_snd.c59
-rw-r--r--src/demuxers/demux_voc.c60
-rw-r--r--src/demuxers/demux_wav.c60
7 files changed, 223 insertions, 209 deletions
diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c
index 751a9acee..2e2945403 100644
--- a/src/demuxers/demux_ac3.c
+++ b/src/demuxers/demux_ac3.c
@@ -21,7 +21,7 @@
* This demuxer detects raw AC3 data in a file and shovels AC3 data
* directly to the AC3 decoder.
*
- * $Id: demux_ac3.c,v 1.6 2003/03/07 12:51:47 guenter Exp $
+ * $Id: demux_ac3.c,v 1.7 2003/03/31 19:31:54 tmmm Exp $
*
*/
@@ -64,6 +64,10 @@ typedef struct {
int frame_size;
int running_time;
+ /* This hack indicates that 2 bytes (0x0B77) have already been consumed
+ * from a non-seekable stream during the detection phase. */
+ int first_non_seekable_frame;
+
char last_mrl[1024];
} demux_ac3_t;
@@ -130,17 +134,34 @@ static const struct frmsize_s frmsizecod_tbl[64] =
static int open_ac3_file(demux_ac3_t *this) {
unsigned char preamble[AC3_PREAMBLE_BYTES];
+ unsigned char preview[MAX_PREVIEW_SIZE];
/* check if the sync mark matches up */
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, preamble, AC3_PREAMBLE_BYTES) !=
- AC3_PREAMBLE_BYTES)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, preamble, AC3_PREAMBLE_BYTES) !=
+ AC3_PREAMBLE_BYTES)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ this->first_non_seekable_frame = 1;
+
+ /* copy over the header bytes for processing */
+ memcpy(preamble, preview, AC3_PREAMBLE_BYTES);
+ }
if ((preamble[0] != 0x0B) ||
(preamble[1] != 0x77))
return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, AC3_PREAMBLE_BYTES, SEEK_SET);
+ }
+
this->sample_rate = preamble[4] >> 6;
if (this->sample_rate > 2)
return 0;
@@ -168,13 +189,12 @@ static int demux_ac3_send_chunk (demux_plugin_t *this_gen) {
demux_ac3_t *this = (demux_ac3_t *) this_gen;
buf_element_t *buf = NULL;
- off_t current_file_pos;
+ off_t current_stream_pos;
int64_t audio_pts;
- int bytes_read;
int frame_number;
- current_file_pos = this->input->get_current_pos(this->input);
- frame_number = current_file_pos / this->frame_size;
+ current_stream_pos = this->input->get_current_pos(this->input);
+ frame_number = current_stream_pos / this->frame_size;
/*
* Each frame represents 256 new audio samples according to the a52 spec.
@@ -198,16 +218,24 @@ static int demux_ac3_send_chunk (demux_plugin_t *this_gen) {
}
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_A52;
- bytes_read = this->input->read(this->input, buf->content, this->frame_size);
- if (bytes_read == 0) {
+ if (this->first_non_seekable_frame) {
+ this->first_non_seekable_frame = 0;
+ buf->content[0] = 0x0B;
+ buf->content[1] = 0x77;
+ buf->size = this->input->read(this->input, &buf->content[2],
+ this->frame_size);
+ } else {
+ buf->size = this->input->read(this->input, buf->content, this->frame_size);
+ }
+
+ if (buf->size == 0) {
buf->free_buffer(buf);
this->status = DEMUX_FINISHED;
return this->status;
}
- buf->size = bytes_read;
- buf->extra_info->input_pos = current_file_pos;
+ buf->type = BUF_AUDIO_A52;
+ buf->extra_info->input_pos = current_stream_pos;
buf->extra_info->input_length = this->input->get_length(this->input);
buf->extra_info->input_time = audio_pts / 90;
buf->pts = audio_pts;
@@ -250,16 +278,21 @@ static int demux_ac3_seek (demux_plugin_t *this_gen,
demux_ac3_t *this = (demux_ac3_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* divide the requested offset integer-wise by the frame alignment and
* multiply by the frame alignment to determine the new starting block */
start_pos /= this->frame_size;
start_pos *= this->frame_size;
this->input->seek(this->input, start_pos, SEEK_SET);
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
return this->status;
}
@@ -298,12 +331,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_ac3_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_ac3.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_ac3_t));
this->stream = stream;
this->input = input;
diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c
index 1ba9c8a0f..ba235e758 100644
--- a/src/demuxers/demux_aiff.c
+++ b/src/demuxers/demux_aiff.c
@@ -19,7 +19,7 @@
*
* AIFF File Demuxer by Mike Melanson (melanson@pcisys.net)
*
- * $Id: demux_aiff.c,v 1.28 2003/03/07 12:51:47 guenter Exp $
+ * $Id: demux_aiff.c,v 1.29 2003/03/31 19:31:54 tmmm Exp $
*
*/
@@ -107,17 +107,32 @@ static int open_aiff_file(demux_aiff_t *this) {
unsigned int chunk_type;
unsigned int chunk_size;
unsigned char buffer[100];
+ unsigned char preview[MAX_PREVIEW_SIZE];
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, signature, AIFF_SIGNATURE_SIZE) !=
- AIFF_SIGNATURE_SIZE)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, signature, AIFF_SIGNATURE_SIZE) !=
+ AIFF_SIGNATURE_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(signature, preview, AIFF_SIGNATURE_SIZE);
+ }
/* check the signature */
if ((BE_32(&signature[0]) != FORM_TAG) ||
(BE_32(&signature[8]) != AIFF_TAG))
return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, AIFF_SIGNATURE_SIZE, SEEK_SET);
+ }
+
/* audio type is PCM unless proven otherwise */
this->audio_type = BUF_AUDIO_LPCM_BE;
this->audio_frames = 0;
@@ -285,6 +300,15 @@ static int demux_aiff_seek (demux_plugin_t *this_gen,
demux_aiff_t *this = (demux_aiff_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* check the boundary offsets */
if (start_pos < 0)
this->input->seek(this->input, this->data_start, SEEK_SET);
@@ -304,10 +328,6 @@ static int demux_aiff_seek (demux_plugin_t *this_gen,
this->input->seek(this->input, start_pos, SEEK_SET);
}
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
return this->status;
}
@@ -348,12 +368,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_aiff_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_aiff.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_aiff_t));
this->stream = stream;
this->input = input;
@@ -462,15 +476,3 @@ void *demux_aiff_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "aiff", XINE_VERSION_CODE, NULL, demux_aiff_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif
diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c
index 93573859a..8055f9619 100644
--- a/src/demuxers/demux_aud.c
+++ b/src/demuxers/demux_aud.c
@@ -32,7 +32,7 @@
* data. This makes seeking conceptually impossible. Upshot: Random
* seeking is not supported.
*
- * $Id: demux_aud.c,v 1.5 2003/03/07 12:51:47 guenter Exp $
+ * $Id: demux_aud.c,v 1.6 2003/03/31 19:31:54 tmmm Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -101,11 +101,20 @@ typedef struct {
static int open_aud_file(demux_aud_t *this) {
unsigned char header[AUD_HEADER_SIZE];
-
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, AUD_HEADER_SIZE) !=
- AUD_HEADER_SIZE)
- return 0;
+ unsigned char preview[MAX_PREVIEW_SIZE];
+
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, header, AUD_HEADER_SIZE) !=
+ AUD_HEADER_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(header, preview, AUD_HEADER_SIZE);
+ }
/* Probabilistic content detection strategy: There is no file signature
* so perform sanity checks on various header parameters:
@@ -120,6 +129,12 @@ static int open_aud_file(demux_aud_t *this) {
if ((this->audio_samplerate < 8000) || (this->audio_samplerate > 48000))
return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, AUD_HEADER_SIZE, SEEK_SET);
+ }
+
if (header[11] == 1)
this->audio_type = BUF_AUDIO_WESTWOOD;
else if (header[11] == 99)
@@ -242,17 +257,17 @@ static int demux_aud_seek (demux_plugin_t *this_gen,
demux_aud_t *this = (demux_aud_t *) this_gen;
- /* if thread is not running, initialize demuxer */
- if( !this->stream->demux_thread_running ) {
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
- /* send new pts */
- xine_demux_control_newpts(this->stream, 0, 0);
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
- this->status = DEMUX_OK;
- /* reposition stream right after headers */
- this->input->seek(this->input, this->data_start, SEEK_SET);
- }
+ /* no seeking yet */
+
return this->status;
}
@@ -288,12 +303,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_aud_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_aud.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_aud_t));
this->stream = stream;
this->input = input;
@@ -399,14 +408,3 @@ void *demux_aud_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "aud", XINE_VERSION_CODE, NULL, demux_aud_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif
diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c
index 0f1e5671c..c8a32fc18 100644
--- a/src/demuxers/demux_realaudio.c
+++ b/src/demuxers/demux_realaudio.c
@@ -19,7 +19,7 @@
*
* RealAudio File Demuxer by Mike Melanson (melanson@pcisys.net)
*
- * $Id: demux_realaudio.c,v 1.17 2003/03/07 12:51:48 guenter Exp $
+ * $Id: demux_realaudio.c,v 1.18 2003/03/31 19:31:56 tmmm Exp $
*
*/
@@ -85,18 +85,33 @@ static int open_ra_file(demux_ra_t *this) {
unsigned char file_header[RA_FILE_HEADER_SIZE];
unsigned char audio_header[RA_AUDIO_HEADER_SIZE];
+ unsigned char preview[MAX_PREVIEW_SIZE];
/* check the signature */
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, file_header, RA_FILE_HEADER_SIZE) !=
- RA_FILE_HEADER_SIZE)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, file_header, RA_FILE_HEADER_SIZE) !=
+ RA_FILE_HEADER_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(file_header, preview, RA_FILE_HEADER_SIZE);
+ }
if ((file_header[0] != '.') ||
(file_header[1] != 'r') ||
(file_header[2] != 'a'))
return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, RA_FILE_HEADER_SIZE, SEEK_SET);
+ }
+
/* load the audio header */
if (this->input->read(this->input, audio_header, RA_AUDIO_HEADER_SIZE) !=
RA_AUDIO_HEADER_SIZE)
@@ -219,6 +234,15 @@ static int demux_ra_seek (demux_plugin_t *this_gen,
demux_ra_t *this = (demux_ra_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* check the boundary offsets */
if (start_pos <= 0)
this->input->seek(this->input, this->data_start, SEEK_SET);
@@ -238,16 +262,6 @@ static int demux_ra_seek (demux_plugin_t *this_gen,
this->input->seek(this->input, start_pos, SEEK_SET);
}
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
- /* if thread is not running, initialize demuxer */
- if( !this->stream->demux_thread_running ) {
-
- this->status = DEMUX_OK;
- }
-
return this->status;
}
@@ -290,12 +304,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_ra_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_ra.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_ra_t));
this->stream = stream;
this->input = input;
@@ -402,15 +410,3 @@ void *demux_realaudio_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "realaudio", XINE_VERSION_CODE, NULL, demux_realaudio_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif
diff --git a/src/demuxers/demux_snd.c b/src/demuxers/demux_snd.c
index 8898460e5..831ad542c 100644
--- a/src/demuxers/demux_snd.c
+++ b/src/demuxers/demux_snd.c
@@ -19,7 +19,7 @@
*
* SND/AU File Demuxer by Mike Melanson (melanson@pcisys.net)
*
- * $Id: demux_snd.c,v 1.27 2003/03/07 12:51:48 guenter Exp $
+ * $Id: demux_snd.c,v 1.28 2003/03/31 19:31:56 tmmm Exp $
*
*/
@@ -92,21 +92,31 @@ typedef struct {
static int open_snd_file(demux_snd_t *this) {
unsigned char header[SND_HEADER_SIZE];
+ unsigned char preview[MAX_PREVIEW_SIZE];
unsigned int encoding;
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, SND_HEADER_SIZE) !=
- SND_HEADER_SIZE)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, header, SND_HEADER_SIZE) !=
+ SND_HEADER_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(header, preview, SND_HEADER_SIZE);
+ }
/* check the signature */
if (BE_32(&header[0]) != snd_TAG)
return 0;
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, SND_HEADER_SIZE) !=
- SND_HEADER_SIZE)
- return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, SND_HEADER_SIZE, SEEK_SET);
+ }
this->data_start = BE_32(&header[0x04]);
this->data_size = BE_32(&header[0x08]);
@@ -257,6 +267,15 @@ static int demux_snd_seek (demux_plugin_t *this_gen,
demux_snd_t *this = (demux_snd_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* check the boundary offsets */
if (start_pos < 0)
this->input->seek(this->input, this->data_start, SEEK_SET);
@@ -276,10 +295,6 @@ static int demux_snd_seek (demux_plugin_t *this_gen,
this->input->seek(this->input, start_pos, SEEK_SET);
}
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
return this->status;
}
@@ -318,12 +333,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_snd_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_snd.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_snd_t));
this->stream = stream;
this->input = input;
@@ -434,15 +443,3 @@ void *demux_snd_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "snd", XINE_VERSION_CODE, NULL, demux_snd_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif
diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c
index 7eb42fa83..76e19524c 100644
--- a/src/demuxers/demux_voc.c
+++ b/src/demuxers/demux_voc.c
@@ -23,7 +23,7 @@
* It will only play that block if it is PCM data. More variations will be
* supported as they are encountered.
*
- * $Id: demux_voc.c,v 1.28 2003/03/07 12:51:48 guenter Exp $
+ * $Id: demux_voc.c,v 1.29 2003/03/31 19:31:58 tmmm Exp $
*
*/
@@ -96,21 +96,30 @@ static int open_voc_file(demux_voc_t *this) {
unsigned char preamble[BLOCK_PREAMBLE_SIZE];
off_t first_block_offset;
signed char sample_rate_divisor;
+ unsigned char preview[MAX_PREVIEW_SIZE];
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, VOC_HEADER_SIZE) !=
- VOC_HEADER_SIZE)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, header, VOC_HEADER_SIZE) !=
+ VOC_HEADER_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(header, preview, VOC_HEADER_SIZE);
+ }
/* check the signature */
if (strncmp(header, VOC_SIGNATURE, strlen(VOC_SIGNATURE)) != 0)
return 0;
- /* load the header */
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, VOC_HEADER_SIZE) !=
- VOC_HEADER_SIZE)
- return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, VOC_HEADER_SIZE, SEEK_SET);
+ }
first_block_offset = LE_16(&header[0x14]);
this->input->seek(this->input, first_block_offset, SEEK_SET);
@@ -256,6 +265,15 @@ static int demux_voc_seek (demux_plugin_t *this_gen,
demux_voc_t *this = (demux_voc_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* check the boundary offsets */
if (start_pos < 0)
this->input->seek(this->input, this->data_start, SEEK_SET);
@@ -275,10 +293,6 @@ static int demux_voc_seek (demux_plugin_t *this_gen,
this->input->seek(this->input, start_pos, SEEK_SET);
}
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
return this->status;
}
@@ -317,12 +331,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_voc_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_voc.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_voc_t));
this->stream = stream;
this->input = input;
@@ -429,15 +437,3 @@ void *demux_voc_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "voc", XINE_VERSION_CODE, NULL, demux_voc_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif
diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c
index b0f36a3dc..ee73b7b98 100644
--- a/src/demuxers/demux_wav.c
+++ b/src/demuxers/demux_wav.c
@@ -20,7 +20,7 @@
* MS WAV File Demuxer by Mike Melanson (melanson@pcisys.net)
* based on WAV specs that are available far and wide
*
- * $Id: demux_wav.c,v 1.38 2003/03/07 12:51:48 guenter Exp $
+ * $Id: demux_wav.c,v 1.39 2003/03/31 19:31:58 tmmm Exp $
*
*/
@@ -90,12 +90,21 @@ static int open_wav_file(demux_wav_t *this) {
unsigned int chunk_tag;
unsigned int chunk_size;
unsigned char chunk_preamble[8];
+ unsigned char preview[MAX_PREVIEW_SIZE];
/* check the signature */
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, signature, WAV_SIGNATURE_SIZE) !=
- WAV_SIGNATURE_SIZE)
- return 0;
+ if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, signature, WAV_SIGNATURE_SIZE) !=
+ WAV_SIGNATURE_SIZE)
+ return 0;
+ } else {
+ this->input->get_optional_data(this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+
+ /* copy over the header bytes for processing */
+ memcpy(signature, preview, WAV_SIGNATURE_SIZE);
+ }
if ((signature[0] != 'R') ||
(signature[1] != 'I') ||
@@ -111,6 +120,12 @@ static int open_wav_file(demux_wav_t *this) {
(signature[15] != ' '))
return 0;
+ /* file is qualified; if the input was not seekable, skip over the header
+ * bytes in the stream */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
+ this->input->seek(this->input, WAV_SIGNATURE_SIZE, SEEK_SET);
+ }
+
/* go after the format structure */
if (this->input->read(this->input,
(unsigned char *)&this->wave_size, 4) != 4)
@@ -252,6 +267,15 @@ static int demux_wav_seek (demux_plugin_t *this_gen,
demux_wav_t *this = (demux_wav_t *) this_gen;
+ this->seek_flag = 1;
+ this->status = DEMUX_OK;
+ xine_demux_flush_engine (this->stream);
+
+ /* if input is non-seekable, do not proceed with the rest of this
+ * seek function */
+ if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ return this->status;
+
/* check the boundary offsets */
if (start_pos <= 0)
this->input->seek(this->input, this->data_start, SEEK_SET);
@@ -271,14 +295,6 @@ static int demux_wav_seek (demux_plugin_t *this_gen,
this->input->seek(this->input, start_pos, SEEK_SET);
}
- this->seek_flag = 1;
- this->status = DEMUX_OK;
- xine_demux_flush_engine (this->stream);
-
- /* if thread is not running, initialize demuxer */
- if( !this->stream->demux_thread_running ) {
- }
-
return this->status;
}
@@ -318,12 +334,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_wav_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_wav.c: input not seekable, can not handle!\n"));
- return NULL;
- }
-
this = xine_xmalloc (sizeof (demux_wav_t));
this->stream = stream;
this->input = input;
@@ -439,15 +449,3 @@ void *demux_wav_init_plugin (xine_t *xine, void *data) {
return this;
}
-
-/*
- * exported plugin catalog entry
- */
-
-#if 0
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "wav", XINE_VERSION_CODE, NULL, demux_wav_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-#endif