Android VideoFileRenderer: Wait for posted frames in release()
We need to wait for posted frames to be rendered first in release() instead of abruptly quitting, in order to simplify testing. BUG=webrtc:6545 R=sakal@webrtc.org Review URL: https://codereview.webrtc.org/2440703002 . Cr-Commit-Position: refs/heads/master@{#14722}
This commit is contained in:
parent
8c63a82bf5
commit
894c400c61
@ -11,10 +11,10 @@ package org.webrtc;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* Can be used to save the video frames to file.
|
||||
@ -121,8 +121,12 @@ public class VideoFileRenderer implements VideoRenderer.Callbacks {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release all resources. All already posted frames will be rendered first.
|
||||
*/
|
||||
public void release() {
|
||||
ThreadUtils.invokeAtFrontUninterruptibly(renderThreadHandler, new Runnable() {
|
||||
final CountDownLatch cleanupBarrier = new CountDownLatch(1);
|
||||
renderThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@ -133,8 +137,10 @@ public class VideoFileRenderer implements VideoRenderer.Callbacks {
|
||||
yuvConverter.release();
|
||||
eglBase.release();
|
||||
renderThread.quit();
|
||||
cleanupBarrier.countDown();
|
||||
}
|
||||
});
|
||||
ThreadUtils.awaitUninterruptibly(cleanupBarrier);
|
||||
}
|
||||
|
||||
public static native void nativeI420Scale(ByteBuffer srcY, int strideY, ByteBuffer srcU,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user