summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_wav.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_wav.c')
-rw-r--r--src/demuxers/demux_wav.c60
1 files changed, 29 insertions, 31 deletions
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