[MPlayer-dev-eng] Re: Prefetching/buffering files

Anil Nambiar nambiara at sharpsec.com
Fri Sep 2 23:58:29 CEST 2005


Jan Knutar <jknutar <at> nic.fi> writes:

> 
> On Saturday 03 September 2005 00:15, Anil Nambiar wrote:
> 
> > Looks like my text-editor has screwed up the tab in the files. here is the 
> > patch.
> 
> I dunno, it still has lots of strange whitespace changes that make it 
difficult
> to separate the real changes from the bogus:
> 
> > -    mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d 
> %d)
> > \n",
> > -        id, MAX_A_STREAMS);
> > -    return NULL;
> > + mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > 
> > %d)\n",
> > +     id, MAX_A_STREAMS);
> > + return NULL;
> 
> What is the real change here?
> 
> > -    demux_close_tv(demuxer); break;
> > + demux_close_tv(demuxer); break;
> 
> huh?
> 
> > -    case DEMUXER_TYPE_AVI:
> > +    case DEMUXER_TYPE_AVI: 
> 
> eh... any reason this line was replaced
> 
> >      case DEMUXER_TYPE_AVI_NI:
> >      case DEMUXER_TYPE_AVI_NINI:
> 
> and these not? :)
> 
> It would be helpful with a patch that only shows the true changes related
> to your original post. Much easier to overview, too.
> 

This is what I have changed. Since I use windows based text editor for 
development, it messes up with the diff. If you check the while loop, i do the 
read before doing the check for packet.

int ds_fill_buffer(demux_stream_t *ds){
  demuxer_t *demux=ds->demuxer;
  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
    if(ds==demux->sub)   mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_sub) 
called\n");else
                         mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(unknown 
0x%X) called\n",(unsigned int)ds);
  }
  while(1){
    if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){
      mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio-
>packs,demux->audio->bytes);
      mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
      break;
    }
    if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){
      mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video-
>packs,demux->video->bytes);
      mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
      break;
    }
    if(!demux_fill_buffer(demux,ds)){
        if(ds->packs <= 0)
        {

           mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"ds_fill_buffer()->demux_fill_buffer() 
failed\n");
           break; // EOF
        }
    }
    if(ds->packs){
      demux_packet_t *p=ds->first;
      // copy useful data:
      ds->buffer=p->buffer;
      ds->buffer_pos=0;
      ds->buffer_size=p->len;
      ds->pos=p->pos;
      ds->dpos+=p->len; // !!!
      ++ds->pack_no;
      if(p->pts){
        ds->pts=p->pts;
        ds->pts_bytes=0;
      }
      ds->pts_bytes+=p->len; // !!!
      ds->flags=p->flags;
      // unlink packet:
      ds->bytes-=p->len;
      ds->current=p;
      ds->first=p->next;
      if(!ds->first) ds->last=NULL;
      --ds->packs;
      return 1; //ds->buffer_size;
    }
  }
  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;
}







More information about the MPlayer-dev-eng mailing list