summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2009-08-05 22:51:53 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2009-08-05 22:51:53 +0100
commitc579d6f6fb0fd0075faf02a80be1a24f7f75071a (patch)
tree9ecca7232b48a5e3421d48d10c9d9861f95c5b36 /src
parentc2c388cfc3258d237493df7e4efdfe2562abe78b (diff)
parent08c9d1d6bce967a909bb55a967bf694ce29b4f48 (diff)
downloadxine-lib-c579d6f6fb0fd0075faf02a80be1a24f7f75071a.tar.gz
xine-lib-c579d6f6fb0fd0075faf02a80be1a24f7f75071a.tar.bz2
Merge from 1.1.
--HG-- rename : src/libmusepack/xine_musepack_decoder.c => src/audio_dec/xine_musepack_decoder.c
Diffstat (limited to 'src')
-rw-r--r--src/audio_dec/xine_musepack_decoder.c76
-rw-r--r--src/audio_out/audio_pulse_out.c2
-rw-r--r--src/demuxers/demux_rawdv.c3
-rw-r--r--src/input/input_cdda.c40
-rw-r--r--src/input/input_dvd.c2
-rw-r--r--src/xine-engine/demux.c18
-rw-r--r--src/xine-utils/utils.c2
7 files changed, 121 insertions, 22 deletions
diff --git a/src/audio_dec/xine_musepack_decoder.c b/src/audio_dec/xine_musepack_decoder.c
index 76e5642f4..42ba64108 100644
--- a/src/audio_dec/xine_musepack_decoder.c
+++ b/src/audio_dec/xine_musepack_decoder.c
@@ -48,7 +48,13 @@
#include <xine/buffer.h>
#include <xine/xineutils.h>
-#include <mpcdec/mpcdec.h>
+#ifdef HAVE_MPCDEC_MPCDEC_H
+# include <mpcdec/mpcdec.h>
+#elif defined(HAVE_MPC_MPCDEC_H)
+# include <mpc/mpcdec.h>
+#else
+# include "musepack/musepack.h"
+#endif
#define MPC_DECODER_MEMSIZE 65536
#define MPC_DECODER_MEMSIZE2 (MPC_DECODER_MEMSIZE/2)
@@ -77,7 +83,11 @@ typedef struct mpc_decoder_s {
mpc_reader reader;
mpc_streaminfo streaminfo;
+#ifndef HAVE_MPC_MPCDEC_H
mpc_decoder decoder;
+#else
+ mpc_demux *decoder;
+#endif
int decoder_ok;
unsigned int current_frame;
@@ -111,8 +121,13 @@ static int32_t mpc_reader_read(void *const data, void *const ptr, int size) {
}
/* Seeks to byte position offset. */
+#ifndef HAVE_MPC_MPCDEC_H
static mpc_bool_t mpc_reader_seek(void *const data, const int32_t offset) {
mpc_decoder_t *const this = (mpc_decoder_t *) data;
+#else
+static mpc_bool_t mpc_reader_seek(mpc_reader *data, int32_t offset) {
+ mpc_decoder_t *const this = (mpc_decoder_t *) data->data;
+#endif
lprintf("mpc_reader_seek: offset=%d\n", offset);
@@ -120,11 +135,19 @@ static mpc_bool_t mpc_reader_seek(void *const data, const int32_t offset) {
* that the buffer starts at the start of the file */
this->read = offset;
+#ifndef HAVE_MPC_MPCDEC_H
return TRUE;
+#else
+ return MPC_TRUE;
+#endif
}
/* Returns the current byte offset in the stream. */
+#ifndef HAVE_MPC_MPCDEC_H
static int32_t mpc_reader_tell(void *const data) {
+#else
+static int32_t mpc_reader_tell(mpc_reader *const data) {
+#endif
lprintf("mpc_reader_tell\n");
/* Tell isn't used so just return 0 */
@@ -132,8 +155,13 @@ static int32_t mpc_reader_tell(void *const data) {
}
/* Returns the total length of the source stream, in bytes. */
+#ifndef HAVE_MPC_MPCDEC_H
static int32_t mpc_reader_get_size(void *const data) {
mpc_decoder_t *const this = (mpc_decoder_t *) data;
+#else
+static int32_t mpc_reader_get_size(mpc_reader *const data) {
+ mpc_decoder_t *const this = (mpc_decoder_t *) data->data;
+#endif
lprintf("mpc_reader_get_size\n");
@@ -141,10 +169,17 @@ static int32_t mpc_reader_get_size(void *const data) {
}
/* True if the stream is a seekable stream. */
+#ifndef HAVE_MPC_MPCDEC_H
static mpc_bool_t mpc_reader_canseek(void *data) {
lprintf("mpc_reader_canseek\n");
return TRUE;
+#else
+static mpc_bool_t mpc_reader_canseek(mpc_reader *data) {
+
+ lprintf("mpc_reader_canseek\n");
+ return MPC_TRUE;
+#endif
}
/**
@@ -175,10 +210,19 @@ static inline void float_to_int(const float *const _f, int16_t *const s16, const
static int mpc_decode_frame (mpc_decoder_t *this) {
float buffer[MPC_DECODER_BUFFER_LENGTH];
uint32_t frames;
+#ifdef HAVE_MPC_MPCDEC_H
+ mpc_frame_info frame;
+#endif
lprintf("mpd_decode_frame\n");
+#ifndef HAVE_MPC_MPCDEC_H
frames = mpc_decoder_decode(&this->decoder, buffer, 0, 0);
+#else
+ frame.buffer = buffer;
+ mpc_demux_decode(this->decoder, &frame);
+ frames = frame.samples;
+#endif
if (frames > 0) {
audio_buffer_t *audio_buffer;
@@ -245,6 +289,16 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
xine_fast_memcpy(this->buf, buf->content, buf->size);
this->size = buf->size;
+#ifdef HAVE_MPC_MPCDEC_H
+ this->decoder = mpc_demux_init(&this->reader);
+ if (!this->decoder) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ _("libmusepack: mpc_demux_init failed.\n"));
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
+ return;
+ }
+ mpc_demux_get_info(this->decoder, &this->streaminfo);
+#else
/* Initialise and read stream info */
mpc_streaminfo_init(&this->streaminfo);
@@ -255,6 +309,7 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
return;
}
+#endif
this->sample_rate = this->streaminfo.sample_freq;
this->channels = this->streaminfo.channels;
@@ -269,7 +324,9 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
this->current_frame = 0;
/* Setup the decoder */
+#ifndef HAVE_MPC_MPCDEC_H
mpc_decoder_setup(&this->decoder, &this->reader);
+#endif
this->decoder_ok = 0;
/* Take this opportunity to initialize stream/meta information */
@@ -322,7 +379,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
/* Time to decode */
if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
/* Increment frame count */
+#ifndef HAVE_MPC_MPCDEC_H
if (this->current_frame++ == this->streaminfo.frames) {
+#else
+ if (this->current_frame++ == this->streaminfo.samples) {
+#endif
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("libmusepack: data after last frame ignored\n"));
return;
@@ -333,7 +394,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if ((this->size - this->read) >= MPC_DECODER_MEMSIZE) {
lprintf("initialise");
+#ifndef HAVE_MPC_MPCDEC_H
if (!mpc_decoder_initialize(&this->decoder, &this->streaminfo)) {
+#else
+ if (!this->decoder) {
+#endif
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("libmusepack: mpc_decoder_initialise failed\n"));
@@ -364,7 +429,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
/* If we are at the end of the stream we decode the remaining frames as we
* know we'll have enough data */
+#ifndef HAVE_MPC_MPCDEC_H
if (this->current_frame == this->streaminfo.frames) {
+#else
+ if (this->current_frame == this->streaminfo.samples) {
+#endif
lprintf("flushing buffers\n");
do {
@@ -397,9 +466,14 @@ static void mpc_dispose (audio_decoder_t *this_gen) {
/* close the audio output */
if (this->output_open)
this->stream->audio_out->close (this->stream->audio_out, this->stream);
+ this->output_open = 0;
/* free anything that was allocated during operation */
free(this->buf);
+#ifdef HAVE_MPC_MPCDEC_H
+ if (this->decoder)
+ mpc_demux_exit(this->decoder);
+#endif
free(this);
}
diff --git a/src/audio_out/audio_pulse_out.c b/src/audio_out/audio_pulse_out.c
index 1f4b6fa87..c3dcac932 100644
--- a/src/audio_out/audio_pulse_out.c
+++ b/src/audio_out/audio_pulse_out.c
@@ -235,7 +235,7 @@ static int connect_context(pulse_driver_t *this) {
}
if (!this->context) {
- char fn[PATH_MAX], *p;
+ char fn[XINE_PATH_MAX], *p;
if (pa_get_binary_name(fn, sizeof(fn)))
p = pa_path_get_filename(fn);
diff --git a/src/demuxers/demux_rawdv.c b/src/demuxers/demux_rawdv.c
index bffd4c9c0..aed2b7c75 100644
--- a/src/demuxers/demux_rawdv.c
+++ b/src/demuxers/demux_rawdv.c
@@ -302,7 +302,8 @@ static int demux_raw_dv_seek (demux_plugin_t *this_gen,
}
if( !start_pos && start_time ) {
- start_pos = (start_time * 90 / this->duration) * this->frame_size;
+ /* Upcast start_time in case sizeof(off_t) > sizeof(int) */
+ start_pos = ((off_t) start_time * 90 / this->duration) * this->frame_size;
}
start_pos = start_pos - (start_pos % this->frame_size);
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index 9c51a16da..61ea118c2 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -1711,7 +1711,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
memset(&buffer, 0, sizeof(buffer));
err = _cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1);
- if (err < 0 || (((err = _cdda_cddb_handle_code(buffer)) != 200) && (err != 210))) {
+ if (err < 0 || (((err = _cdda_cddb_handle_code(buffer)) != 200) && (err != 210) && (err != 211))) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"input_cdda: cddb query command returned error code '%03d'.\n", err);
_cdda_cddb_socket_close(this);
@@ -1732,7 +1732,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
}
}
- if (err == 210) {
+ if ((err == 210) || (err == 211)) {
memset(&buffer, 0, sizeof(buffer));
err = _cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1);
if (err < 0) {
@@ -2132,26 +2132,18 @@ static int cdda_close(cdda_input_plugin_t *this_gen) {
static uint32_t cdda_plugin_get_capabilities (input_plugin_t *this_gen) {
- return INPUT_CAP_SEEKABLE | INPUT_CAP_BLOCK;
+ return INPUT_CAP_SEEKABLE;
}
static off_t cdda_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) {
- /* only allow reading in block-sized chunks */
-
- return 0;
-}
-
-static buf_element_t *cdda_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo,
- off_t nlen) {
-
cdda_input_plugin_t *this = (cdda_input_plugin_t *) this_gen;
- buf_element_t *buf;
- unsigned char frame_data[CD_RAW_FRAME_SIZE];
int err = 0;
- if (nlen != CD_RAW_FRAME_SIZE)
+ /* only allow reading in block-sized chunks */
+
+ if (len != CD_RAW_FRAME_SIZE)
return 0;
if (this->current_frame > this->last_frame)
@@ -2185,14 +2177,26 @@ static buf_element_t *cdda_plugin_read_block (input_plugin_t *this_gen, fifo_buf
if( err < 0 )
return 0;
- memcpy(frame_data, this->cache[this->current_frame-this->cache_first], CD_RAW_FRAME_SIZE);
+ memcpy(buf, this->cache[this->current_frame-this->cache_first], CD_RAW_FRAME_SIZE);
this->current_frame++;
+ return CD_RAW_FRAME_SIZE;
+}
+
+static buf_element_t *cdda_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo,
+ off_t nlen) {
+
+ buf_element_t *buf;
+
buf = fifo->buffer_pool_alloc(fifo);
buf->content = buf->mem;
buf->type = BUF_DEMUX_BLOCK;
- buf->size = CD_RAW_FRAME_SIZE;
- memcpy(buf->mem, frame_data, CD_RAW_FRAME_SIZE);
+
+ buf->size = cdda_plugin_read(this_gen, buf->content, nlen);
+ if (buf->size == 0) {
+ buf->free_buffer(buf);
+ buf = NULL;
+ }
return buf;
}
@@ -2230,7 +2234,7 @@ static off_t cdda_plugin_get_length (input_plugin_t *this_gen) {
static uint32_t cdda_plugin_get_blocksize (input_plugin_t *this_gen) {
- return CD_RAW_FRAME_SIZE;
+ return 0;
}
static const char* cdda_plugin_get_mrl (input_plugin_t *this_gen) {
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index da52604ca..86c5f44dd 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -53,7 +53,9 @@
#include <dlfcn.h>
#ifndef WIN32
+#if ! defined(__GNU__)
#include <sys/mount.h>
+#endif
#include <sys/wait.h>
#include <sys/poll.h>
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index ba43ddc60..fb4176763 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -122,10 +122,28 @@ void _x_demux_flush_engine (xine_stream_t *stream) {
static struct timespec _x_compute_interval(unsigned int millisecs) {
struct timespec ts;
+#ifdef WIN32
+ FILETIME ft;
+ ULARGE_INTEGER ui;
+
+ GetSystemTimeAsFileTime(&ft);
+ ui.u.LowPart = ft.dwLowDateTime;
+ ui.u.HighPart = ft.dwHighDateTime;
+ ui.QuadPart += millisecs * 10000;
+ ts.tv_sec = ui.QuadPart / 10000000;
+ ts.tv_sec = (ui.QuadPart % 10000000)*100;
+#elif _POSIX_TIMERS > 0
clock_gettime(CLOCK_REALTIME, &ts);
uint64_t ttimer = (uint64_t)ts.tv_sec*1000 + ts.tv_nsec/1000000 + millisecs;
ts.tv_sec = ttimer/1000;
ts.tv_nsec = (ttimer%1000)*1000000;
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t ttimer = (uint64_t)tv.tv_sec*1000 + tv.tv_usec/1000 + millisecs;
+ ts.tv_sec = ttimer/1000;
+ ts.tv_nsec = (ttimer%1000)*1000000;
+#endif
return ts;
}
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index 2fb6ea554..3b84e6295 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -584,7 +584,7 @@ char *xine_get_system_encoding(void) {
char *codeset = NULL;
#ifdef HAVE_NL_LANGINFO
- setlocale(LC_ALL, "");
+ setlocale(LC_CTYPE, "");
codeset = nl_langinfo(CODESET);
#endif
/*