mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
AudioLib: When handling a LOOP_END tag in FLAC or Ogg, truncate any blocks that read past it so that the specified value is respected precisely, instead of rounding up to the nearest block size.
DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5163 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
940bef522d
commit
c47ebac6c1
2 changed files with 17 additions and 7 deletions
|
@ -208,7 +208,7 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
|
|||
{
|
||||
flac_data * fd = (flac_data *) client_data;
|
||||
VoiceNode *voice = fd->owner;
|
||||
const FLAC__uint64 samples = frame->header.blocksize;
|
||||
FLAC__uint64 samples = frame->header.blocksize;
|
||||
|
||||
UNREFERENCED_PARAMETER(decoder);
|
||||
|
||||
|
@ -216,6 +216,19 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
|
|||
voice->bits = frame->header.bits_per_sample;
|
||||
voice->SamplingRate = frame->header.sample_rate;
|
||||
|
||||
if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER)
|
||||
fd->sample_pos = frame->header.number.frame_number;
|
||||
else if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER)
|
||||
fd->sample_pos = frame->header.number.sample_number;
|
||||
|
||||
if ((FLAC__uint64)(uintptr_t)voice->LoopEnd > 0 && fd->sample_pos + samples >= (FLAC__uint64)(uintptr_t)voice->LoopEnd)
|
||||
{
|
||||
samples = (FLAC__uint64)(uintptr_t)voice->LoopEnd - fd->sample_pos;
|
||||
if (!FLAC__stream_decoder_seek_absolute(fd->stream, (FLAC__uint64)(uintptr_t)voice->LoopStart))
|
||||
MV_Printf("MV_GetNextFLACBlock FLAC__stream_decoder_seek_absolute: LOOP_START %ul, LOOP_END %ul\n",
|
||||
(FLAC__uint64)(uintptr_t)voice->LoopStart, (FLAC__uint64)(uintptr_t)voice->LoopEnd);
|
||||
}
|
||||
|
||||
voice->length = ((samples * (voice->bits/8))/2)<<voice->bits;
|
||||
voice->position = 0;
|
||||
voice->BlockLength = 0;
|
||||
|
@ -224,11 +237,6 @@ FLAC__StreamDecoderWriteStatus write_flac_stream(const FLAC__StreamDecoder *deco
|
|||
voice->FixedPointBufferSize = ( voice->RateScale * MV_MIXBUFFERSIZE ) - voice->RateScale;
|
||||
MV_SetVoiceMixMode( voice );
|
||||
|
||||
if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER)
|
||||
fd->sample_pos = frame->header.number.frame_number;
|
||||
else if (frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER)
|
||||
fd->sample_pos = frame->header.number.sample_number;
|
||||
|
||||
{
|
||||
const size_t size = samples * voice->channels * (voice->bits/8);
|
||||
if (size > fd->blocksize)
|
||||
|
|
|
@ -242,9 +242,11 @@ static playbackstatus MV_GetNextVorbisBlock
|
|||
#endif
|
||||
//fprintf(stderr, "ov_read = %d\n", bytes);
|
||||
if (bytes > 0) {
|
||||
ogg_int64_t currentPosition;
|
||||
bytesread += bytes;
|
||||
if ((ogg_int64_t)(intptr_t)voice->LoopEnd > 0
|
||||
&& ov_pcm_tell(&vd->vf) >= (ogg_int64_t)(intptr_t)voice->LoopEnd) {
|
||||
&& (currentPosition = ov_pcm_tell(&vd->vf)) >= (ogg_int64_t)(intptr_t)voice->LoopEnd) {
|
||||
bytesread -= (currentPosition - (ogg_int64_t)(intptr_t)voice->LoopEnd) * voice->channels * 2; // (voice->bits>>3)
|
||||
err = ov_pcm_seek(&vd->vf,(ogg_int64_t)(intptr_t)voice->LoopStart);
|
||||
if (err != 0) {
|
||||
MV_Printf("MV_GetNextVorbisBlock ov_pcm_seek: LOOP_START %l, LOOP_END %l, err %d\n",
|
||||
|
|
Loading…
Reference in a new issue