aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpdemux/demuxer.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdemux/demuxer.c')
-rw-r--r--libmpdemux/demuxer.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 6b95faffc5..78d33ac382 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -38,7 +38,7 @@ demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
//---------------
ds->packs=0;
ds->bytes=0;
- ds->first=ds->last=NULL;
+ ds->first=ds->last=ds->current=NULL;
ds->id=id;
ds->demuxer=demuxer;
//----------------
@@ -296,7 +296,7 @@ int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
// 1 = succesfull
int ds_fill_buffer(demux_stream_t *ds){
demuxer_t *demux=ds->demuxer;
- if(ds->buffer) free(ds->buffer);
+ if(ds->current) free_demux_packet(ds->current);
if(verbose>2){
if(ds==demux->audio) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_audio) called\n");else
if(ds==demux->video) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_video) called\n");else
@@ -319,11 +319,11 @@ int ds_fill_buffer(demux_stream_t *ds){
}
ds->pts_bytes+=p->len; // !!!
ds->flags=p->flags;
- // free packet:
+ // unlink packet:
ds->bytes-=p->len;
+ ds->current=p;
ds->first=p->next;
if(!ds->first) ds->last=NULL;
- free(p);
--ds->packs;
return 1; //ds->buffer_size;
}
@@ -344,6 +344,7 @@ int ds_fill_buffer(demux_stream_t *ds){
}
ds->buffer_pos=ds->buffer_size=0;
ds->buffer=NULL;
+ ds->current=NULL;
mp_msg(MSGT_DEMUXER,MSGL_V,"ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video");
ds->eof=1;
return 0;
@@ -387,8 +388,7 @@ void ds_free_packs(demux_stream_t *ds){
demux_packet_t *dp=ds->first;
while(dp){
demux_packet_t *dn=dp->next;
- if(dp->buffer) free(dp->buffer);
- free(dp);
+ free_demux_packet(dp);
dp=dn;
}
if(ds->asf_packet){
@@ -400,7 +400,8 @@ void ds_free_packs(demux_stream_t *ds){
ds->first=ds->last=NULL;
ds->packs=0; // !!!!!
ds->bytes=0;
- if(ds->buffer) free(ds->buffer);
+ if(ds->current) free_demux_packet(ds->current);
+ ds->current=NULL;
ds->buffer=NULL;
ds->buffer_pos=ds->buffer_size;
ds->pts=0; ds->pts_bytes=0;