summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_aac.c2
-rw-r--r--src/demuxers/demux_flac.c25
-rw-r--r--src/demuxers/demux_mpgaudio.c3
-rw-r--r--src/demuxers/id3.c40
-rw-r--r--src/demuxers/id3.h40
-rw-r--r--src/input/input_http.c11
-rw-r--r--src/libxineadec/xine_speex_decoder.c21
-rw-r--r--src/xine-utils/monitor.c13
8 files changed, 67 insertions, 88 deletions
diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c
index ab71e8382..1775a4e0e 100644
--- a/src/demuxers/demux_aac.c
+++ b/src/demuxers/demux_aac.c
@@ -84,7 +84,7 @@ static int open_aac_file(demux_aac_t *this) {
/* Check if there's an ID3v2 tag at the start */
if ( id3v2_istag(peak) ) {
- id3size = id3v2_tagsize(&peak[6]);
+ id3size = BE_32_synchsafe(&peak[6]);
this->input->seek(this->input, 4, SEEK_SET);
diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c
index 116409d1f..ac7458726 100644
--- a/src/demuxers/demux_flac.c
+++ b/src/demuxers/demux_flac.c
@@ -90,37 +90,24 @@ static int open_flac_file(demux_flac_t *flac) {
flac->seekpoints = NULL;
- /* fetch the file signature, get enough bytes so that id3 can also
- be skipped and/or parsed */
- if (_x_demux_read_header(flac->input, preamble, 10) != 10)
+ /* fetch the file signature, 4 bytes will read both the fLaC
+ * signature and the */
+ if (_x_demux_read_header(flac->input, preamble, 4) != 4)
return 0;
+ flac->input->seek(flac->input, 4, SEEK_SET);
+
/* Unfortunately some FLAC files have an ID3 flag prefixed on them
* before the actual FLAC headers... these are barely legal, but
* users use them and want them working, so check and skip the ID3
* tag if present.
*/
if ( id3v2_istag(preamble) ) {
- uint32_t id3size;
-
- /* First 3 bytes are the ID3 signature as above, then comes two bytes
- * encoding the major and minor version of ID3 used, that we can ignore
- * as long as we don't try to read the metadata; after those there's a
- * single byte with flags that depends on the ID3 version used; and now
- * after all that stuff, there's the size of the rest of the tag, which
- * is encoded as four bytes.. but only 7 out of 8 bits of every byte is
- * used... don't ask.
- */
- id3size = id3v2_tagsize(&preamble[6]);
-
id3v2_parse_tag(flac->input, flac->stream, preamble);
- flac->input->seek(flac->input, id3size, SEEK_SET);
-
if ( flac->input->read(flac->input, preamble, 4) != 4 )
return 0;
- } else
- flac->input->seek(flac->input, 4, SEEK_SET);
+ }
/* validate signature */
if ((preamble[0] != 'f') || (preamble[1] != 'L') ||
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index bd55c9f0a..64bae2794 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -697,8 +697,7 @@ static int detect_mpgaudio_file(input_plugin_t *input) {
* id3v2 are not specific to mp3 files,
* flac files can contain id3v2 tags
*/
- uint8_t *ptr = &buf[6];
- uint32_t tag_size = id3v2_tagsize(ptr);
+ uint32_t tag_size = BE_32_synchsafe(&buf[6]);
lprintf("try to skip id3v2 tag (%d bytes)\n", tag_size);
if ((10 + tag_size) >= preview_len) {
lprintf("cannot skip id3v2 tag\n");
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c
index b707166b6..a59eb6259 100644
--- a/src/demuxers/id3.c
+++ b/src/demuxers/id3.c
@@ -227,38 +227,6 @@ static int id3v2_parse_genre(char* dest, char *src, int len) {
return 1;
}
-#if 0
-/* parse an unsynchronized 16bits integer */
-static uint16_t BE_16_synchsafe(uint8_t buf[2]) {
- return ((uint16_t)(buf[0] & 0x7F) << 7) |
- (uint16_t)(buf[1] & 0x7F);
-}
-#endif
-
-/* parse an unsynchronized 24bits integer */
-static uint32_t BE_24_synchsafe(uint8_t buf[3]) {
- return ((uint32_t)(buf[0] & 0x7F) << 14) |
- ((uint32_t)(buf[1] & 0x7F) << 7) |
- (uint32_t)(buf[2] & 0x7F);
-}
-
-/* parse an unsynchronized 32bits integer */
-static uint32_t BE_32_synchsafe(uint8_t buf[4]) {
- return ((uint32_t)(buf[0] & 0x7F) << 21) |
- ((uint32_t)(buf[1] & 0x7F) << 14) |
- ((uint32_t)(buf[2] & 0x7F) << 7) |
- (uint32_t)(buf[3] & 0x7F);
-}
-
-/* parse an unsynchronized 35bits integer */
-static uint32_t BE_35_synchsafe(uint8_t buf[5]) {
- return ((uint32_t)(buf[0] & 0x07) << 28) |
- ((uint32_t)(buf[1] & 0x7F) << 21) |
- ((uint32_t)(buf[2] & 0x7F) << 14) |
- ((uint32_t)(buf[3] & 0x7F) << 7) |
- (uint32_t)(buf[4] & 0x7F);
-}
-
static int id3v2_parse_header(input_plugin_t *input, uint8_t *mp3_frame_header,
id3v2_header_t *tag_header) {
uint8_t buf[6];
@@ -379,7 +347,7 @@ int id3v22_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V22_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ "id3: invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -573,7 +541,7 @@ int id3v23_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V23_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ "id3: invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -824,7 +792,7 @@ int id3v24_parse_tag(input_plugin_t *input,
if (tag_header.flags & ID3V24_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ "id3: invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -898,7 +866,7 @@ int id3v2_parse_tag(input_plugin_t *input,
break;
case 4:
- xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n");
+ xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.4 tag\n");
result = id3v24_parse_tag(input, stream, mp3_frame_header);
break;
diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h
index 9d08f6817..b8f0984b1 100644
--- a/src/demuxers/id3.h
+++ b/src/demuxers/id3.h
@@ -170,6 +170,10 @@ int id3v2_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
int8_t *mp3_frame_header);
+/**
+ * @brief Checks if the given buffer is an ID3 tag preamble
+ * @param ptr Pointer to the first 10 bytes of the ID3 tag
+ */
static inline int id3v2_istag(uint8_t *ptr) {
return
(ptr[0] == 'I') &&
@@ -177,12 +181,36 @@ static inline int id3v2_istag(uint8_t *ptr) {
(ptr[2] == '3');
}
-static inline uint32_t id3v2_tagsize(uint8_t *ptr) {
- return
- ((uint32_t)ptr[0] << 21) +
- ((uint32_t)ptr[1] << 14) +
- ((uint32_t)ptr[2] << 7) +
- (uint32_t)ptr[3];
+#if 0
+/* parse an unsynchronized 16bits integer */
+static inline uint16_t BE_16_synchsafe(uint8_t buf[2]) {
+ return ((uint16_t)(buf[0] & 0x7F) << 7) |
+ (uint16_t)(buf[1] & 0x7F);
+}
+#endif
+
+/* parse an unsynchronized 24bits integer */
+static inline uint32_t BE_24_synchsafe(uint8_t buf[3]) {
+ return ((uint32_t)(buf[0] & 0x7F) << 14) |
+ ((uint32_t)(buf[1] & 0x7F) << 7) |
+ (uint32_t)(buf[2] & 0x7F);
+}
+
+/* parse an unsynchronized 32bits integer */
+static inline uint32_t BE_32_synchsafe(uint8_t buf[4]) {
+ return ((uint32_t)(buf[0] & 0x7F) << 21) |
+ ((uint32_t)(buf[1] & 0x7F) << 14) |
+ ((uint32_t)(buf[2] & 0x7F) << 7) |
+ (uint32_t)(buf[3] & 0x7F);
+}
+
+/* parse an unsynchronized 35bits integer */
+static inline uint32_t BE_35_synchsafe(uint8_t buf[5]) {
+ return ((uint32_t)(buf[0] & 0x07) << 28) |
+ ((uint32_t)(buf[1] & 0x7F) << 21) |
+ ((uint32_t)(buf[2] & 0x7F) << 14) |
+ ((uint32_t)(buf[3] & 0x7F) << 7) |
+ (uint32_t)(buf[4] & 0x7F);
}
#endif /* ID3_H */
diff --git a/src/input/input_http.c b/src/input/input_http.c
index 12b7f3f35..d1202ae14 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -832,11 +832,10 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
httpcode, httpstatus);
return -7;
} else if (httpcode == 401) {
- _x_message(this->stream, XINE_MSG_AUTHENTICATION_NEEDED, this->mrl, NULL);
xine_log (this->stream->xine, XINE_LOG_MSG,
_("input_http: http status not 2xx: >%d %s<\n"),
httpcode, httpstatus);
- return -8;
+ /* don't return - there may be a WWW-Authenticate header... */
} else if (httpcode == 403) {
_x_message(this->stream, XINE_MSG_PERMISSION_ERROR, this->mrl, NULL);
xine_log (this->stream->xine, XINE_LOG_MSG,
@@ -874,6 +873,10 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
return http_plugin_open(this_gen);
}
+ if (!strncasecmp (this->buf, "WWW-Authenticate: ", 18))
+ strcpy (this->preview, this->buf + 18);
+
+
/* Icecast / ShoutCast Stuff */
if (!strncasecmp(this->buf, TAG_ICY_NAME, sizeof(TAG_ICY_NAME) - 1)) {
_x_meta_info_set(this->stream, XINE_META_INFO_ALBUM,
@@ -933,6 +936,10 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
lprintf ("end of headers\n");
+ if (httpcode == 401)
+ _x_message(this->stream, XINE_MSG_AUTHENTICATION_NEEDED,
+ this->mrl, *this->preview ? this->preview : NULL, NULL);
+
/*
* fill preview buffer
*/
diff --git a/src/libxineadec/xine_speex_decoder.c b/src/libxineadec/xine_speex_decoder.c
index b729dc3bb..034e726a6 100644
--- a/src/libxineadec/xine_speex_decoder.c
+++ b/src/libxineadec/xine_speex_decoder.c
@@ -72,8 +72,6 @@ typedef struct speex_decoder_s {
SpeexStereoState stereo;
int expect_metadata;
- float output[MAX_FRAME_SIZE];
-
int header_count;
xine_stream_t *stream;
@@ -296,9 +294,8 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
for (j = 0; j < this->nframes; j++) {
int ret;
int bitrate;
- ogg_int16_t * ptr = audio_buffer->mem;
- ret = speex_decode (this->st, &this->bits, this->output);
+ ret = speex_decode_int (this->st, &this->bits, audio_buffer->mem);
if (ret==-1)
break;
@@ -312,27 +309,13 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
}
if (this->channels == 2) {
- speex_decode_stereo (this->output, this->frame_size, &this->stereo);
+ speex_decode_stereo_int (audio_buffer->mem, this->frame_size, &this->stereo);
}
speex_decoder_ctl (this->st, SPEEX_GET_BITRATE, &bitrate);
if (bitrate <= 1) bitrate = 16000; /* assume 16 kbit */
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, bitrate);
- /*PCM saturation (just in case)*/
- for (i=0; i < this->frame_size * this->channels; i++)
- {
- if (this->output[i]>32000.0)
- this->output[i]=32000.0;
- else if (this->output[i]<-32000.0)
- this->output[i]=-32000.0;
- }
-
- /*Convert to short and play */
- for (i=0; i< this->frame_size * this->channels; i++) {
- *ptr++ = (ogg_int16_t)this->output[i];
- }
-
audio_buffer->vpts = this->pts;
this->pts=0;
audio_buffer->num_frames = this->frame_size;
diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c
index 19a9dc977..b19195065 100644
--- a/src/xine-utils/monitor.c
+++ b/src/xine-utils/monitor.c
@@ -61,13 +61,20 @@ int xine_profiler_allocate_slot (const char *label) {
}
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-__inline__ unsigned long long int rdtsc(void)
+#if defined(ARCH_X86_32)
+static __inline__ unsigned long long int rdtsc(void)
{
unsigned long long int x;
- __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
+ __asm__ volatile ("rdtsc\n\t" : "=A" (x));
return x;
}
+#elif defined(ARCH_X86_64)
+static __inline__ unsigned long long int rdtsc(void)
+{
+ unsigned long long int a, d;
+ __asm__ volatile ("rdtsc\n\t" : "=a" (a), "=d" (d));
+ return (d << 32) | (a & 0xffffffff);
+}
#endif
void xine_profiler_start_count (int id) {