ScreenRecorder icon indicating copy to clipboard operation
ScreenRecorder copied to clipboard

onRecording 回调时间有交错

Open linyongsheng opened this issue 7 years ago • 2 comments

你好 感谢你贡献的代码。发现录制进度回调的实现有点小瑕疵:

private void writeSampleData(int track, MediaCodec.BufferInfo buffer, ByteBuffer encodedData) {
...
if (!eos && mCallback != null) {
      mCallback.onRecording(buffer.presentationTimeUs);
}
...
}

也就是说在写入音频和视频数据都会导致回调,音视和视频各自的时间是线性递增,但是一起回调就有可能有时间交错

linyongsheng avatar Dec 14 '17 12:12 linyongsheng

是有可能发生,其实这里加个回调只是为了外部能够有时长提示而已。。。 你有什么好的建议吗?

yrom avatar Dec 15 '17 03:12 yrom

可以考虑保存最近回调的时间,若最新的回调时间大于该值,则允许回调,并更新最近回调时间;若最新回调时间小于该值,则不处理

linyongsheng avatar Dec 15 '17 09:12 linyongsheng