DOUAudioStreamer icon indicating copy to clipboard operation
DOUAudioStreamer copied to clipboard

当音频文件的mSampleRate不为44100时文件可能会提前结束

Open matthewyan opened this issue 10 years ago • 3 comments

我有个音频文件,取得的mSampleRate是48000,播放到文件后面时,还有一段没播完就提前终止了。

进入到这个判断逻辑了

SInt64 frame1 = _decodingContext.outputPos + ioOutputDataPackets; if (_decodingContext.decodeValidFrames != 0 && frame1 > _decodingContext.decodeValidFrames) { SInt64 framesToTrim64 = frame1 - _decodingContext.decodeValidFrames; UInt32 framesToTrim = (framesToTrim64 > ioOutputDataPackets) ? ioOutputDataPackets : (UInt32)framesToTrim64; int bytesToTrim = (int)(framesToTrim * _decodingContext.outputFormat.mBytesPerFrame);

fillBufList.mBuffers[0].mDataByteSize -= (unsigned long)bytesToTrim;
ioOutputDataPackets -= framesToTrim;

if (ioOutputDataPackets == 0) {
  [_lpcm setEnd:YES];
  pthread_mutex_unlock(&_decodingContext.mutex);
  return DOUAudioDecoderEndEncountered;
}

}

matthewyan avatar Apr 07 '15 09:04 matthewyan

看了一下,_decodingContext.decodeValidFrames不应该在开始更改,因为不管码率多少,在中间解码的过程中,最后解完都跟srcPti.mNumberValidFrames一样。

matthewyan avatar Apr 15 '15 08:04 matthewyan

@matthewyan 我也遇到了,请问你是如何处理的呢?

WenbinFan avatar May 04 '15 11:05 WenbinFan

@FANWENBIN 我把这个判断逻辑注释掉了: if (_decodingContext.decodeValidFrames != 0 && frame1 > _decodingContext.decodeValidFrames) { ... }

matthewyan avatar May 04 '15 11:05 matthewyan