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.c103
1 files changed, 31 insertions, 72 deletions
diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c
index f88c58572..51bc624e3 100644
--- a/src/demuxers/demux_aiff.c
+++ b/src/demuxers/demux_aiff.c
@@ -15,14 +15,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* AIFF File Demuxer by Mike Melanson (melanson@pcisys.net)
- *
- * $Id: demux_aiff.c,v 1.41 2007/01/19 00:26:40 dgp85 Exp $
- *
*/
#ifdef HAVE_CONFIG_H
@@ -36,10 +33,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -90,14 +87,13 @@ static int open_aiff_file(demux_aiff_t *this) {
unsigned char preamble[PREAMBLE_SIZE];
unsigned int chunk_type;
unsigned int chunk_size;
- unsigned char buffer[100];
if (_x_demux_read_header(this->input, signature, AIFF_SIGNATURE_SIZE) != AIFF_SIGNATURE_SIZE)
return 0;
/* check the signature */
- if ((BE_32(&signature[0]) != FORM_TAG) ||
- (BE_32(&signature[8]) != AIFF_TAG))
+ if ((_X_BE_32(&signature[0]) != FORM_TAG) ||
+ (_X_BE_32(&signature[8]) != AIFF_TAG))
return 0;
/* file is qualified; skip over the header bytes in the stream */
@@ -118,26 +114,28 @@ static int open_aiff_file(demux_aiff_t *this) {
this->status = DEMUX_FINISHED;
return 0;
}
- chunk_type = BE_32(&preamble[0]);
- chunk_size = BE_32(&preamble[4]);
+ chunk_type = _X_BE_32(&preamble[0]);
+ chunk_size = _X_BE_32(&preamble[4]);
- if (chunk_size > sizeof(buffer) / sizeof(buffer[0])) {
- /* the chunk is too large to fit in the buffer -> this cannot be an aiff chunk */
- this->status = DEMUX_FINISHED;
- return 0;
- }
-
if (chunk_type == COMM_TAG) {
+ unsigned char buffer[100];
+
+ if (chunk_size > sizeof(buffer) / sizeof(buffer[0])) {
+ /* the chunk is too large to fit in the buffer -> this cannot be an aiff chunk */
+ this->status = DEMUX_FINISHED;
+ return 0;
+ }
+
if (this->input->read(this->input, buffer, chunk_size) !=
chunk_size) {
this->status = DEMUX_FINISHED;
return 0;
}
- this->audio_channels = BE_16(&buffer[0]);
- this->audio_frames = BE_32(&buffer[2]);
- this->audio_bits = BE_16(&buffer[6]);
- this->audio_sample_rate = BE_16(&buffer[0x0A]);
+ this->audio_channels = _X_BE_16(&buffer[0]);
+ this->audio_frames = _X_BE_32(&buffer[2]);
+ this->audio_bits = _X_BE_16(&buffer[6]);
+ this->audio_sample_rate = _X_BE_16(&buffer[0x0A]);
this->audio_bytes_per_second = this->audio_channels *
(this->audio_bits / 8) * this->audio_sample_rate;
@@ -307,12 +305,6 @@ static int demux_aiff_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_aiff_dispose (demux_plugin_t *this_gen) {
- demux_aiff_t *this = (demux_aiff_t *) this_gen;
-
- free(this);
-}
-
static int demux_aiff_get_status (demux_plugin_t *this_gen) {
demux_aiff_t *this = (demux_aiff_t *) this_gen;
@@ -347,7 +339,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_aiff_send_headers;
this->demux_plugin.send_chunk = demux_aiff_send_chunk;
this->demux_plugin.seek = demux_aiff_seek;
- this->demux_plugin.dispose = demux_aiff_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_aiff_get_status;
this->demux_plugin.get_stream_length = demux_aiff_get_stream_length;
this->demux_plugin.get_capabilities = demux_aiff_get_capabilities;
@@ -358,19 +350,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -389,41 +369,20 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "AIFF file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "AIFF";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "aif aiff";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-aiff: aif, aiff: AIFF audio;"
- "audio/aiff: aif, aiff: AIFF audio;"
- "audio/x-pn-aiff: aif, aiff: AIFF audio;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_aiff_class_t *this = (demux_aiff_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_aiff_init_plugin (xine_t *xine, void *data) {
demux_aiff_class_t *this;
this = xine_xmalloc (sizeof (demux_aiff_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("AIFF file demux plugin");
+ this->demux_class.identifier = "AIFF";
+ this->demux_class.mimetypes =
+ "audio/x-aiff: aif, aiff: AIFF audio;"
+ "audio/aiff: aif, aiff: AIFF audio;"
+ "audio/x-pn-aiff: aif, aiff: AIFF audio;";
+ this->demux_class.extensions = "aif aiff";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}