use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.
the class LocalRenderer method cleanUpPlayer.
private void cleanUpPlayer() {
if (DEBUG) {
Log.d(TAG, mDebugId + ": Cleaning up current player");
}
synchronized (mErrorLock) {
mError = null;
if (mErrorRetriever != null) {
mErrorRetriever.cancelRequestLocked(false);
// Don't set to null as we may need to cancel again with true if
// the object gets destroyed.
}
}
mAudioManager.abandonAudioFocus(this);
SurfaceHolder.Callback cb = mHolderCB;
mHolderCB = null;
SurfaceHolder holder = mHolder;
mHolder = null;
if (holder != null && cb != null) {
holder.removeCallback(cb);
}
MediaPlayer player = mPlayer;
mPlayer = null;
if (player != null) {
player.reset();
player.release();
}
}
use of android.view.SurfaceHolder in project android_frameworks_base by crdroidandroid.
the class RSSurfaceView method init.
private void init() {
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed
SurfaceHolder holder = getHolder();
holder.addCallback(this);
}
use of android.view.SurfaceHolder in project android_frameworks_base by AOSPA.
the class Camera2SurfaceViewTestCase method updatePreviewSurface.
/**
* Update the preview surface size.
*
* @param size The preview size to be updated.
*/
protected void updatePreviewSurface(Size size) {
if (size.equals(mPreviewSize) && mPreviewSurface != null) {
Log.w(TAG, "Skipping update preview surface size...");
return;
}
mPreviewSize = size;
Camera2SurfaceViewActivity ctsActivity = getActivity();
final SurfaceHolder holder = ctsActivity.getSurfaceView().getHolder();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
holder.setFixedSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
}
});
boolean res = ctsActivity.waitForSurfaceSizeChanged(WAIT_FOR_SURFACE_CHANGE_TIMEOUT_MS, mPreviewSize.getWidth(), mPreviewSize.getHeight());
assertTrue("wait for surface change to " + mPreviewSize.toString() + " timed out", res);
mPreviewSurface = holder.getSurface();
assertNotNull("Preview surface is null", mPreviewSurface);
assertTrue("Preview surface is invalid", mPreviewSurface.isValid());
}
use of android.view.SurfaceHolder in project android_frameworks_base by AOSPA.
the class CameraTest method checkTakePicture.
private void checkTakePicture() {
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "Start preview");
mCamera.startPreview();
waitForPreviewDone();
mCamera.setPreviewCallback(null);
mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
waitForSnapshotDone();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
}
use of android.view.SurfaceHolder in project android_frameworks_base by AOSPA.
the class CameraStressTest method testStressCameraSceneModes.
/**
* Stress test iterating on the various scene modes (action, night, party, etc.)
*/
@LargeTest
public void testStressCameraSceneModes() throws Exception {
try {
SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
Parameters params = mCameraTestHelper.getCameraParameters();
List<String> supportedSceneModes = params.getSupportedSceneModes();
assertNotNull("No scene modes supported", supportedSceneModes);
mOutput.write("Total number of loops: " + (NUMBER_OF_SCENE_MODE_LOOPS * supportedSceneModes.size()) + "\n");
Log.v(TAG, "Start preview");
mOutput.write("No of loop: ");
for (int i = 0; i < supportedSceneModes.size(); i++) {
for (int j = 0; j < NUMBER_OF_SCENE_MODE_LOOPS; j++) {
runOnLooper(new Runnable() {
@Override
public void run() {
mCameraTestHelper.setupCameraTest();
}
});
Log.v(TAG, "Setting scene mode to " + supportedSceneModes.get(i));
params.setSceneMode(supportedSceneModes.get(i));
mCameraTestHelper.setParameters(params);
mCameraTestHelper.startCameraPreview(surfaceHolder);
mCameraTestHelper.capturePhoto();
if (i == 0 && j == 0) {
mOutput.write(Integer.toString(j + i * NUMBER_OF_SCENE_MODE_LOOPS));
} else {
mOutput.write(", " + (j + i * NUMBER_OF_SCENE_MODE_LOOPS));
}
}
}
mCameraTestHelper.cleanupTestImages();
} catch (Exception e) {
Log.e(TAG, e.toString());
fail("Camera scene mode test Exception");
}
}
Aggregations