I'm trying to do a voice recording app using the emulator - API21. I wrote my code in a way that the voice recording code portion is in another java file rather reside in the UI activity there. When I click on the start button, no error occurs and from the logs, it seems that recording has started. However, the app crashes after I click on the stop button. Do you know what I have done wrong here?
Logcat
07-19 15:22:53.180 1312-1476/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
07-19 15:22:53.290 953-953/? W/AudioFlinger﹕ acquireAudioSessionId() unknown client 2062 for session 8
07-19 15:22:53.310 953-953/? I/MPEG4Writer﹕ limits: 4294967295/0 bytes/us, bit rate: 12200 bps and the estimated moov size 3072 bytes
07-19 15:22:53.320 953-3278/? I/MediaCodecSource﹕ MediaCodecSource (audio) started
07-19 15:22:53.340 953-3280/? W/AudioFlinger﹕ RecordThread: buffer overflow
07-19 15:22:53.360 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.370 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.380 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.400 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.410 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.420 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.430 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.440 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.450 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.470 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.480 953-3286/? I/MPEG4Writer﹕ setStartTimestampUs: 40000
07-19 15:22:53.480 953-3286/? I/MPEG4Writer﹕ Earliest track starting time: 40000
07-19 15:22:53.490 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:53.530 953-3279/? W/AudioSource﹕ AudioRecord reported overrun!
07-19 15:22:54.950 953-1286/? D/MPEG4Writer﹕ Audio track stopping
07-19 15:22:54.950 953-1286/? D/MPEG4Writer﹕ Audio track source stopping
07-19 15:22:54.960 1312-1476/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
07-19 15:22:54.970 953-3278/? I/MediaCodecSource﹕ encoder (audio) stopped
07-19 15:22:55.000 953-1284/? W/AudioFlinger﹕ write blocked for 1470 msecs, 1 delayed writes, thread 0xf62b7000
--------- beginning of crash
07-19 15:22:55.080 950-950/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-19 15:22:55.080 950-950/? I/DEBUG﹕ Build fingerprint: 'generic_x86_64/sdk_phone_x86_64/generic_x86_64:5.0.2/LSY64/1772600:eng/test-keys'
07-19 15:22:55.080 950-950/? I/DEBUG﹕ Revision: '0'
07-19 15:22:55.080 950-950/? I/DEBUG﹕ ABI: 'x86_64'
07-19 15:22:55.080 950-950/? I/DEBUG﹕ pid: 2062, tid: 2070, name: Binder_1 >>> ch.com.voiceme <<<
07-19 15:22:55.080 950-950/? I/DEBUG﹕ signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdead4321
07-19 15:22:55.130 950-950/? I/DEBUG﹕ rax 0000000000000004 rbx 0000000000000004 rcx 00007f8c53c714b8 rdx 0000000000000001
07-19 15:22:55.130 950-950/? I/DEBUG﹕ rsi 000000000000186d rdi 000000007035c240
07-19 15:22:55.130 950-950/? I/DEBUG﹕ r8 0000000000000000 r9 000000007144d434 r10 000000007144d434 r11 00007f8c53c716d8
07-19 15:22:55.130 950-950/? I/DEBUG﹕ r12 00000000dead4321 r13 0000000000000000 r14 00000000719a59d4 r15 000000007035c240
07-19 15:22:55.130 950-950/? I/DEBUG﹕ cs 0000000000000033 ss 000000000000002b
07-19 15:22:55.130 950-950/? I/DEBUG﹕ rip 00007f8c61ae607c rbp 00007f8c5ac2e800 rsp 00007f8c53c71360 eflags 0000000000010206
07-19 15:22:55.130 950-950/? I/DEBUG﹕ backtrace:
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #00 pc 00000000000b507c /system/lib64/libart.so (art::CheckMethodArguments(art::mirror::ArtMethod*, unsigned int*)+629)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #01 pc 000000000033b0b6 /system/lib64/libart.so (art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, __va_list_tag*)+1094)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #02 pc 0000000000273c2d /system/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, __va_list_tag*)+397)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #03 pc 000000000011b284 /system/lib64/libart.so (art::CheckJNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, __va_list_tag*)+132)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #04 pc 0000000000021ae5 /system/lib64/libmedia_jni.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+133)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #05 pc 000000000003bd54 /system/lib64/libmedia_jni.so (JNIMediaRecorderListener::notify(int, int, int)+68)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #06 pc 00000000000dee01 /system/lib64/libmedia.so (android::MediaRecorder::notify(int, int, int)+145)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #07 pc 00000000000d5efa /system/lib64/libmedia.so (android::BnMediaRecorderClient::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+90)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #08 pc 0000000000036b44 /system/lib64/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+116)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #09 pc 000000000003fea7 /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+871)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #10 pc 00000000000400f1 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+65)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #11 pc 0000000000040169 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+89)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #12 pc 0000000000047826 /system/lib64/libbinder.so (android::PoolThread::threadLoop()+22)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #13 pc 0000000000018eb8 /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+376)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #14 pc 00000000000a6264 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+84)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #15 pc 000000000002731e /system/lib64/libc.so (__pthread_start(void*)+46)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #16 pc 000000000002339b /system/lib64/libc.so (__start_thread+11)
07-19 15:22:55.130 950-950/? I/DEBUG﹕ #17 pc 0000000000019885 /system/lib64/libc.so (__bionic_clone+53)
07-19 15:22:55.180 950-950/? I/DEBUG﹕ Tombstone written to: /data/tombstones/tombstone_09
07-19 15:22:55.180 1312-1351/system_process I/BootReceiver﹕ Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE)
07-19 15:22:55.180 1312-2211/system_process E/SharedPreferencesImpl﹕ Couldn't create directory for SharedPreferences file shared_prefs/log_files.xml
07-19 15:22:55.190 1312-3305/system_process W/ActivityManager﹕ Exception thrown during pause
android.os.TransactionTooLargeException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:496)
at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:701)
at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:852)
at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2754)
at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2611)
at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2453)
at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11511)
at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11408)
at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12087)
at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11603)
at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
07-19 15:22:55.190 1312-3305/system_process E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!
07-19 15:22:55.190 1312-3305/system_process I/ActivityManager﹕ Restarting because process died: ActivityRecord{78fabd1 u0 ch.com.voiceme/.VoiceMe t71}
07-19 15:22:55.190 1312-3305/system_process E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!
07-19 15:22:55.210 1312-1441/system_process W/InputDispatcher﹕ channel '3bddbe08 ch.com.voiceme/ch.com.voiceme.AudioRecTimeSchedule (server)' ~ Consumer closed input channel or an error occurred. events=0x9
07-19 15:22:55.210 1312-1441/system_process E/InputDispatcher﹕ channel '3bddbe08 ch.com.voiceme/ch.com.voiceme.AudioRecTimeSchedule (server)' ~ Channel is unrecoverably broken and will be disposed!
07-19 15:22:55.210 1312-1441/system_process W/InputDispatcher﹕ channel '1c939c32 ch.com.voiceme/ch.com.voiceme.VoiceMe (server)' ~ Consumer closed input channel or an error occurred. events=0x9
07-19 15:22:55.210 1312-1441/system_process E/InputDispatcher﹕ channel '1c939c32 ch.com.voiceme/ch.com.voiceme.VoiceMe (server)' ~ Channel is unrecoverably broken and will be disposed!
07-19 15:22:55.260 1312-1732/system_process I/WindowState﹕ WIN DEATH: Window{1c939c32 u0 ch.com.voiceme/ch.com.voiceme.VoiceMe}
07-19 15:22:55.260 1312-1732/system_process W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '1c939c32 ch.com.voiceme/ch.com.voiceme.VoiceMe (server)'
07-19 15:22:55.270 1312-3305/system_process W/ActivityManager﹕ Exception when starting activity ch.com.voiceme/.VoiceMe
MainActivity.java
private void onRecord(boolean start) {
if (start) {
audioRec.startRecording();}
else {audioRec.stopRecording();}
}
private void onPlay(boolean start) {
if (start) { audioRec.startPlaying(); }
else { audioRec.stopPlaying(); }
}
AudioRecord.java
public AudioRecord() {
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
Log.d("path", mFileName);
mFileName += "/audiorecordtest.3gp";
}
public void startPlaying() {
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
}
public void stopPlaying() {
if (mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
}
public void startRecording() {
try {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
public void stopRecording() {
try {
mRecorder.stop();
}
catch(RuntimeException ex){ Log.e("testttt", ex.getMessage()); /* Ignore */ }
if (mRecorder != null) {
mRecorder.reset();
mRecorder.release();
mRecorder = null;
}
}