mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Minor code cleanup of FLAC decoder.
This commit is contained in:
@@ -72,19 +72,18 @@ love::sound::Decoder *FLACDecoder::clone()
|
|||||||
int FLACDecoder::decode()
|
int FLACDecoder::decode()
|
||||||
{
|
{
|
||||||
// `bufferSize` is in bytes, so divide by 2.
|
// `bufferSize` is in bytes, so divide by 2.
|
||||||
drflac_uint64 readed = drflac_read_pcm_frames_s16(flac, bufferSize / 2 / flac->channels, (drflac_int16 *) buffer);
|
drflac_uint64 read = drflac_read_pcm_frames_s16(flac, bufferSize / 2 / flac->channels, (drflac_int16 *) buffer);
|
||||||
readed = readed * 2 * flac->channels;
|
read *= 2 * flac->channels;
|
||||||
|
|
||||||
if (readed < bufferSize)
|
if ((int) read < bufferSize)
|
||||||
eof = true;
|
eof = true;
|
||||||
|
|
||||||
return (int) readed;
|
return (int) read;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLACDecoder::seek(double s)
|
bool FLACDecoder::seek(double s)
|
||||||
{
|
{
|
||||||
double duration = getDuration();
|
drflac_uint64 seekPosition = (drflac_uint64) (s * flac->sampleRate);
|
||||||
drflac_uint64 seekPosition = (drflac_uint64) (s * ((double) flac->totalPCMFrameCount) / duration);
|
|
||||||
|
|
||||||
drflac_bool32 result = drflac_seek_to_pcm_frame(flac, seekPosition);
|
drflac_bool32 result = drflac_seek_to_pcm_frame(flac, seekPosition);
|
||||||
if (result)
|
if (result)
|
||||||
|
|||||||
Reference in New Issue
Block a user