From 4bc035a65cac177be9294e69f110497e3b6e34e6 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 22 May 2009 09:18:15 -0700 Subject: Fix issue 1846343 - part 1 This change is the first part of a fix for issue 1846343, : - Added new enum values for input sources in AudioRecord and MediaRecorder for voice uplink, downlink and uplink+downlink sources. - renamed streamType to inputSource in all native functions handling audio record. A second change is required in opencore author driver and android audio input to completely fix the issue. --- media/java/android/media/AudioRecord.java | 14 ++++---------- media/java/android/media/MediaRecorder.java | 15 +++++++++++++++ media/jni/android_media_MediaRecorder.cpp | 2 +- media/libmedia/AudioRecord.cpp | 18 ++++++++++++------ media/libmedia/IAudioFlinger.cpp | 8 ++++---- 5 files changed, 36 insertions(+), 21 deletions(-) (limited to 'media') diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 3346bed..4d1535f 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -88,7 +88,7 @@ public class AudioRecord private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT = -16; private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17; private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT = -18; - private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE = -19; + private static final int AUDIORECORD_ERROR_SETUP_INVALIDSOURCE = -19; private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED = -20; // Events: @@ -113,13 +113,7 @@ public class AudioRecord */ @SuppressWarnings("unused") private int mNativeRecorderInJavaObj; - /** - * Accessed by native methods: provides access to record source constants - */ - @SuppressWarnings("unused") - private final static int SOURCE_DEFAULT = MediaRecorder.AudioSource.DEFAULT; - @SuppressWarnings("unused") - private final static int SOURCE_MIC = MediaRecorder.AudioSource.MIC; + /** * Accessed by native methods: provides access to the callback data. */ @@ -252,8 +246,8 @@ public class AudioRecord //-------------- // audio source - if ( (audioSource != MediaRecorder.AudioSource.DEFAULT) - && (audioSource != MediaRecorder.AudioSource.MIC) ) { + if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) || + (audioSource > MediaRecorder.getAudioSourceMax()) ) { throw (new IllegalArgumentException("Invalid audio source.")); } else { mRecordSource = audioSource; diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 5d90e62..44f21c8 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -125,6 +125,15 @@ public class MediaRecorder public static final int DEFAULT = 0; /** Microphone audio source */ public static final int MIC = 1; + + /** Voice call uplink (Tx) audio source */ + public static final int VOICE_UPLINK = 2; + + /** Voice call downlink (Rx) audio source */ + public static final int VOICE_DOWNLINK = 3; + + /** Voice call uplink + downlink audio source */ + public static final int VOICE_CALL = 4; } /** @@ -203,6 +212,12 @@ public class MediaRecorder throws IllegalStateException; /** + * Gets the maximum value for audio sources. + * @see android.media.MediaRecorder.AudioSource + */ + public static final int getAudioSourceMax() { return AudioSource.VOICE_CALL; } + + /** * Sets the video source to be used for recording. If this method is not * called, the output file will not contain an video track. The source needs * to be specified before setting recording-parameters or encoders. Call diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index cac65d6..7561af1 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -177,7 +177,7 @@ static void android_media_MediaRecorder_setAudioSource(JNIEnv *env, jobject thiz, jint as) { LOGV("setAudioSource(%d)", as); - if (as < AUDIO_SOURCE_DEFAULT || as > AUDIO_SOURCE_MIC) { + if (as < AUDIO_SOURCE_DEFAULT || as > AUDIO_SOURCE_MAX) { jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio source"); return; } diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 1720af0..4c8b02a 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -50,7 +50,7 @@ AudioRecord::AudioRecord() } AudioRecord::AudioRecord( - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -61,7 +61,7 @@ AudioRecord::AudioRecord( int notificationFrames) : mStatus(NO_INIT) { - mStatus = set(streamType, sampleRate, format, channelCount, + mStatus = set(inputSource, sampleRate, format, channelCount, frameCount, flags, cbf, user, notificationFrames); } @@ -82,7 +82,7 @@ AudioRecord::~AudioRecord() } status_t AudioRecord::set( - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -104,8 +104,8 @@ status_t AudioRecord::set( return NO_INIT; } - if (streamType == DEFAULT_INPUT) { - streamType = MIC_INPUT; + if (inputSource == DEFAULT_INPUT) { + inputSource = MIC_INPUT; } if (sampleRate == 0) { @@ -157,7 +157,7 @@ status_t AudioRecord::set( // open record channel status_t status; - sp record = audioFlinger->openRecord(getpid(), streamType, + sp record = audioFlinger->openRecord(getpid(), inputSource, sampleRate, format, channelCount, frameCount, @@ -201,6 +201,7 @@ status_t AudioRecord::set( mMarkerReached = false; mNewPosition = 0; mUpdatePeriod = 0; + mInputSource = (uint8_t)inputSource; return NO_ERROR; } @@ -242,6 +243,11 @@ int AudioRecord::frameSize() const return channelCount()*((format() == AudioSystem::PCM_8_BIT) ? sizeof(uint8_t) : sizeof(int16_t)); } +int AudioRecord::inputSource() const +{ + return (int)mInputSource; +} + // ------------------------------------------------------------------------- status_t AudioRecord::start() diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index 52bd7d4..eeaa54f 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -99,7 +99,7 @@ public: virtual sp openRecord( pid_t pid, - int streamType, + int inputSource, uint32_t sampleRate, int format, int channelCount, @@ -110,7 +110,7 @@ public: Parcel data, reply; data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); data.writeInt32(pid); - data.writeInt32(streamType); + data.writeInt32(inputSource); data.writeInt32(sampleRate); data.writeInt32(format); data.writeInt32(channelCount); @@ -384,14 +384,14 @@ status_t BnAudioFlinger::onTransact( case OPEN_RECORD: { CHECK_INTERFACE(IAudioFlinger, data, reply); pid_t pid = data.readInt32(); - int streamType = data.readInt32(); + int inputSource = data.readInt32(); uint32_t sampleRate = data.readInt32(); int format = data.readInt32(); int channelCount = data.readInt32(); size_t bufferCount = data.readInt32(); uint32_t flags = data.readInt32(); status_t status; - sp record = openRecord(pid, streamType, + sp record = openRecord(pid, inputSource, sampleRate, format, channelCount, bufferCount, flags, &status); reply->writeInt32(status); reply->writeStrongBinder(record->asBinder()); -- cgit v1.1