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