开发者

Android Camera mediaserver dies after takepicture - works in Emulator

开发者 https://www.devze.com 2023-01-30 12:07 出处:网络
I am getting this error on my Archos 32 Android device.I found this post : Droid's mediaserver dies on camera.takePicture()

I am getting this error on my Archos 32 Android device. I found this post : Droid's mediaserver dies on camera.takePicture()

But it's not very specific as to what "missing pieces" are besides the preview.

My code runs on the emulator and on at least one other droid device. Is there just an incompatibility with the archos or could I still be missing something?

The archos has a working camera program so I know it's possible to have an app that takes a picture but I'm beginnning to think there's some incompatibility with the sdk. Where can I download a complete working camera eclipse project? All I can find is code snippets.

Here's the debug log:

12-10 10:37:46.827: DEBUG/CameraHalUtils(16242): PPM: STOPPED PREVIEW :5691.681 ms
12-10 10:37:46.835: INFO/cat(1096): <6>video4linux video0: w 640, h 480, fmt 56595559 -> w 640, h 480
12-10 10:37:47.110: DEBUG/CameraHalUtils(16242): PPM: AFTER CAPTURE YUV IMAGE :5975.250 ms
12-10 10:37:47.131: INFO/DEBUG(16218): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-10 10:37:47.131: INFO/DEBUG(16218): Build fingerprint: 'archos/g8/G8A/:2.2.1/FROYO/eng..20101126.043425:user/test-keys'
12-10 10:37:47.131: INFO/DEBUG(16218): pid: 16242, tid: 16250  >>> /system/bin/mediaserver <<<
12-10 10:37:47.131: INFO/DEBUG(16218): signal 11 (SIGSEGV), fault addr 00000000
12-10 10:37:47.131: INFO/DEBUG(16218):  r0 00000000  r1 aba8ee30  r2 fefefeff  r3 00000000
12-10 10:37:47.131: INFO/DEBUG(16218):  r4 a7940a6c  r5 000119c0  r6 00010b04  r7 40506eb4
12-10 10:37:47.131: INFO/DEBUG(16218):  r8 00100000  r9 a811c319  10 40407000  fp 00012400
12-10 10:37:47.131: INFO/DEBUG(16218):  ip 00000000  sp 40506ab8  lr a790f30f  pc a790f310  cpsr 20000030
12-10 10:37:47.139: INFO/DEBUG(16218):  d0  643a64696f72646e  d1  20656c6261696c52
12-10 10:37:47.139: INFO/DEBUG(16218):  d2  0049002e00650020  d3  0065006d00610043
12-10 10:37:47.139: INFO/DEBUG(16218):  d4  7e7f7c7e7f7e7c81  d5  7b7e80827f807d7f
12-10 10:37:47.139: INFO/DEBUG(16218):  d6  2728282a29292928  d7  3f80000028282828
12-10 10:37:47.139: INFO/DEBUG(16218):  d8  000000003f800000  d9  0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d10 0000000000000000  d11 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d12 0000000000000000  d13 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d14 0000000000000000  d15 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d16 3ff0000000000000  d17 3ff0000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d18 7e37e43c8800759c  d19 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d20 0000000000000000  d21 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d22 0000000000000000  d23 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d24 0000000000000000  d25 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d26 0000000000000000  d27 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d28 0000000000000000  d29 0000000000000000
12-10 10:37:47.139: INFO/DEBUG(16218):  d30 0000000000000000  d31 0000000000000000
12-10 10:37:47.139: DEBUG/AudioHardwareAM(16242): acquire wakelock
12-10 10:37:47.139: INFO/DEBUG(16218):  scr 20000010
12-10 10:37:47.163: INFO/cat(1096): <7>Configure McBSP for 1 phase
12-10 10:37:47.163: INFO/cat(1096): <7>Configure McBSP TX FIFO threshold to 1260
12-10 10:37:47.194: INFO/DEBUG(16218):          #00  pc 0000f310  /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218):          #01  pc 0000d2cc  /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218):          #02  pc 00009790  /system/lib/libcamera.so
12-10 10:37:47.202: INFO/DEBUG(16218):          #03  pc 0001beea  /system/lib/libutils.so
12-10 10:37:47.209: INFO/DEBUG(16218):          #04  pc 0001c380  /system/lib/libutils.so
12-10 10:37:47.209: INFO/DEBUG(16218):          #05  pc 00011188  /system/lib/libc.so
12-10 10:37:47.209: INFO/DEBUG(16218):          #06  pc 00010c68  /system/lib/libc.so
12-10 10:37:47.209: INFO/DEBUG(16218): code around pc:
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2f0 2b004603 2300bf14 b2db2301 d0462b00 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f300 681bab13 7368f503 f0044618 4603ff0b 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f310 f102681a 6812020c 47904618 46194603 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f320 681aab56 6b9bab25 46114608 f7f9461a 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f330 ab13ed9c f503681b 46187368 fef2f004 
12-10 10:37:47.217: INFO/DEBUG(16218): code around lr:
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2ec efeaf7f9 2b004603 2300bf14 b2db2301 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f2fc d0462b00 681bab13 7368f503 f0044618 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f30c 4603ff0b f102681a 6812020c 47904618 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f31c 46194603 681aab56 6b9bab25 46114608 
12-10 10:37:47.217: INFO/DEBUG(16218): a790f32c f7f9461a ab13ed9c f503681b 46187368 

Here's what the CameraHal is reporting:

12-10 10:37:41.100: DEBUG/CameraHal(16242): opening ti camera hal
12-10 10:37:41.100: DEBUG/CameraHal(16242): 5269: createInstance() ENTER
12-10 10:37:41.131: INFO/CameraHal(16242): initDefaultParameters: Camera type is OV7675
12-10 10:37:41.131: DEBUG/CameraHal(16242): 1364: CameraCreate() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): 1377: CameraCreate() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): 378: initDefaultParameters() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): 3749: setParameters() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): PreviewFormat yuv420sp
12-10 10:37:41.460: DEBUG/CameraHal(16242): PictureFormat jpeg
12-10 10:37:41.460: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 640, 176 and 480, 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 176, 176 and 144, 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): PreviewResolution by App 176 x 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.460: DEBUG/CameraHal(16242): Validating 640, 640 and 480, 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.460: DEBUG/CameraHal(16242): Picture Size by App 640 x 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): FRAMERATE 30
12-10 10:37:41.460: DEBUG/CameraHal(16242): Picture Size by CamHal 640 x 480
12-10 10:37:41.460: DEBUG/CameraHal(16242): Preview Resolution by CamHal 176 x 144
12-10 10:37:41.460: DEBUG/CameraHal(16242): Zoom by App 0
12-10 10:37:41.530: DEBUG/CameraHal(16242): 4432: setParameters() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): 679: initDefaultParameters() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): 3339: ICaptureCreate() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 3382: ICaptureCreate() EXIT
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING PROC THREAD 
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Shutter THREAD 
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Raw THREAD 
12-10 10:37:41.530: DEBUG/CameraHal(16242): STARTING Snapshot THREAD 
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2976: procThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2913: shutterThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2848: rawThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 2727: snapshotThread() ENTER
12-10 10:37:41.530: DEBUG/CameraHal(16242): 843: previewThread() ENTER
12-10 10:37:41.553: DEBUG/CameraHal(16242): 4724: getParameters() ENTER
12-10 10:37:41.553: DEBUG/CameraHal(16242): 4979: getParameters() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): 3749: setParameters() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): PreviewFormat yuv420sp
12-10 10:37:41.561: DEBUG/CameraHal(16242): PictureFormat jpeg
12-10 10:37:41.561: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 640, 176 and 480, 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 176, 176 and 144, 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): PreviewResolution by App 176 x 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): 350: validateSize() ENTER
12-10 10:37:41.561: DEBUG/CameraHal(16242): Validating 640, 640 and 480, 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): 367: validateSize() EXIT
12-10 10:37:41.561: DEBUG/CameraHal(16242): Picture Size by App 640 x 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): FRAMERATE 30
12-10 10:37:41.561: DEBUG/CameraHal(16242): Picture Size by CamHal 640 x 480
12-10 10:37:41.561: DEBUG/CameraHal(16242): Preview Resolution by CamHal 176 x 144
12-10 10:37:41.561: DEBUG/CameraHal(16242): Zoom by App 0
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4432: setParameters() EXIT
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4724: getParameters() ENTER
12-10 10:37:41.631: DEBUG/CameraHal(16242): 4979: getParameters() EXIT
12-10 10:37:41.631: DEBUG/CameraHal(16242): CameraHal setOverlay/1/00000000/00000000
12-10 10:37:41.631: ERROR/CameraHal(16242): Trying to set overlay, but overlay is null!, line:3472
12-10 10:37:41.663: DEBUG/CameraHal(16242): CameraHal setOverlay/1/00020340/00000000
12-10 10:37:41.663: DEBUG/CameraHal(16242): 3495: setOverlay() EXIT
12-10 10:37:41.663: DEBUG/CameraHal(16242): 3502: startPreview() ENTER
12-10 10:37:41.663: DEBUG/CameraHal(16242): Receive Command: PREVIEW_START
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1364: CameraCreate() ENTER
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1377: CameraCreate() EXIT
12-10 10:37:41.663: DEBUG/CameraHal(16242): 1425: CameraConfigure() ENTER
12-10 10:37:41.717: INFO/CameraHal(16242): CameraConfigure PreviewFormat: w=176 h=144
12-10 10:37:41.717: DEBUG/CameraHal(16242): CameraConfigure: framerate to set = 30
12-10 10:37:41.717: DEBUG/CameraHal(16242): CameraConfigure: Old frame rate is 30/1  fps
12-10 10:37:41.772: INFO/CameraHal(16242): CameraConfigure: New frame rate is 30/1 fps
12-10 10:37:41.772: DEBUG/CameraHal(16242): 1470: CameraConfigure() EXIT
12-10 10:37:41.772: DEBUG/CameraHal(16242): 1487: CameraStart() ENTER
12-10 10:37:41.772: DEBUG/CameraHal(16242): **CaptureQBuffers: preview size=176x144
12-10 10:37:41.772: DEBUG/CameraHal(16242): mPreviewFrameSize = 0xd000 = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): number of buffers = 6
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [0].start = 0x40d89000  length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [1].start = 0x40d96000  length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [2].start = 0x40da3000  length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [3].start = 0x40db0000  length = 53248
12-10 10:37:41.772: DEBUG/CameraHal(16242): User Buffer [4].start = 0x40dbd000  length = 53248
12-10 10:37:41.780: DEBUG/CameraHal(16242): User Buffer [5].start = 0x40dca000  length = 53248
12-10 10:37:41.874: ERROR/CameraHal(16242): Initial Crop: crop_top = 0, crop_left = 0, crop_width = 639, crop_height = 478
12-10 10:37:41.874: DEBUG/CameraHal(16242): 1594: CameraStart() EXIT
12-10 10:37:41.874: DEBUG/CameraHal(16242): PREVIEW_START ACK
12-10 10:37:41.874: DEBUG/CameraHal(16242): Preview Started!
12-10 10:37:41.874: DEBUG/CameraHal(16242): 3519: startPreview() EXIT
12-10 10:37:45.663: DEBUG/CameraHal(16242): 3686: takePicture() ENTER
12-10 10:37:45.663: DEBUG/CameraHal(16242): ENTER OPTION PREVIEW_CAPTURE
12-10 10:37:45.694: DEBUG/CameraHal(16242): 1610: CameraStop() ENTER
12-10 10:37:45.694: DEBUG/CameraHal(16242): Done dequeuing from Camera!
12-10 10:37:46.827: DEBUG/CameraHal(16242): 1644: CameraStop() EXIT
12-10 10:37:46.827: DEBUG/CameraHal(16242): 2297: ICapturePerform() ENTER
12-10 10:37:46.827: DEBUG/CameraHal(16242):  PICTURE NUMBER =1
12-10 10:37:46.827: DEBUG/CameraHal(16242): Picture Size: Width = 640     Height = 480
12-10 10:37:46.881: DEBUG/CameraHal(16242): pictureFrameSize = 0x96000 = 614400
12-10 10:37:46.881: DEBUG/CameraHal(16242): Picture Buffer: Base = 0x40e25000 Offset = 0x0
12-10 10:37:46.913: DEBUG/CameraHal(16242): De-queue the next avaliable buffer

My code: package com.example;

import android.app.Activity; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.ShutterCallback; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.FrameLayout;

public class CameraDemo extends Activity { private static final String TAG = "CameraDemo"; Camera camera; Preview preview; Button buttonClick;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    preview = new Preview(this);
    ((FrameLayout) findViewById(R.id.preview)).addView(preview);

    buttonClick = (Button) findViewById(R.id.buttonClick);
    buttonClick.setOnClickListener( new OnClickListener() {
        public void onClick(View v) {
            preview.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
        }
    });

    Log.d(TAG, "onCreate'd");
}


ShutterCallback shutterCallback = new ShutterCallback() {
    public void onShutter() {
        Log.d(TAG, "onShutter'd");
    }
};

/** Handles data for raw picture */
PictureCallback rawCallback = new PictureCallback() {
    public void onPictureTaken(byte[] data, Camera camera) {
        Log.d(TAG, "onPictureTaken - raw");
    }
};

/** Handles data for jpeg picture */
PictureCallback jpegCallback = new PictureCallback开发者_如何学运维() {
    public void onPictureTaken(byte[] data, Camera camera) {
        Log.d(TAG, "onPictureTaken - jpeg");
    }
};

}

package com.example;

import java.io.IOException; import android.content.Context; import android.hardware.Camera; import android.view.SurfaceHolder; import android.view.SurfaceView;

class Preview extends SurfaceView implements SurfaceHolder.Callback {

SurfaceHolder mHolder;
public Camera camera;

Preview(Context context) {
    super(context);

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

public void surfaceCreated(SurfaceHolder holder) {
    // The Surface has been created, acquire the camera and tell it where
    // to draw.
    camera = Camera.open();
    try {
        camera.setPreviewDisplay(holder);


    } catch (IOException e) {
        e.printStackTrace();
    }
}

public void surfaceDestroyed(SurfaceHolder holder) {
    // Surface will be destroyed when we return, so stop the preview.
    // Because the CameraDevice object is not a shared resource, it's very
    // important to release it when the activity is paused.
    camera.stopPreview();
    camera = null;
}

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    // Now that the size is known, set up the camera parameters and begin
    // the preview.
    Camera.Parameters parameters = camera.getParameters();
   // parameters.setPreviewSize(w, h);   // seems to crash if this code is enabled
    camera.setParameters(parameters);
    camera.startPreview();
}

}

Layout

<FrameLayout android:id="@+id/preview"
    android:layout_weight="1" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
</FrameLayout>

<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/buttonClick"
    android:text="Click" android:layout_gravity="center"></Button>


I also have an Archos32 exhibiting the same issue as you're having. Did you ever find an answer to your issue? I've checked out your code and my Archos32's mediaserver also dies upon trying to take a picture.

I have updated your code, though, and have it to a point where the media server doesn't die when taking a picture. I've basically updated Preview.java in the following manner:

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
    // Now that the size is known, set up the camera parameters and begin
    // the preview.
    Camera.Parameters parameters = camera.getParameters();

        List<Size> previewSizes = parameters.getSupportedPreviewSizes();
        Size optimalPreviewSize = previewSizes.get(0);

    // parameters.setPreviewSize(w, h);   // seems to crash if this code is enabled
    parameters.setPreviewFormat(ImageFormat.JPEG);
    parameters.setPreviewSize(optimalPreviewSize.width, optimalPreviewSize.height);     

    camera.setParameters(parameters);
    camera.startPreview();
}

This is pretty down & dirty, because I'm not doing anything special to determine which preview size to use for the camera preview - I'm just grabbing the first one found - but the outcome of the changes I have made are that the media server no longer crashes onShutter(), and rawCallback() and jpegCallback() are now called, too.

If you want, you can grab the getOptimalPreview method from Google's CameraPreview API Demo to get the "optimal" preview size to use when taking a picture.

Let me know if this works for you - I've been fighting with my Archos for hours trying to get the camera implemented without crashing, and have finally started to make some progress.

0

精彩评论

暂无评论...
验证码 换一张
取 消