drmp3_uint64seekPosInBytes;// Points to the first byte of an MP3 frame.
drmp3_uint64pcmFrameIndex;// The index of the PCM frame this seek point targets.
drmp3_uint16mp3FramesToDiscard;// The number of whole MP3 frames to be discarded before pcmFramesToDiscard.
drmp3_uint16pcmFramesToDiscard;// The number of leading samples to read and discard. These are discarded after mp3FramesToDiscard.
}drmp3_seek_point;
// Callback for when data is read. Return value is the number of bytes actually read.
//
// pUserData [in] The user data that was passed to drmp3_init(), drmp3_open() and family.
...
...
@@ -214,12 +218,16 @@ typedef struct
drmp3_read_proconRead;
drmp3_seek_proconSeek;
void*pUserData;
drmp3_uint32frameChannels;// The number of channels in the currently loaded MP3 frame. Internal use only.
drmp3_uint32frameSampleRate;// The sample rate of the currently loaded MP3 frame. Internal use only.
drmp3_uint32framesConsumed;
drmp3_uint32framesRemaining;
drmp3_uint8frames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];// <-- Multipled by sizeof(float) to ensure there's enough room for DR_MP3_FLOAT_OUTPUT.
drmp3_uint32mp3FrameChannels;// The number of channels in the currently loaded MP3 frame. Internal use only.
drmp3_uint32mp3FrameSampleRate;// The sample rate of the currently loaded MP3 frame. Internal use only.
drmp3_uint32pcmFramesConsumedInMP3Frame;
drmp3_uint32pcmFramesRemainingInMP3Frame;
drmp3_uint8pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];// <-- Multipled by sizeof(float) to ensure there's enough room for DR_MP3_FLOAT_OUTPUT.
drmp3_uint64currentPCMFrame;// The current PCM frame, globally, based on the output sample rate. Mainly used for seeking.
drmp3_uint64streamCursor;// The current byte the decoder is sitting on in the raw stream.
drmp3_srcsrc;
drmp3_seek_point*pSeekPoints;// NULL by default. Set with drmp3_bind_seek_table(). Memory is owned by the client. dr_mp3 will never attempt to free this pointer.
drmp3_uint32seekPointCount;// The number of items in pSeekPoints. When set to 0 assumes to no seek table. Defaults to zero.
drmp3_uint32samplesRead=drmp3dec_decode_frame(&pMP3->decoder,pMP3->pData,(int)pMP3->dataSize,(drmp3d_sample_t*)pMP3->frames,&info);// <-- Safe size_t -> int conversion thanks to the check above.
pcmFramesRead=drmp3dec_decode_frame(&pMP3->decoder,pMP3->pData,(int)pMP3->dataSize,pPCMFrames,&info);// <-- Safe size_t -> int conversion thanks to the check above.
// If there is no prior seekpoint it means the target PCM frame comes before the first seek point. Just assume a seekpoint at the start of the file in this case.
// If we haven't found a data chunk, return an error.
if(!foundDataChunk){
returnDRWAV_FALSE;
}
// We may have moved passed the data chunk. If so we need to move back. If running in sequential mode we can assume we are already sitting on the data chunk.