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