MediaRecorder Launch Error Codes

I want to record a raw h.264 video without sound and possibly speed up HW (and replenish it later). So I decided to use MediaRecorder (and crack a socket for streaming).

I have the following code:

 final MediaRecorder recorder = new MediaRecorder(); final Camera camera = Camera.open(); camera.unlock(); recorder.setCamera(camera); recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); final CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW); recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); recorder.setVideoFrameRate(profile.videoFrameRate); recorder.setVideoEncodingBitRate(profile.videoBitRate); recorder.prepare(); recorder.start(); 

And bam! This is in logcat:

 E/MediaRecorder﹕ start failed: -38 

I started a googling search and found a lot of questions and answers, but nothing about my -38 error code.

So, I tried to look at the Android source code and noticed its native method, and I don't know where to look for that.

So my big question is: Is there a list of these error codes, so I can find what the -38 error means?

I also know that I am targeting API 10 (Gingerbread) and building with the latest SDK 21.

+7
android android-mediarecorder
source share
2 answers

Ok, I think I have an answer for you. The startup function that works with the error is defined in a file called mediarecorder.cpp . Found here:

 frameworks/av/media/libmedia/mediarecorder.cpp 

This start function returns a variable of type status_t and corresponds to the error you see.

Now the status_t type status_t defined in a file called Errors.h , which can be found here:

 system/core/include/utils/Errors.h 

This defines an enumeration corresponding to status_t , as shown here:

 enum { OK = 0, // Everything swell. NO_ERROR = 0, // No errors. UNKNOWN_ERROR = 0x80000000, NO_MEMORY = -ENOMEM, INVALID_OPERATION = -ENOSYS, BAD_VALUE = -EINVAL, BAD_TYPE = 0x80000001, NAME_NOT_FOUND = -ENOENT, PERMISSION_DENIED = -EPERM, NO_INIT = -ENODEV, ALREADY_EXISTS = -EEXIST, DEAD_OBJECT = -EPIPE, FAILED_TRANSACTION = 0x80000002, JPARKS_BROKE_IT = -EPIPE, #if !defined(HAVE_MS_C_RUNTIME) BAD_INDEX = -EOVERFLOW, NOT_ENOUGH_DATA = -ENODATA, WOULD_BLOCK = -EWOULDBLOCK, TIMED_OUT = -ETIMEDOUT, UNKNOWN_TRANSACTION = -EBADMSG, #else BAD_INDEX = -E2BIG, NOT_ENOUGH_DATA = 0x80000003, WOULD_BLOCK = 0x80000004, TIMED_OUT = 0x80000005, UNKNOWN_TRANSACTION = 0x80000006, #endif FDS_NOT_ALLOWED = 0x80000007, }; 

As you can see, some of the values ​​here are taken from errno.h , so we just need to see which one is equal to 38.

According to this source , 38 complies with ENOSYS . So, if we look at the status_t enumeration, we will see that in android, ENOSYS corresponds to an invalid operation. Not very useful, but I hope this at least points you in the right direction.

+4
source share

I meet this error code in my call recording application. this error code will be displayed in logcat when starting the media recorder when Microphone is in use in another application, such as Voice Assistant (for example: Ok google, etc.) or another application for recording calls.

0
source share

All Articles