Here is what I see.

In AudioRecord.h and in the MediaRecorder.AudioSource, the enum values
differ.

In native code (AudioRecord.h), the values are ..
44     enum input_source {
45         DEFAULT_INPUT   =-1,
46         MIC_INPUT       = 0,
47         VOICE_UPLINK_INPUT = 1,
48         VOICE_DOWNLINK_INPUT = 2,
49         VOICE_CALL_INPUT = 3,
50         NUM_INPUT_SOURCES
51     };
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=include/media/AudioRecord.h;h=13e51eea1eb478517f677df0642b4d2221571192;hb=donut#l38


In Java MediaRecorder AudioSource, the values are ..
120     public final class AudioSource {
121       /* Do not change these values without updating their
counterparts
122        * in include/media/mediarecorder.h!
123        */
124         private AudioSource() {}
125         public static final int DEFAULT = 0;
126         /** Microphone audio source */
127         public static final int MIC = 1;
128
129         /** Voice call uplink (Tx) audio source */
130         public static final int VOICE_UPLINK = 2;
131
132         /** Voice call downlink (Rx) audio source */
133         public static final int VOICE_DOWNLINK = 3;
134
135         /** Voice call uplink + downlink audio source */
136         public static final int VOICE_CALL = 4;
137     }

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/java/android/media/MediaRecorder.java;h=be4b489eb08683750fc2149184ab073e8528e6d4;hb=donut#l120


Now, if you look at AudioFlinger, any input source, whose value of
stream type is >=
NUM_INPUT_SOURCES (i.e., 4), we will get an "invalid stream type".
Because of the
mismatch of the enums, the Java API sets the value of VOICE_CALL
stream type as 4.
So, the check fails and we get the failure.

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=libs/audioflinger/AudioFlinger.cpp;h=da7cc8a6aa62a9d66097a6d9c7c184d132df7c3d;hb=donut#l2245

Fix:
Set the values of the stream types to be the same in the Java and c++
code.

Hope this helps.


On Nov 19, 1:31 pm, Hetal Patel <heta...@gmail.com> wrote:
> Understood, I thought that this was straightforward.
>
> When attempting to record a phone conversation on Android v1.6 (by
> using the
> "MediaRecorder.AudioSource.VOICE_CALL" audio source parameter), at
> runtime an
> exception is thrown unexpectedly. The test is performed on the HTC ADP
> with firmware 1.6.
>
> Here is the snippet of code, which causes the crash:
>
> recorder = new MediaRecorder();
> int audioSource = MediaRecorder.AudioSource.VOICE_CALL;
> recorder.setAudioSource(audioSource);
> recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
> recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
> final String filePath = Environment.getExternalStorageDirectory() + "/
> record.3gpp";
> final File file = new File(filePath);
> file.getParentFile().mkdirs();
> recorder.setOutputFile(filePath);
> recorder.prepare();
> recorder.start(); // Recording is now started
>
> At runtime, when the "recorder.start()" method is executed, an
> exception is thrown ,
> and in the DDMS log, I get:
>
> 09-30 15:35:09.812: ERROR/AudioFlinger(51): invalid stream type
> 09-30 15:35:09.812: ERROR/AudioRecord(51): AudioFlinger could not
> create record
> track, status: -22
> 09-30 15:35:09.812: ERROR/MediaRecorder(11204): start failed:
> -2147483648
>
> I hope that the problem reporting is now clear enough. Thank you for
> your time.
>
> On Nov 19, 1:31 pm, Hetal Patel <heta...@gmail.com> wrote:
>
> > I'm deseperately trying to use the "VOICE_CALL" parameter, in order to
> > record both
> > the in and out audio streams during a phone call. When using
> > "VOICE_UPLINK" or
> > "VOICE_DOWNLINK" or "MIC", it works fine, however.
>
> > At runtime, in the DDMS log, I get:
>
> > 09-30 15:35:09.812: ERROR/AudioFlinger(51): invalid stream type
> > 09-30 15:35:09.812: ERROR/AudioRecord(51): AudioFlinger could not
> > create record
> > track, status: -22
> > 09-30 15:35:09.812: ERROR/MediaRecorder(11204): start failed:
> > -2147483648
>
> > I'm running my test againt the ADP with the 1.6 firmware. Could
> > someone indicate
> > whether this problem is linked to the ADP drivers, or if it is
> > something which
> > resorts to Android v1.6, please?
>
> > Thank you for your support.
>
> > On Nov 19, 1:30 pm, Hetal Patel <heta...@gmail.com> wrote:
>
> > > In Package
>
> > > android.media
>
> > > Classes MediaRecorder.MediaSource now after API Level 4 ( Android
> > > 1.6 ) Includes
>
> > > 4 VOICE_CALL        Voice call uplink + downlink audio source
> > > 3 VOICE_DOWNLINK    Voice call downlink (Rx) audio source
> > > 2 VOICE_UPLINK      Voice call uplink (Tx) audio source
>
> > > See the Details here
>
> > >http://developer.android.com/reference/android/media/MediaRecorder.Au...
>
> > > On Nov 14, 5:04 am, Joachim Neumann <joac...@joachimneumann.com>
> > > wrote:
>
> > > > Hi Roman and Nick,
>
> > > > Looks like I have to exercise some patience with my plans to implement
> > > > a software hearing aid in a mobile phone.
>
> > > > Thanks a lot for your explanations and the helpful link to embedded.com
>
> > > > Joachim

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to