Changeset 5e2537971a6e4870333667628e014cfe2e7381e8

Show
Ignore:
Timestamp:
11/09/06 21:17:17 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1163103437 +0000
git-parent:

[ea64177035896669780fc00f4edee086ab0094fa]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1163103437 +0000
Message:

Handle seeking with best effort in dump filter
instead of aborting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access_filter/dump.c

    r919c654 r5e25379  
    7676    FILE *stream; 
    7777    int64_t tmp_max; 
     78    int64_t dumpsize; 
    7879}; 
    7980 
     
    146147    FILE *stream = p_sys->stream; 
    147148 
    148     if ((stream == NULL) || (len == 0)) 
     149    if ((stream == NULL) /* not dumping */ 
     150     || (access->info.i_pos < p_sys->dumpsize) /* already known data */) 
    149151        return; 
     152 
     153    size_t needed = access->info.i_pos - p_sys->dumpsize; 
     154    if (len < needed) 
     155        return; /* gap between data and dump offset (seek too far ahead?) */ 
     156 
     157    buffer += len - needed; 
     158    len = needed; 
     159 
     160    if (len == 0) 
     161        return; /* no useful data */ 
    150162 
    151163    if ((p_sys->tmp_max != -1) && (access->info.i_pos > p_sys->tmp_max)) 
     
    155167    } 
    156168 
     169    assert (len > 0); 
    157170    if (fwrite (buffer, len, 1, stream) != 1) 
    158171    { 
     
    161174    } 
    162175 
     176    p_sys->dumpsize += len; 
    163177    return; 
    164178 
     
    178192 
    179193    Dump (access, buffer, len); 
    180     //Trigger (access); 
    181194 
    182195    return len; 
     
    222235 
    223236    if (p_sys->stream != NULL) 
    224     { 
    225         msg_Dbg (access, "seeking - dump will not work"); 
    226         fclose (p_sys->stream); 
    227         p_sys->stream = NULL; 
    228     } 
     237        msg_Dbg (access, "seeking - dump might not work"); 
    229238 
    230239    src->info.i_update = access->info.i_update;