Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Recording Audio with MediaRecorder on G1
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
michael  
View profile  
 More options Feb 11, 10:02 am
From: michael <kuh...@gmail.com>
Date: Wed, 11 Feb 2009 07:02:41 -0800 (PST)
Local: Wed, Feb 11 2009 10:02 am
Subject: Recording Audio with MediaRecorder on G1
Hi,

I've written a little program (see below) to record audio using
MediaRecorder. While everything works fine in the emulator (SDK1r2),
the program does not work on the real phone (HTC G1). On the phone,
after pressing the start button, the audio file is created, but no
content is written to it (i.e. the file size remains 0). Also, no
exception is shown in logcat, and no AudioStreamInGeneric events are
generated (such events are generated when running the program on the
emulator).

Is there maybe a setting on the phone that I have to turn on (or off)?
Or am I missing something else?

I've set the permission to record audio in the android-manifest.xml
file using
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-
permission>

Thanks for any help!

Michael
------------------------------
My program code:

package ch.ethz.dcg.mictest;

import android.app.Activity;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MicTest extends Activity {

        private final static String TAG = MicTest.class.getSimpleName();

        private MediaRecorder recorder;
        private Button button;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                recorder = new MediaRecorder();

                button = (Button)findViewById(R.id.button);
                button.setText("start");
                button.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                        buttonClicked();
                        }
                });
        }

        private void buttonClicked() {
                if (button.getText().equals("start")) {
                        try {
                                recorder = new MediaRecorder();
                                String path = "/sdcard/test.3gpp";

                                recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                                recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                                recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                                recorder.setOutputFile(path);

                                recorder.prepare();
                                recorder.start();
                                button.setText("stop");
                        } catch (Exception e) {
                                Log.w(TAG, e);
                        }
                } else {
                        try {
                                recorder.stop();
                                recorder.release(); // Now the object cannot be reused
                                button.setEnabled(false);
                        } catch (Exception e) {
                                Log.w(TAG, e);
                        }
                }
        }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Sparks  
View profile  
 More options Feb 11, 11:42 pm
From: Dave Sparks <davidspa...@android.com>
Date: Wed, 11 Feb 2009 20:42:26 -0800 (PST)
Local: Wed, Feb 11 2009 11:42 pm
Subject: Re: Recording Audio with MediaRecorder on G1
I looked over the code and didn't see anything obvious. You won't see
anything in the log unless an error occurs - we try to minimize
logging in production code.

Run adb bugreport and take a look at the kernel log. You should see
something like this:

<6>[  820.265000] adsp: opening module AUDPREPROCTASK
<6>[  820.265488] audmgr_rpc_thread() start
<6>[  820.266281] adsp: module AUDPREPROCTASK has been registered
<6>[  820.266586] adsp: opening module AUDRECTASK
<6>[  820.267838] adsp: module AUDRECTASK has been registered
<6>[  820.268326] snd_set_device 256 1 0
<6>[  820.280289] audmgr: rpc_reply status 0
<6>[  820.291489] audmgr: rpc READY handle=0x00000000
<6>[  820.355332] audmgr: rpc CODEC_CONFIG volume=0x00002ff4
<6>[  820.355759] msm_adsp_enable() 'AUDPREPROCTASK'
<6>[  820.357468] adsp: rpc event=0, proc_id=2, module=14, image=0
<6>[  820.357926] adsp: module AUDPREPROCTASK: READY
<6>[  820.358688] msm_adsp_enable() 'AUDRECTASK'
<6>[  820.359909] adsp: rpc event=0, proc_id=2, module=13, image=0
<6>[  820.360825] adsp: module AUDRECTASK: READY
<6>[  820.362259] audpre: CFG ENABLED
<6>[  820.363663] audrec: PARAM CFG DONE
<6>[  822.417343] audrec: CFG SLEEP
<6>[  822.417801] msm_adsp_disable() 'AUDRECTASK'
<6>[  822.420151] msm_adsp_disable() 'AUDPREPROCTASK'
<6>[  822.423081] adsp: closing module AUDRECTASK
<6>[  822.423508] adsp: closing module AUDPREPROCTASK
<6>[  822.423843] adsp: disable interrupt
<6>[  822.424667] snd_set_device 256 1 1
<6>[  822.428391] audmgr: rpc_reply status 0
<3>[  822.458450] audmgr: DISABLED

If so, then we know that the audio input driver is being opened
correctly.

On Feb 11, 7:02 am, michael <kuh...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google