Hi,
My MediaRecorder tried to use the camera object opened by Camera app
through setCamera function, however, it got the following warming
message and the program halted.
W/CameraService(  966): Tried to connect to locked camera

It seems that connect function always halts my program since camera
serveice client had been connected to a process(camera ap process),
anyone konws how to fix this issue?

status_t CameraService::Client::connect(const sp<ICameraClient>&
client)
{
    // connect a new process to the camera
    LOGV("connect (%p)", client->asBinder().get());

    // I hate this hack, but things get really ugly when the media
recorder
    // service is handing back the camera to the app. The
ICameraClient
    // destructor will be called during the same IPC, making it look
like
    // the remote client is trying to disconnect. This hack
temporarily
    // sets the mClientPid to an invalid pid to prevent the hardware
from
    //  being torn down.
    {

        // hold a reference to the old client or we will deadlock if
the client is
        // in the same process and we hold the lock when we remove the
reference
        sp<ICameraClient> oldClient;
        {
            Mutex::Autolock _l(mLock);
            if (mClientPid != 0) {
                LOGW("Tried to connect to locked camera");
                return -EBUSY;
            }
            oldClient = mCameraClient;

            // did the client actually change?
            if (client->asBinder() == mCameraClient->asBinder())
return NO_ERROR;

            mCameraClient = client;
            mClientPid = -1;
            mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
            LOGV("connect new process (%d) to existing camera client",
mClientPid);
        }

    }
    // the old client destructor is called when oldClient goes out of
scope
    // now we set the new PID to lock the interface again
    mClientPid = IPCThreadState::self()->getCallingPid();

    return NO_ERROR;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"android-framework" group.
To post to this group, send email to android-framework@googlegroups.com
To unsubscribe from this group, send email to 
android-framework+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/android-framework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to