Changeset 341 for CoolStreaming


Ignore:
Timestamp:
Apr 3, 2012, 7:32:43 AM (13 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/UVarBlockSerializer.pas

    r307 r341  
    110110  SUInt64Overflow = '64-bit UInt read overflow.';
    111111  SReadError = 'Stream read error. Expected length %d, read %d. Source stream size %d.';
     112  SErrorGetVarSize = 'Error reading variable block size';
    112113
    113114{ TVarBlockSerializer }
     
    416417  StoredPosition: Integer;
    417418begin
    418   StoredPosition := Stream.Position;
    419   Result := 1; // Byte block length
    420   Data := Stream.ReadByte;
    421   if Data = $ff then Result := GetVarSize + ReadVarUInt + 1
    422   else begin
    423     Result := DecodeUnaryLength(Data);
    424   end;
    425   Stream.Position := StoredPosition;
     419  try
     420    StoredPosition := Stream.Position;
     421    Result := 1; // Byte block length
     422    Data := Stream.ReadByte;
     423
     424    if Data = $ff then Result := GetVarSize + ReadVarUInt + 1
     425    else begin
     426      Result := DecodeUnaryLength(Data);
     427    end;
     428    Stream.Position := StoredPosition;
     429  except
     430    raise Exception.Create(SErrorGetVarSize);
     431  end;
    426432end;
    427433
     
    477483  I: Integer;
    478484  StreamHelper: TStreamHelper;
     485  RequestedSize: Integer;
    479486begin
    480487  try
     
    492499        StreamHelper.ReadStream(Data.Stream, GetVarSize);
    493500    except
    494       raise Exception.Create(SMaskedValueReadError);
     501      //raise Exception.Create(SMaskedValueReadError);
     502      // Error recovery for not enough source data in stream
     503      Data.Stream.Size := 0;
     504      Data.Stream.WriteByte(0);
    495505    end;
    496506  finally
Note: See TracChangeset for help on using the changeset viewer.