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

Commit 01525dd3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Pause callback during stopPreview()" into sc-dev

parents 431cb2e4 33d09ca4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -935,6 +935,7 @@ status_t Camera2Client::startPreviewL(Parameters &params, bool restart) {
        return res;
    }

    mCallbackProcessor->unpauseCallback();
    params.state = Parameters::PREVIEW;
    return OK;
}
@@ -969,6 +970,7 @@ void Camera2Client::stopPreviewL() {
            FALLTHROUGH_INTENDED;
        case Parameters::RECORD:
        case Parameters::PREVIEW:
            mCallbackProcessor->pauseCallback();
            syncWithDevice();
            // Due to flush a camera device sync is not a sufficient
            // guarantee that the current client parameters are
+10 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ CallbackProcessor::CallbackProcessor(sp<Camera2Client> client):
        mDevice(client->getCameraDevice()),
        mId(client->getCameraId()),
        mCallbackAvailable(false),
        mCallbackPaused(true),
        mCallbackToApp(false),
        mCallbackStreamId(NO_STREAM) {
}
@@ -216,6 +217,14 @@ int CallbackProcessor::getStreamId() const {
    return mCallbackStreamId;
}

void CallbackProcessor::unpauseCallback() {
    mCallbackPaused = false;
}

void CallbackProcessor::pauseCallback() {
    mCallbackPaused = true;
}

void CallbackProcessor::dump(int /*fd*/, const Vector<String16>& /*args*/) const {
}

@@ -234,7 +243,7 @@ bool CallbackProcessor::threadLoop() {

    do {
        sp<Camera2Client> client = mClient.promote();
        if (client == 0) {
        if (client == 0 || mCallbackPaused) {
            res = discardNewCallback();
        } else {
            res = processNewCallback(client);
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_CALLBACKPROCESSOR_H
#define ANDROID_SERVERS_CAMERA_CAMERA2_CALLBACKPROCESSOR_H

#include <atomic>

#include <utils/Thread.h>
#include <utils/String16.h>
#include <utils/Vector.h>
@@ -52,6 +54,9 @@ class CallbackProcessor:
    status_t deleteStream();
    int getStreamId() const;

    void unpauseCallback();
    void pauseCallback();

    void dump(int fd, const Vector<String16>& args) const;
  private:
    static const nsecs_t kWaitDuration = 10000000; // 10 ms
@@ -67,6 +72,8 @@ class CallbackProcessor:
        NO_STREAM = -1
    };

    std::atomic<bool> mCallbackPaused;

    // True if mCallbackWindow is a remote consumer, false if just the local
    // mCallbackConsumer
    bool mCallbackToApp;