Changeset 60b307b4bc1ec3422daa3f5b75bef3eeaad0a04d

Show
Ignore:
Timestamp:
16/12/05 18:28:36 (3 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1134754116 +0000
git-parent:

[1f61d23a127e0686aa6b2d5e3afdbd11d9ffcbc5]

git-author:
Clément Stenac <zorglub@videolan.org> 1134754116 +0000
Message:

Refill stream when seeking near of end of track.
Needs testing and review

+ allow enabling of debug through #define STREAM_DEBUG

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/input/stream.c

    r3a65334 r60b307b  
    2828#include "input_internal.h" 
    2929 
     30#undef STREAM_DEBUG 
     31 
    3032/* TODO: 
    3133 *  - tune the 2 methods 
     
    624626        } 
    625627 
    626         if( p_access->info.b_prebuffered )  
     628        if( p_access->info.b_prebuffered ) 
    627629        { 
    628630            /* Access has already prebufferred - update stats and exit */ 
     
    9981000    } 
    9991001 
    1000 #if 0 
     1002#ifdef STREAM_DEBUG 
    10011003    msg_Dbg( s, "AStreamReadStream: %d pos="I64Fd" tk=%d start="I64Fd 
    10021004             " offset=%d end="I64Fd, 
     
    10531055    if( tk->i_start >= tk->i_end ) return 0; /* EOF */ 
    10541056 
    1055 #if 0 
     1057#ifdef STREAM_DEBUG 
    10561058    msg_Dbg( s, "AStreamPeekStream: %d pos="I64Fd" tk=%d " 
    10571059             "start="I64Fd" offset=%d end="I64Fd, 
     
    11161118    int i; 
    11171119 
    1118 #if 0 
     1120#ifdef STREAM_DEBUG 
    11191121    msg_Dbg( s, "AStreamSeekStream: to "I64Fd" pos="I64Fd 
    11201122             "tk=%d start="I64Fd" offset=%d end="I64Fd, 
     
    11301132        i_pos < p_sys->stream.tk[p_sys->stream.i_tk].i_end ) 
    11311133    { 
    1132         //msg_Dbg( s, "AStreamSeekStream: current track" ); 
     1134        stream_track_t *tk = &p_sys->stream.tk[p_sys->stream.i_tk]; 
     1135#ifdef STREAM_DEBUG 
     1136        msg_Dbg( s, "AStreamSeekStream: current track" ); 
     1137#endif 
    11331138        p_sys->i_pos = i_pos; 
    1134         p_sys->stream.i_offset = i_pos - p_sys->stream.tk[p_sys->stream.i_tk].i_start; 
     1139        p_sys->stream.i_offset = i_pos - tk->i_start; 
     1140 
     1141        /* If there is not enough data left in the track, refill  */ 
     1142        /* \todo How to get a correct value for 
     1143         *    - refilling threshold 
     1144         *    - how much to refill 
     1145         */ 
     1146        if( (tk->i_end - tk->i_start ) - p_sys->stream.i_offset < 
     1147                                             p_sys->stream.i_read_size ) 
     1148        { 
     1149            if( p_sys->stream.i_used < STREAM_READ_ATONCE / 2  ) 
     1150            { 
     1151                p_sys->stream.i_used = STREAM_READ_ATONCE / 2 ; 
     1152                if( AStreamRefillStream( s ) ) 
     1153                    return VLC_EGENERIC; 
     1154            } 
     1155        } 
    11351156        return VLC_SUCCESS; 
    11361157    } 
     
    11541175        if( i_pos >= tk->i_start && i_pos <= tk->i_end ) 
    11551176        { 
    1156 #if 0 
     1177#ifdef STREAM_DEBUG 
    11571178            msg_Dbg( s, "AStreamSeekStream: reusing %d start="I64Fd 
    11581179                     " end="I64Fd, i, tk->i_start, tk->i_end ); 
    11591180#endif 
     1181 
    11601182            /* Seek at the end of the buffer */ 
    11611183            if( ASeek( s, tk->i_end ) ) return VLC_EGENERIC; 
     
    12411263    if( i_toread <= 0 ) return VLC_EGENERIC; /* EOF */ 
    12421264 
    1243     /* msg_Dbg( s, "AStreamRefillStream: toread=%d", i_toread ); */ 
     1265#ifdef STREAM_DEBUG 
     1266    msg_Dbg( s, "AStreamRefillStream: used=%d toread=%d", 
     1267                 p_sys->stream.i_used, i_toread ); 
     1268#endif 
    12441269 
    12451270    i_start = mdate();