Skip to content

Commit

Permalink
can't seek into the middle of the sample anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePLMonster committed Feb 8, 2017
1 parent ddfb4bd commit 13bbb35
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vbcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
class VBStream
{
public:
static const size_t VB_BLOCK_SIZE = 512 * 16 * 2;
static const size_t VB_SAMPLE_SIZE = 0x10;
static const size_t VB_BLOCK_SIZE = 512 * VB_SAMPLE_SIZE * 2;

VBStream( FILE* file, int sample_rate, int stereo, int size )
: stream( file ), fileSize( size + sizeof(VAG_HEADER) )
Expand Down Expand Up @@ -104,6 +105,11 @@ class VBStream
if ( Type == AIL_FILE_SEEK_CURRENT ) Offset += virtualCursor;
else if ( Type == AIL_FILE_SEEK_END ) Offset = fileSize - Offset;

if ( UsesInterleave() )
Offset &= ~((VB_SAMPLE_SIZE*2)-1);
else
Offset &= ~(VB_SAMPLE_SIZE-1);

S32 OffsetNoHeader = Offset - sizeof(VAG_HEADER);
S32 CursorNoHeader = virtualCursor - sizeof(VAG_HEADER);

Expand Down Expand Up @@ -142,8 +148,6 @@ class VBStream
private:
void ReadBlockAndInterleave( )
{
const size_t VB_SAMPLE_SIZE = 0x10;

U8 buf[VB_BLOCK_SIZE];
size_t bytesRead = fread( buf, 1, VB_BLOCK_SIZE, stream );

Expand Down

0 comments on commit 13bbb35

Please sign in to comment.