fyhertz / libstreaming

A solution for streaming H.264, H.263, AMR, AAC using RTP on Android
Apache License 2.0
3.49k stars 1.08k forks source link

streaming.gl.SurfaceView: waiting time for new frame too long? #148

Closed t-benze closed 9 months ago

t-benze commented 9 years ago

In class streaming.gl.SurfaceView, the waiting time for synchronisation here is set to 2500 ms, ideally this should be fine as new frames keep coming in and notifying mSyncObject. However, in my testing, sometimes it will really wait for 2500ms and causes the preview to freeze. Changing the waiting time to a smaller value (e.g. 100) does fix the problem. But I'm not quite sure why this is happening, can anyone give some reasoning about this?

@Override
public void run() {
while (mRunning) {
  synchronized (mSyncObject) {
  mSyncObject.wait(2500);
  if (mFrameAvailable) {
  ....
  }
}
Locnath commented 9 years ago

Are you sure that there is no issue from camera? This thread should be woken up everytime there is a frame available from the camera driver. If you have the liberty of logging the android framework, I would recommend logging at camera HAL layer to ensure that the supply of camera frames is regular(should be ‘1000/fps’ milliseconds)

From: Benze Tang [mailto:notifications@github.com] Sent: 23 October 2015 14:28 To: fyhertz/libstreaming libstreaming@noreply.github.com Subject: [libstreaming] streaming.gl.SurfaceView: waiting time for new frame too long? (#148)

In class streaming.gl.SurfaceView, the waiting time for synchronisation here is set to 2500 ms, ideally this should be fine as new frames keep coming in and notifying mSyncObject. However, in my testing, sometimes it will really wait for 2500ms and causes the preview to freeze. Changing the waiting time to a smaller value (e.g. 100) will fix the problem. But I'm not sure why this is happening, can anyone give some reasoning about it?

@Override public void run() { while (mRunning) { synchronized (mSyncObject) { mSyncObject.wait(2500); if (mFrameAvailable) { .... } }

— Reply to this email directly or view it on GitHub https://github.com/fyhertz/libstreaming/issues/148 .