Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db2b5f44 authored by Ruben Brunk's avatar Ruben Brunk Committed by Android (Google) Code Review
Browse files

Merge "camera2: Release surface in ImageReader#close and fix legacy cleanup"

parents a483a1d8 443ab2c7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -292,6 +292,10 @@ public class LegacyCameraDevice implements AutoCloseable {
                    Log.e(TAG, "configureOutputs - null outputs are not allowed");
                    return BAD_VALUE;
                }
                if (!output.isValid()) {
                    Log.e(TAG, "configureOutputs - invalid output surfaces are not allowed");
                    return BAD_VALUE;
                }
                StreamConfigurationMap streamConfigurations = mStaticCharacteristics.
                        get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

@@ -522,7 +526,7 @@ public class LegacyCameraDevice implements AutoCloseable {
     * @return the width and height of the surface
     *
     * @throws NullPointerException if the {@code surface} was {@code null}
     * @throws IllegalStateException if the {@code surface} was invalid
     * @throws BufferQueueAbandonedException if the {@code surface} was invalid
     */
    public static Size getSurfaceSize(Surface surface) throws BufferQueueAbandonedException {
        checkNotNull(surface);
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class LegacyExceptionUtils {
            case CameraBinderDecorator.NO_ERROR: {
                return CameraBinderDecorator.NO_ERROR;
            }
            case CameraBinderDecorator.ENODEV: {
            case CameraBinderDecorator.BAD_VALUE: {
                throw new BufferQueueAbandonedException();
            }
        }
+4 −0
Original line number Diff line number Diff line
@@ -498,6 +498,10 @@ public class RequestThreadManager {
            return;
        }
        for(Surface s : surfaces) {
            if (s == null || !s.isValid()) {
                Log.w(TAG, "Jpeg surface is invalid, skipping...");
                continue;
            }
            try {
                LegacyCameraDevice.setSurfaceFormat(s, LegacyMetadataMapper.HAL_PIXEL_FORMAT_BLOB);
            } catch (LegacyExceptionUtils.BufferQueueAbandonedException e) {
+1 −2
Original line number Diff line number Diff line
@@ -373,8 +373,7 @@ static sp<ANativeWindow> getNativeWindow(JNIEnv* env, jobject surface) {
        return NULL;
    }
    if (anw == NULL) {
        jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
                "Surface had no valid native window.");
        ALOGE("%s: Surface had no valid native window.", __FUNCTION__);
        return NULL;
    }
    return anw;
+1 −0
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ public class ImageReader implements AutoCloseable {
    @Override
    public void close() {
        setOnImageAvailableListener(null, null);
        if (mSurface != null) mSurface.release();
        nativeClose();
    }