summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_mpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_mpc.c')
-rw-r--r--src/demuxers/demux_mpc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/demuxers/demux_mpc.c b/src/demuxers/demux_mpc.c
index 346f0c2e6..220e1b8b6 100644
--- a/src/demuxers/demux_mpc.c
+++ b/src/demuxers/demux_mpc.c
@@ -47,6 +47,7 @@
#include "buffer.h"
#include "bswap.h"
#include "group_audio.h"
+#include "id3.h"
/* Note that the header is actually 25 bytes long, so we'd only read 28
* (because of byte swapping we have to round up to nearest multiple of 4)
@@ -89,17 +90,13 @@ static int open_mpc_file(demux_mpc_t *this) {
/* TODO: non-seeking version */
if (INPUT_IS_SEEKABLE(this->input)) {
/* Check for id3v2 tag */
- if ((this->header[0] == 'I') ||
- (this->header[1] == 'D') ||
- (this->header[2] == '3')) {
+ if (id3v2_istag(this->header)) {
lprintf("found id3v2 header\n");
/* Read tag size */
- id3v2_size = (this->header[6] << 21) +
- (this->header[7] << 14) +
- (this->header[8] << 7) +
- this->header[9] + 10;
+
+ id3v2_size = _X_BE_32_synchsafe(&this->header[6]) + 10;
/* Add footer size if one is present */
if (this->header[5] & 0x10)
@@ -118,9 +115,7 @@ static int open_mpc_file(demux_mpc_t *this) {
}
/* Validate signature - We only support SV 7.x at the moment */
- if ((this->header[0] != 'M') ||
- (this->header[1] != 'P') ||
- (this->header[2] != '+') ||
+ if ( memcmp(this->header, "MP+", 3) != 0 ||
((this->header[3]&0x0f) != 0x07))
return 0;
@@ -214,7 +209,7 @@ static int demux_mpc_send_chunk(demux_plugin_t *this_gen) {
/* Read data */
bytes_read = this->input->read(this->input, buf->content, bytes_to_read);
- if(bytes_read == 0) {
+ if(bytes_read <= 0) {
buf->free_buffer(buf);
this->status = DEMUX_FINISHED;
return this->status;
@@ -324,7 +319,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_mpc_t *this;
- this = xine_xmalloc (sizeof (demux_mpc_t));
+ this = calloc(1, sizeof(demux_mpc_t));
this->stream = stream;
this->input = input;
@@ -381,11 +376,12 @@ static const char *get_identifier (demux_class_t *this_gen) {
}
static const char *get_extensions (demux_class_t *this_gen) {
- return "mpc mp+";
+ return "mpc mp+ mpp";
}
static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
+ return "audio/musepack: mpc, mp+, mpp: Musepack audio;"
+ "audio/x-musepack: mpc, mp+, mpp: Musepack audio;";
}
static void class_dispose (demux_class_t *this_gen) {
@@ -397,7 +393,7 @@ static void class_dispose (demux_class_t *this_gen) {
void *demux_mpc_init_plugin (xine_t *xine, void *data) {
demux_mpc_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpc_class_t));
+ this = calloc(1, sizeof(demux_mpc_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;