Permalink
Browse files

fixed to now work (need "raw" audio format)

  • Loading branch information...
1 parent 482efc5 commit 0749cd478248f79f5d57bf741a692a0780a7c90d @commonsguy committed Nov 5, 2012
@@ -18,7 +18,6 @@
import android.media.MediaRecorder;
import android.media.MediaRecorder.OnErrorListener;
import android.media.MediaRecorder.OnInfoListener;
-import android.os.Build;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor.AutoCloseInputStream;
@@ -35,7 +34,7 @@
public class MainActivity extends Activity implements
OnCheckedChangeListener, OnErrorListener, OnInfoListener {
- private static final String BASENAME="recording-stream.3gp";
+ private static final String BASENAME="recording-stream.amr";
private MediaRecorder recorder=null;
@Override
@@ -74,17 +73,9 @@ public void onCheckedChanged(CompoundButton buttonView,
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
- recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setOutputFile(getStreamFd());
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
- recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
- recorder.setAudioEncodingBitRate(160 * 1024);
- }
- else {
- recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
- }
-
+ recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioChannels(2);
try {
@@ -149,7 +140,7 @@ private FileDescriptor getStreamFd() {
pipe=ParcelFileDescriptor.createPipe();
new TransferThread(new AutoCloseInputStream(pipe[0]),
- new FileOutputStream(getOutputFile())).start();
+ new FileOutputStream(getOutputFile())).start();
}
catch (IOException e) {
Log.e(getClass().getSimpleName(), "Exception opening pipe", e);
@@ -182,7 +173,7 @@ public void run() {
}
in.close();
-
+
out.flush();
out.getFD().sync();
out.close();

0 comments on commit 0749cd4

Please sign in to comment.