summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_ac3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_ac3.c')
-rw-r--r--src/demuxers/demux_ac3.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c
index fa2dddfed..7f3dadeb7 100644
--- a/src/demuxers/demux_ac3.c
+++ b/src/demuxers/demux_ac3.c
@@ -23,7 +23,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.19 2005/06/04 20:32:08 jstembridge Exp $
+ * $Id: demux_ac3.c,v 1.21 2007/03/19 16:42:32 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -51,7 +51,6 @@
#include "group_audio.h"
#define DATA_TAG 0x61746164
-#define PEAK_SIZE 7056 /* 3 raw cd frames */
typedef struct {
demux_plugin_t demux_plugin;
@@ -129,31 +128,29 @@ static const struct frmsize_s frmsizecod_tbl[64] =
static int open_ac3_file(demux_ac3_t *this) {
int i;
int offset = 0;
- int peak_size = 0;
+ size_t peak_size = 0;
int spdif_mode = 0;
uint32_t syncword = 0;
uint32_t blocksize;
- uint8_t peak[PEAK_SIZE];
+ uint8_t *peak;
- lprintf("open_ac3_file\n");
-
- /* block based demuxer (i.e. cdda) will only allow reads in block
- * sized pieces */
blocksize = this->input->get_blocksize(this->input);
- if (blocksize && INPUT_IS_SEEKABLE(this->input)) {
- int read;
-
+ if (blocksize) {
this->input->seek(this->input, 0, SEEK_SET);
- while (peak_size < PEAK_SIZE) {
- read = this->input->read(this->input, &peak[peak_size], blocksize);
- if (read)
- peak_size += read;
- else
- break;
- }
+ buf_element_t *buf = this->input->read_block(this->input,
+ this->audio_fifo,
+ blocksize);
this->input->seek(this->input, 0, SEEK_SET);
+
+ if (!buf)
+ return 0;
+
+ peak = alloca(peak_size = buf->size);
+ xine_fast_memcpy(peak, buf->content, peak_size);
+
+ buf->free_buffer(buf);
} else {
- peak_size = MAX_PREVIEW_SIZE;
+ peak = alloca(peak_size = MAX_PREVIEW_SIZE);
if (_x_demux_read_header(this->input, peak, peak_size) != peak_size)
return 0;
@@ -163,10 +160,7 @@ static int open_ac3_file(demux_ac3_t *this) {
/* Check for wav header, as we'll handle AC3 with a wav header shoved
* on the front for CD burning */
- if ((peak[0] == 'R') && (peak[1] == 'I') && (peak[2] == 'F') &&
- (peak[3] == 'F') && (peak[8] == 'W') && (peak[9] == 'A') &&
- (peak[10] == 'V') && (peak[11] == 'E') && (peak[12] == 'f') &&
- (peak[13] == 'm') && (peak[14] == 't') && (peak[15] == ' ')) {
+ if ( memcmp(peak, "RIFF", 4) == 0 || memcmp(&peak[8], "WAVEfmt ", 8) == 0 ) {
/* Check this looks like a cd audio wav */
unsigned int audio_type;
xine_waveformatex *wave = (xine_waveformatex *) &peak[20];
@@ -441,7 +435,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: {
- char *extensions, *mrl;
+ const char *extensions, *mrl;
mrl = input->get_mrl (input);
extensions = class_gen->get_extensions (class_gen);
@@ -471,19 +465,19 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static char *get_description (demux_class_t *this_gen) {
+static const char *get_description (demux_class_t *this_gen) {
return "Raw AC3 demux plugin";
}
-static char *get_identifier (demux_class_t *this_gen) {
+static const char *get_identifier (demux_class_t *this_gen) {
return "AC3";
}
-static char *get_extensions (demux_class_t *this_gen) {
+static const char *get_extensions (demux_class_t *this_gen) {
return "ac3";
}
-static char *get_mimetypes (demux_class_t *this_gen) {
+static const char *get_mimetypes (demux_class_t *this_gen) {
return NULL;
}