summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-08-10 16:03:21 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2003-08-10 16:03:21 +0000
commit5565e0dd6dfbd1a160ecbdd2c84af0dc5d279d93 (patch)
tree9a24163ad7b1394313a726c02542e5394318d320
parentc916741b33565418c8c574cf5b6f0139af46061b (diff)
downloadxine-lib-5565e0dd6dfbd1a160ecbdd2c84af0dc5d279d93.tar.gz
xine-lib-5565e0dd6dfbd1a160ecbdd2c84af0dc5d279d93.tar.bz2
apply Frantisek patches to handle end of streams better
CVS patchset: 5267 CVS date: 2003/08/10 16:03:21
-rw-r--r--src/demuxers/demux_elem.c25
-rw-r--r--src/demuxers/demux_mpgaudio.c36
-rw-r--r--src/input/input_gnome_vfs.c6
3 files changed, 37 insertions, 30 deletions
diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c
index d324f4d61..9100ebdc6 100644
--- a/src/demuxers/demux_elem.c
+++ b/src/demuxers/demux_elem.c
@@ -19,7 +19,7 @@
*/
/*
- * $Id: demux_elem.c,v 1.74 2003/07/25 21:02:05 miguelfreitas Exp $
+ * $Id: demux_elem.c,v 1.75 2003/08/10 16:03:21 miguelfreitas Exp $
*
* demultiplexer for elementary mpeg streams
*/
@@ -55,7 +55,7 @@ typedef struct {
input_plugin_t *input;
int status;
- int blocksize;
+ uint32_t blocksize;
} demux_mpeg_elem_t ;
typedef struct {
@@ -64,22 +64,23 @@ typedef struct {
static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) {
buf_element_t *buf;
+ uint32_t blocksize;
+ off_t done;
lprintf ("next piece\n");
- buf = this->input->read_block(this->input, this->video_fifo, this->blocksize);
+ buf = this->video_fifo->buffer_pool_alloc(this->video_fifo);
+ blocksize = (this->blocksize ? this->blocksize : buf->max_size);
+ done = this->input->read(this->input, buf->mem, blocksize);
+ lprintf ("read size = %lld\n", done);
- if (!buf) {
- this->status = DEMUX_FINISHED;
- return 0;
- }
-
- lprintf ("size = %d\n", buf->size);
- if (buf->size <= 0) {
+ if (done <= 0) {
buf->free_buffer (buf);
this->status = DEMUX_FINISHED;
return 0;
}
+ buf->size = done;
+ buf->content = buf->mem;
buf->pts = 0;
buf->extra_info->input_pos = this->input->get_current_pos(this->input);
buf->type = BUF_VIDEO_MPEG;
@@ -89,7 +90,7 @@ static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) {
this->video_fifo->put(this->video_fifo, buf);
- return (buf->size > 0);
+ return 1;
}
static int demux_mpeg_elem_send_chunk (demux_plugin_t *this_gen) {
@@ -114,8 +115,6 @@ static void demux_mpeg_elem_send_headers (demux_plugin_t *this_gen) {
this->audio_fifo = this->stream->audio_fifo;
this->blocksize = this->input->get_blocksize(this->input);
- if (!this->blocksize)
- this->blocksize = 2048;
xine_demux_control_start(this->stream);
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index c6d62d1de..9127f76f7 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpgaudio.c,v 1.104 2003/08/05 18:23:56 hadess Exp $
+ * $Id: demux_mpgaudio.c,v 1.105 2003/08/10 16:03:21 miguelfreitas Exp $
*
* demultiplexer for mpeg audio (i.e. mp3) streams
*
@@ -74,6 +74,7 @@ typedef struct {
int64_t last_pts;
int send_newpts;
int buf_flag_seek;
+ uint32_t blocksize;
} demux_mpgaudio_t ;
@@ -422,26 +423,32 @@ static void check_newpts( demux_mpgaudio_t *this, int64_t pts ) {
static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags) {
- buf_element_t *buf = NULL;
+ buf_element_t *buf;
+ uint32_t blocksize;
uint32_t head;
off_t buffer_pos;
+ off_t done;
uint64_t pts = 0;
- int worked = 0;
buffer_pos = this->input->get_current_pos(this->input);
- if(this->audio_fifo)
- buf = this->input->read_block(this->input,
- this->audio_fifo, 2048);
- if (buf == NULL) {
- this->status = DEMUX_FINISHED;
+ if (!this->audio_fifo)
+ return 0;
+
+ buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
+
+ blocksize = (this->blocksize ? this->blocksize : buf->max_size);
+ done = this->input->read(this->input, buf->mem, blocksize);
+
+ if (done <= 0) {
+ buf->free_buffer(buf);
return 0;
}
if (this->bitrate == 0) {
int i, ver,srindex,brindex,xbytes,xframes;
- for( i = 0; i < buf->size-4; i++ ) {
+ for( i = 0; i < done-4; i++ ) {
head = (buf->mem[i+0] << 24) + (buf->mem[i+1] << 16) +
(buf->mem[i+2] << 8) + buf->mem[i+3];
@@ -501,16 +508,15 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags) {
#if 0
buf->pts = pts;
#endif
+ buf->size = done;
+ buf->content = buf->mem;
buf->type = BUF_AUDIO_MPEG;
buf->decoder_info[0] = 1;
buf->decoder_flags = decoder_flags;
- worked = (buf->size == 2048);
-
- if(this->audio_fifo)
- this->audio_fifo->put(this->audio_fifo, buf);
+ this->audio_fifo->put(this->audio_fifo, buf);
- return worked;
+ return 1;
}
static int demux_mpgaudio_send_chunk (demux_plugin_t *this_gen) {
@@ -612,6 +618,8 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) {
read_id3_tags (this);
}
+ this->blocksize = this->input->get_blocksize(this->input);
+
/*
* send preview buffers
*/
diff --git a/src/input/input_gnome_vfs.c b/src/input/input_gnome_vfs.c
index a0e3b988b..af9e8912c 100644
--- a/src/input/input_gnome_vfs.c
+++ b/src/input/input_gnome_vfs.c
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_gnome_vfs.c,v 1.13 2003/07/26 15:44:47 hadess Exp $
+ * $Id: input_gnome_vfs.c,v 1.14 2003/08/10 16:03:21 miguelfreitas Exp $
*/
@@ -94,7 +94,7 @@ gnomevfs_plugin_read (input_plugin_t *this_gen, char *buf, off_t len)
return -1;
} else if (res == GNOME_VFS_ERROR_EOF) {
D("gnomevfs_plugin_read: GNOME_VFS_ERROR_EOF");
- return 0;
+ return num_bytes;
}
if (n <= 0)
@@ -121,7 +121,7 @@ gnomevfs_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo,
total_bytes = gnomevfs_plugin_read (this_gen, buf->content, todo);
- if (total_bytes) buf->size = total_bytes;
+ if (total_bytes == todo) buf->size = todo;
else
{
buf->free_buffer (buf);