Skip to content

Commit 072d3f3

Browse files
icculussezero
authored andcommitted
dr_mp3: Fix seek table generation with memory buffers instead of i/o callbacks.
drmp3_calculate_seek_points() builds the table with file positions like this: ```c mp3FrameInfo[iMP3Frame].bytePos = pMP3->streamCursor - pMP3->dataSize; ``` drmp3_decode_next_frame_ex__callbacks() updates both streamCursor and dataSize, but drmp3_decode_next_frame_ex__memory() does not, so all entries in the seek table end up pointing at the start of the audio file. This patch updates streamCursor as we read more bytes, but leaves dataSize at zero, since the latter appears to be how much is left to consume of the existing read buffer before more is read from disk, so subtracting zero in drmp3_calculate_seek_points() is the correct thing to do when reading entirely from memory. Fixes mackron/dr_libs#278 [ Mainstraem P/R: mackron/dr_libs#279. ]
1 parent 6509f9f commit 072d3f3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/codecs/dr_libs/dr_mp3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sampl
28832883

28842884
/* Consume the data. */
28852885
pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
2886+
pMP3->streamCursor += (size_t)info.frame_bytes;
28862887

28872888
return pcmFramesRead;
28882889
}

0 commit comments

Comments
 (0)