MediaRecorder prepare() causes segfault

by dwilde1 » Mon, 29 Mar 2010 13:47:36 GMT


Sponsored Links
 Folks,

I have a situation where my MediaRecorder instance causes a segfault.
I'm working with a HTC Hero, Android 1.5+APIs. In the log i see (after
the segfault announcement) a register dump and then a numbered list
#00 libmedia_jni.so to  #18 linker, then a stack trace.

My Eclipse won't let me copy the log buffer, but I've done three
screen captures that sum it up. If you have time to examine, send me a
direct e-mail.

<pre><code>
    if (mRecorder == null) mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
//       mRecorder.setVideoSize(640, 480);
//       mRecorder.setVideoFrameRate(20);
    mRecorder.setPreviewDisplay(surfaceHolder.getSurface());
    mRecorder.prepare();
    mRecorder.start();
</code></pre>

I've tried other variants, including H263 and 3gp. What else can I do
to debug this? Everythin g seems fine up to prepare().

I tried adding the onErrorListener, but it seems to interfere with the
MediaPlayer's onErrorListener. I'm using a 4-second beep-count to
prepare for auto triggering of the camera, and when I enable the error
handler for the MR everything in my handler state machines goes awry.

Thanks in advance! :D

--



MediaRecorder prepare() causes segfault

by dwilde1 » Tue, 30 Mar 2010 03:09:10 GMT


 n Mar 28, 4:24pm, dwilde1 <dwil...@gmail.com> wrote:

UPDATE:

I learned about the log redirection capabilities of adb last night
after I posted:)

Here's the pertinent section from a run (note: I've reduced resolution
to 320x240 also, no joy):


I/ActivityManager( 80): Start proc com.ejf.convince.jenplus for
activity com.ejf.convince.jenplus/.JenPLUS: pid=17738 uid=10075
gids={1006, 3003}
I/jdwp (17738): received file descriptor 10 from ADB
W/System.err(17738): Can't dispatch DDM chunk 46454154: no handler
defined
W/System.err(17738): Can't dispatch DDM chunk 4d505251: no handler
defined
I/WindowManager( 80): Screen status=true, current orientation=-1,
SensorEnabled=false
I/WindowManager( 80): needSensorRunningLp, mCurrentAppOrientation
=-1
I/WindowManager( 80): Enabling listeners
W/ActivityThread(17738): Application com.ejf.convince.jenplus is
waiting for the debugger on port 8100...
I/System.out(17738): Sending WAIT chunk
I/dalvikvm(17738): Debugger is active
I/AlertDialog( 80): [onCreate] auto launch SIP.
I/WindowManager( 80): onOrientationChanged, rotation changed to 0
I/System.out(17738): Debugger has connected
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): waiting for debugger to settle...
I/System.out(17738): debugger has settled (1370)
I/ActivityManager( 80): Displayed activity
com.ejf.convince.jenplus/.JenPLUS: 5186 ms
I/OpenCore( 2696): [Hank debug] LN 289 FN CreateNode
I/AudioHardwareMSM72XX( 2696): AUDIO_START: start kernel pcm_out
driver.
W/AudioFlinger( 2696): write blocked for 96 msecs
I/PlayerDriver( 2696): CIQ 1625 sendEvent state=5
I/OpenCore( 2696): [Hank debug] LN 289 FN CreateNode
I/PlayerDriver( 2696): CIQ 1625 sendEvent state=5
I/OpenCore( 2696): [Hank debug] LN 289 FN CreateNode
I/PlayerDriver( 2696): CIQ 1625 sendEvent state=5
I/OpenCore( 2696): [Hank debug] LN 289 FN CreateNode
I/PlayerDriver( 2696): CIQ 1625 sendEvent state=5
W/AuthorDriver( 2696): Intended width(640) exceeds the max allowed
width(352). Max width is used instead.
W/AuthorDriver( 2696): Intended height(480) exceeds the max allowed
height(288). Max height is used instead.
I/AudioHardwareMSM72XX( 2696): AudioHardware pcm playback is going to
standby.
I/DEBUG (16094): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG (16094): Build fingerprint: 'sprint/htc_heroc/heroc/heroc:
1.5/CUPCAKE/85027:user/release-keys'
I/DEBUG (16094): pid: 17738, tid: 17738 >>>
com.ejf.convince.jenplus <<<
I/DEBUG (16094): signal 11 (SIGSEGV), fault addr 00000018
I/DEBUG (16094): r0 ffffe4c0 r1 ffffe268 r2 41098b48 r3 00000000
I/DEBUG (16094): r4 4349ff70 r5 ab309358 r6 0000a9c8 r7 beb0f448
I/DEBUG (16094): r8 beb0f468 r9 41049dd8 10 41a93b78 fp 00001070
I/DEBUG (16094): ip ad083e5c sp beb0f440 lr ad03dd75 pc
ab3054f4 cpsr 80000030
I


Sponsored Links


MediaRecorder prepare() causes segfault

by dwilde1 » Wed, 31 Mar 2010 01:24:12 GMT


 urther UPDATE: I've tried all combinations of CAMERA and RECORD_*
permissions in the Manifest and also tried reducing frame rate to 10
and resolution to 176x144, and preset the surfaceHolder to that same
resolution, still no joy, I've also started rebooting the phone every
time it crashes. What else haven't I understood or tried? I can't
debug into the prepare() code, and nobody seems to be able to answer
ANY of these MR questions. I'm fully prepared to accept that I'm
missing something, but I was raised -- and hammered during 27 years of
embedded coding -- to believe that a segfault in a VM interpreter is a
really bad (read: embarrassing :) thing to see.

I'd like to understand this and at least point to a fix. My next step
is to see what's involved in importing the rest of the source into my
system.


On Mar 29, 8:40am, dwilde1 <dwil...@gmail.com> wrote:

--



Other Threads

1. how to use camera application without sd card detect?

Hi, All,

    There is a question I need for help. When I was using the camera
application, the ERROR: Please insert SD card before using camera
jumped out because the driver of sd card haven't been porting
properly. Is there anyway to use android camera application without sd
card?

--~--~---------~--~----~------------~-------~--~----~

2. Question about linking to Android camera libraries from C++

Goal: I am trying to gain access to raw camera data on the G1 from native
code (JNI C++) so that I can do real time image processing on camera frames
at 15 fps. This will not work in the Java API because it takes too long for
the camera preview callback to load the data.

Setup: I am using the CodeSourcery C++ cross-compilation toolchain for ARM
development on Windows. I include the relevant header files from the
Android
source code and create a shared library object using the following commands
(my project name is flow):

arm-none-linux-gnueabi-g++ -I"C:\Program Files\Java\jdk1.6.0_11\include"
 -I"C:\Program Files\Java\jdk1.6.0_11\include\linux"
 -I"C:\Program
Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\core\include"
 -I"C:\Program
Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\base\include"
 -I"C:\Program Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\msm7k"
 -I"C:\Program
Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\base\camera\libcameraservice"
 -I"C:\Program
Files\Eclipse\SDK\android-sdk-windows-1.0_r2\source\common\include"
 -fpic -c flow.c

arm-none-linux-gnueabi-ld
 --dynamic-linker /system/bin/linker -nostdlib -I /system/bin/linker
 -rpath-link /system/lib
 -L"C:\Program Files\CodeSourcery\Sourcery G++
Lite\arm-none-linux-gnueabi\lib\ldscripts" -L.
 -shared -o libflow.so flow.o
 -z now @minlibs.inc

where minlibs.inc contains:
 -lcameraservice -lcamera -lui -lpixelflinger -lhardware -lgps -lcorecg
-lOmxH264Dec -lutils
 -lqcamera -lwpa_client -lnetutils -lcutils -lrpc -llog -lz -lstdc++ -lm
-lc
-ldl

In order to link, I pulled copies of all the libraries in the /system/lib
folder on the device to my computer. Then I take this shared library object
and copy it to the resource directory of my Java Android project in
Eclipse.
This Android activity uses System.load() to load my shared object and then
I
call the functions in the shared object from Java by standard JNI.

What works: I am able to run activities on the phone that call JNI
functions
which contain calls to Android functions. For example, I was able to write
a
message to the log and call android::CameraService::instantiate() and see
the log messages in the ddms de{*filter*}.

Problem: The camera libraries that I would like to interface with are using
a template class sp. A function I want to use returns type:
android::sp<android::CameraHardwareInterface>. As soon as I declare a
variable of this type, the constructor and destructor are required. Despite
lengthy efforts, I have not been able to get a program to run that contains
this type declaration. The code builds and links fine on my computer,
without warnings, but the Activity crashes immediately upon execution and
the ddms de{*filter*} just says that my shared object is "not found" whenever
this type declaration is present. I do not know how to get any more
detailed
debug messages from the dynamic linker.

What I've tried: I made a batch file that scans through all the libraries
using arm-none-linux-gnueabi-nm -C -D to find the symbols needed to declare
this type. I believe that my minlibs.inc file contains all necessary
libraries, however I am not sure. The code for the constructor and
destructor of sp is directly in the header files that I have included and
the only functions they reference are incStrong and decStrong, which are
found in libutils.so, which I have linked to. I also sorted the relevant
libraries based on dependencies obtained using
arm-none-linux-gnueabi-objdump -p as can be seen in the minlibs.inc file
above. I also tried using an alternate constructor by passing in a null
pointer:

 android::QualcommCameraHardware *qcam = NULL;
 android::sp<android::CameraHardwareInterface> cam(qcam);
 //android::sp<android::CameraHardwareInterface> cam;

My C++ function really only contains these lines, a call to
__android_log_write, and return.

Question: Any ideas on how to get this to run without crashing?

--~--~---------~--~----~------------~-------~--~----~

3. How to add app calendar on the G1 emulator?

4. How can I get the mms in my program?

5. Android PC connectivity

6. Testing Sync Application - Contacts and Calendar

7. Data syncronization-- Contacts and Calendar