Loading api/current.xml +44 −0 Original line number Original line Diff line number Diff line Loading @@ -71065,6 +71065,17 @@ visibility="public" visibility="public" > > </constructor> </constructor> <method name="getAudioSourceMax" return="int" abstract="false" native="false" synchronized="false" static="true" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="getMaxAmplitude" <method name="getMaxAmplitude" return="int" return="int" abstract="false" abstract="false" Loading Loading @@ -71466,6 +71477,39 @@ visibility="public" visibility="public" > > </field> </field> <field name="VOICE_CALL" type="int" transient="false" volatile="false" value="4" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="VOICE_DOWNLINK" type="int" transient="false" volatile="false" value="3" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="VOICE_UPLINK" type="int" transient="false" volatile="false" value="2" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> </class> <interface name="MediaRecorder.OnErrorListener" <interface name="MediaRecorder.OnErrorListener" abstract="true" abstract="true" core/jni/android_media_AudioRecord.cpp +9 −25 Original line number Original line Diff line number Diff line Loading @@ -45,8 +45,6 @@ struct fields_t { jmethodID postNativeEventInJava; //... event post callback method jmethodID postNativeEventInJava; //... event post callback method int PCM16; //... format constants int PCM16; //... format constants int PCM8; //... format constants int PCM8; //... format constants int SOURCE_DEFAULT; //... record source constants int SOURCE_MIC; //... record source constants jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data }; }; Loading @@ -66,7 +64,7 @@ struct audiorecord_callback_cookie { #define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16 #define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16 #define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17 #define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17 #define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18 #define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18 #define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE -19 #define AUDIORECORD_ERROR_SETUP_INVALIDSOURCE -19 #define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20 #define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20 jint android_media_translateRecorderErrorCode(int code) { jint android_media_translateRecorderErrorCode(int code) { Loading Loading @@ -154,15 +152,14 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, int frameSize = nbChannels * bytesPerSample; int frameSize = nbChannels * bytesPerSample; size_t frameCount = buffSizeInBytes / frameSize; size_t frameCount = buffSizeInBytes / frameSize; // compare the source against the Java constants // convert and check input source value AudioRecord::stream_type arSource; // input_source values defined in AudioRecord.h are equal to if (source == javaAudioRecordFields.SOURCE_DEFAULT) { // JAVA MediaRecord.AudioSource values minus 1. arSource = AudioRecord::DEFAULT_INPUT; AudioRecord::input_source arSource = (AudioRecord::input_source)(source - 1); } else if (source == javaAudioRecordFields.SOURCE_MIC) { if (arSource < AudioRecord::DEFAULT_INPUT || arSource = AudioRecord::MIC_INPUT; arSource >= AudioRecord::NUM_INPUT_SOURCES) { } else { LOGE("Error creating AudioRecord: unknown source."); LOGE("Error creating AudioRecord: unknown source."); return AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE; return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE; } } audiorecord_callback_cookie *lpCallbackData = NULL; audiorecord_callback_cookie *lpCallbackData = NULL; Loading Loading @@ -511,8 +508,6 @@ static JNINativeMethod gMethods[] = { #define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative" #define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative" #define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT" #define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT" #define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT" #define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT" #define JAVA_CONST_SOURCEDEFAULT_NAME "SOURCE_DEFAULT" #define JAVA_CONST_SOURCEMIC_NAME "SOURCE_MIC" #define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj" #define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj" #define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie" #define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie" Loading Loading @@ -583,17 +578,6 @@ int register_android_media_AudioRecord(JNIEnv *env) return -1; return -1; } } // Get the recording source constants from the AudioRecord class if ( !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, kClassPathName, JAVA_CONST_SOURCEDEFAULT_NAME, &(javaAudioRecordFields.SOURCE_DEFAULT)) || !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, kClassPathName, JAVA_CONST_SOURCEMIC_NAME, &(javaAudioRecordFields.SOURCE_MIC)) ) { // error log performed in getIntConstantFromClass() return -1; } return AndroidRuntime::registerNativeMethods(env, return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); kClassPathName, gMethods, NELEM(gMethods)); } } Loading include/media/AudioRecord.h +13 −6 Original line number Original line Diff line number Diff line Loading @@ -39,10 +39,15 @@ class AudioRecord { { public: public: enum stream_type { // input sources values must always be defined in the range // [AudioRecord::DEFAULT_INPUT, AudioRecord::NUM_INPUT_SOURCES[ enum input_source { DEFAULT_INPUT =-1, DEFAULT_INPUT =-1, MIC_INPUT = 0, MIC_INPUT = 0, NUM_STREAM_TYPES VOICE_UPLINK_INPUT = 1, VOICE_DOWNLINK_INPUT = 2, VOICE_CALL_INPUT = 3, NUM_INPUT_SOURCES }; }; static const int DEFAULT_SAMPLE_RATE = 8000; static const int DEFAULT_SAMPLE_RATE = 8000; Loading Loading @@ -118,7 +123,7 @@ public: * * * Parameters: * Parameters: * * * streamType: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT). * inputSource: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT). * sampleRate: Track sampling rate in Hz. * sampleRate: Track sampling rate in Hz. * format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed * format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed * 16 bits per sample). * 16 bits per sample). Loading @@ -140,7 +145,7 @@ public: RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE }; }; AudioRecord(int streamType, AudioRecord(int inputSource, uint32_t sampleRate = 0, uint32_t sampleRate = 0, int format = 0, int format = 0, int channelCount = 0, int channelCount = 0, Loading @@ -165,7 +170,7 @@ public: * - NO_INIT: audio server or audio hardware not initialized * - NO_INIT: audio server or audio hardware not initialized * - PERMISSION_DENIED: recording is not allowed for the requesting process * - PERMISSION_DENIED: recording is not allowed for the requesting process * */ * */ status_t set(int streamType = 0, status_t set(int inputSource = 0, uint32_t sampleRate = 0, uint32_t sampleRate = 0, int format = 0, int format = 0, int channelCount = 0, int channelCount = 0, Loading Loading @@ -197,6 +202,7 @@ public: int channelCount() const; int channelCount() const; uint32_t frameCount() const; uint32_t frameCount() const; int frameSize() const; int frameSize() const; int inputSource() const; /* After it's created the track is not active. Call start() to /* After it's created the track is not active. Call start() to Loading Loading @@ -323,7 +329,8 @@ private: audio_track_cblk_t* mCblk; audio_track_cblk_t* mCblk; uint8_t mFormat; uint8_t mFormat; uint8_t mChannelCount; uint8_t mChannelCount; uint8_t mReserved[2]; uint8_t mInputSource; uint8_t mReserved; status_t mStatus; status_t mStatus; uint32_t mLatency; uint32_t mLatency; Loading include/media/IAudioFlinger.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ public: virtual sp<IAudioRecord> openRecord( virtual sp<IAudioRecord> openRecord( pid_t pid, pid_t pid, int streamType, int inputSource, uint32_t sampleRate, uint32_t sampleRate, int format, int format, int channelCount, int channelCount, Loading include/media/mediarecorder.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,10 @@ typedef void (*media_completion_f)(status_t status, void *cookie); enum audio_source { enum audio_source { AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4, AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_CALL }; }; enum video_source { enum video_source { Loading Loading
api/current.xml +44 −0 Original line number Original line Diff line number Diff line Loading @@ -71065,6 +71065,17 @@ visibility="public" visibility="public" > > </constructor> </constructor> <method name="getAudioSourceMax" return="int" abstract="false" native="false" synchronized="false" static="true" final="true" deprecated="not deprecated" visibility="public" > </method> <method name="getMaxAmplitude" <method name="getMaxAmplitude" return="int" return="int" abstract="false" abstract="false" Loading Loading @@ -71466,6 +71477,39 @@ visibility="public" visibility="public" > > </field> </field> <field name="VOICE_CALL" type="int" transient="false" volatile="false" value="4" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="VOICE_DOWNLINK" type="int" transient="false" volatile="false" value="3" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="VOICE_UPLINK" type="int" transient="false" volatile="false" value="2" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> </class> <interface name="MediaRecorder.OnErrorListener" <interface name="MediaRecorder.OnErrorListener" abstract="true" abstract="true"
core/jni/android_media_AudioRecord.cpp +9 −25 Original line number Original line Diff line number Diff line Loading @@ -45,8 +45,6 @@ struct fields_t { jmethodID postNativeEventInJava; //... event post callback method jmethodID postNativeEventInJava; //... event post callback method int PCM16; //... format constants int PCM16; //... format constants int PCM8; //... format constants int PCM8; //... format constants int SOURCE_DEFAULT; //... record source constants int SOURCE_MIC; //... record source constants jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data }; }; Loading @@ -66,7 +64,7 @@ struct audiorecord_callback_cookie { #define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16 #define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16 #define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17 #define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17 #define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18 #define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18 #define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE -19 #define AUDIORECORD_ERROR_SETUP_INVALIDSOURCE -19 #define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20 #define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20 jint android_media_translateRecorderErrorCode(int code) { jint android_media_translateRecorderErrorCode(int code) { Loading Loading @@ -154,15 +152,14 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, int frameSize = nbChannels * bytesPerSample; int frameSize = nbChannels * bytesPerSample; size_t frameCount = buffSizeInBytes / frameSize; size_t frameCount = buffSizeInBytes / frameSize; // compare the source against the Java constants // convert and check input source value AudioRecord::stream_type arSource; // input_source values defined in AudioRecord.h are equal to if (source == javaAudioRecordFields.SOURCE_DEFAULT) { // JAVA MediaRecord.AudioSource values minus 1. arSource = AudioRecord::DEFAULT_INPUT; AudioRecord::input_source arSource = (AudioRecord::input_source)(source - 1); } else if (source == javaAudioRecordFields.SOURCE_MIC) { if (arSource < AudioRecord::DEFAULT_INPUT || arSource = AudioRecord::MIC_INPUT; arSource >= AudioRecord::NUM_INPUT_SOURCES) { } else { LOGE("Error creating AudioRecord: unknown source."); LOGE("Error creating AudioRecord: unknown source."); return AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE; return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE; } } audiorecord_callback_cookie *lpCallbackData = NULL; audiorecord_callback_cookie *lpCallbackData = NULL; Loading Loading @@ -511,8 +508,6 @@ static JNINativeMethod gMethods[] = { #define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative" #define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative" #define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT" #define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT" #define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT" #define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT" #define JAVA_CONST_SOURCEDEFAULT_NAME "SOURCE_DEFAULT" #define JAVA_CONST_SOURCEMIC_NAME "SOURCE_MIC" #define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj" #define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj" #define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie" #define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie" Loading Loading @@ -583,17 +578,6 @@ int register_android_media_AudioRecord(JNIEnv *env) return -1; return -1; } } // Get the recording source constants from the AudioRecord class if ( !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, kClassPathName, JAVA_CONST_SOURCEDEFAULT_NAME, &(javaAudioRecordFields.SOURCE_DEFAULT)) || !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, kClassPathName, JAVA_CONST_SOURCEMIC_NAME, &(javaAudioRecordFields.SOURCE_MIC)) ) { // error log performed in getIntConstantFromClass() return -1; } return AndroidRuntime::registerNativeMethods(env, return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); kClassPathName, gMethods, NELEM(gMethods)); } } Loading
include/media/AudioRecord.h +13 −6 Original line number Original line Diff line number Diff line Loading @@ -39,10 +39,15 @@ class AudioRecord { { public: public: enum stream_type { // input sources values must always be defined in the range // [AudioRecord::DEFAULT_INPUT, AudioRecord::NUM_INPUT_SOURCES[ enum input_source { DEFAULT_INPUT =-1, DEFAULT_INPUT =-1, MIC_INPUT = 0, MIC_INPUT = 0, NUM_STREAM_TYPES VOICE_UPLINK_INPUT = 1, VOICE_DOWNLINK_INPUT = 2, VOICE_CALL_INPUT = 3, NUM_INPUT_SOURCES }; }; static const int DEFAULT_SAMPLE_RATE = 8000; static const int DEFAULT_SAMPLE_RATE = 8000; Loading Loading @@ -118,7 +123,7 @@ public: * * * Parameters: * Parameters: * * * streamType: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT). * inputSource: Select the audio input to record to (e.g. AudioRecord::MIC_INPUT). * sampleRate: Track sampling rate in Hz. * sampleRate: Track sampling rate in Hz. * format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed * format: PCM sample format (e.g AudioSystem::PCM_16_BIT for signed * 16 bits per sample). * 16 bits per sample). Loading @@ -140,7 +145,7 @@ public: RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE }; }; AudioRecord(int streamType, AudioRecord(int inputSource, uint32_t sampleRate = 0, uint32_t sampleRate = 0, int format = 0, int format = 0, int channelCount = 0, int channelCount = 0, Loading @@ -165,7 +170,7 @@ public: * - NO_INIT: audio server or audio hardware not initialized * - NO_INIT: audio server or audio hardware not initialized * - PERMISSION_DENIED: recording is not allowed for the requesting process * - PERMISSION_DENIED: recording is not allowed for the requesting process * */ * */ status_t set(int streamType = 0, status_t set(int inputSource = 0, uint32_t sampleRate = 0, uint32_t sampleRate = 0, int format = 0, int format = 0, int channelCount = 0, int channelCount = 0, Loading Loading @@ -197,6 +202,7 @@ public: int channelCount() const; int channelCount() const; uint32_t frameCount() const; uint32_t frameCount() const; int frameSize() const; int frameSize() const; int inputSource() const; /* After it's created the track is not active. Call start() to /* After it's created the track is not active. Call start() to Loading Loading @@ -323,7 +329,8 @@ private: audio_track_cblk_t* mCblk; audio_track_cblk_t* mCblk; uint8_t mFormat; uint8_t mFormat; uint8_t mChannelCount; uint8_t mChannelCount; uint8_t mReserved[2]; uint8_t mInputSource; uint8_t mReserved; status_t mStatus; status_t mStatus; uint32_t mLatency; uint32_t mLatency; Loading
include/media/IAudioFlinger.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ public: virtual sp<IAudioRecord> openRecord( virtual sp<IAudioRecord> openRecord( pid_t pid, pid_t pid, int streamType, int inputSource, uint32_t sampleRate, uint32_t sampleRate, int format, int format, int channelCount, int channelCount, Loading
include/media/mediarecorder.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,10 @@ typedef void (*media_completion_f)(status_t status, void *cookie); enum audio_source { enum audio_source { AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4, AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_CALL }; }; enum video_source { enum video_source { Loading