I want to understand how the preview buffer passed to addCallbackBuffer
relates to the byte[]
array passed through onPreviewFrame
, which prompts the following related questions.
Q1. I am guessing that the buffer passed in addCallbackBuffer
is used to store a new camera frame and that before onPreviewFrame
is called, that buffer is copied into the data buffer passed through onPreviewFrame
. If it is the case, that would mean that I can reuse my preview frame buffer by calling addCallbackBuffer
as soon as I enter onPreviewFrame
and note at the end of the function when I am done processing the buffer returned by onPreviewFrame
. Is that correct?
Q2. I am also not clear about the mechanism for using two preview frame buffers. Say I have two private byte[]
preview buffers added as follows during initialization:
addCallbackBuffer(mPreviewBuffer1);
addCallbackBuffer(mPreviewBuffer2);
How do I know which preview buffer was used when I am in onPreviewFrame
so that I can re-add the correct preview frame buffer with addCallbackBuffer
again?
private byte[] mPreviewBuffer1;
private byte[] mPreviewBuffer1;
...
public void onPreviewFrame(byte[] camera, Camera c) {
...
// how do I decide which buffer to re-add?
//c.addCallbackBuffer(mPreviewBuffer1);
//c.addCallbackBuffer(mPreviewBuffer2);
...
}
Q3. Am I understanding correctly that another thread is responsible for acquiring the frame buffer, i.e. that as long as a preview buffer is in the queue, we will be capturing a frame while onPreviewFrame
is executing? If that's not the case, having two call back buffers would not help with speed, would it?