Loading core/jni/android_media_AudioSystem.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -389,7 +389,8 @@ android_media_AudioSystem_dyn_policy_callback(int event, String8 regId, int val) static void android_media_AudioSystem_recording_callback(int event, int session, int source, const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig) const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle) { JNIEnv *env = AndroidRuntime::getJNIEnv(); if (env == NULL) { Loading @@ -401,12 +402,14 @@ android_media_AudioSystem_recording_callback(int event, int session, int source, } // create an array for 2*3 integers to store the record configurations (client + device) jintArray recParamArray = env->NewIntArray(6); // plus 1 integer for the patch handle const int REC_PARAM_SIZE = 7; jintArray recParamArray = env->NewIntArray(REC_PARAM_SIZE); if (recParamArray == NULL) { ALOGE("recording callback: Couldn't allocate int array for configuration data"); return; } jint recParamData[6]; jint recParamData[REC_PARAM_SIZE]; recParamData[0] = (jint) audioFormatFromNative(clientConfig->format); // FIXME this doesn't support index-based masks recParamData[1] = (jint) inChannelMaskFromNative(clientConfig->channel_mask); Loading @@ -415,7 +418,8 @@ android_media_AudioSystem_recording_callback(int event, int session, int source, // FIXME this doesn't support index-based masks recParamData[4] = (jint) inChannelMaskFromNative(deviceConfig->channel_mask); recParamData[5] = (jint) deviceConfig->sample_rate; env->SetIntArrayRegion(recParamArray, 0, 6, recParamData); recParamData[6] = (jint) patchHandle; env->SetIntArrayRegion(recParamArray, 0, REC_PARAM_SIZE, recParamData); // callback into java jclass clazz = env->FindClass(kClassPathName); Loading media/java/android/media/AudioFormat.java +20 −0 Original line number Diff line number Diff line Loading @@ -897,6 +897,26 @@ public class AudioFormat implements Parcelable { } } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AudioFormat that = (AudioFormat) o; if (mPropertySetMask != that.mPropertySetMask) return false; // return false if any of the properties is set and the values differ return !((((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_ENCODING) != 0) && (mEncoding != that.mEncoding)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_SAMPLE_RATE) != 0) && (mSampleRate != that.mSampleRate)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK) != 0) && (mChannelMask != that.mChannelMask)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK) != 0) && (mChannelIndexMask != that.mChannelIndexMask))); } @Override public int hashCode() { return Objects.hash(mPropertySetMask, mSampleRate, mEncoding, mChannelMask, Loading media/java/android/media/AudioPatch.java +7 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,13 @@ public class AudioPatch { return mSinks; } /** * Get the system unique patch ID. */ public int id() { return mHandle.id(); } @Override public String toString() { StringBuilder s = new StringBuilder(); Loading media/java/android/media/AudioRecordConfiguration.java +46 −24 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package android.media; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import java.util.ArrayList; import java.util.Objects; /** Loading @@ -28,6 +30,7 @@ import java.util.Objects; * */ public class AudioRecordConfiguration implements Parcelable { private final static String TAG = new String("AudioRecordConfiguration"); private final int mSessionId; Loading @@ -36,30 +39,18 @@ public class AudioRecordConfiguration implements Parcelable { private final AudioFormat mDeviceFormat; private final AudioFormat mClientFormat; private final AudioDeviceInfo mRecDevice; /** * @hide */ public AudioRecordConfiguration(int session, int source, AudioFormat clientFormat, AudioFormat deviceFormat) { mSessionId = session; mClientSource = source; mDeviceFormat = deviceFormat; mClientFormat = clientFormat; mRecDevice = null; } private final int mPatchHandle; /** * @hide */ public AudioRecordConfiguration(int session, int source, AudioFormat devFormat, AudioFormat clientFormat, AudioDeviceInfo device) { AudioFormat clientFormat, int patchHandle) { mSessionId = session; mClientSource = source; mDeviceFormat = devFormat; mClientFormat = clientFormat; mRecDevice = device; mPatchHandle = patchHandle; } /** Loading Loading @@ -96,10 +87,38 @@ public class AudioRecordConfiguration implements Parcelable { public AudioFormat getClientFormat() { return mClientFormat; } /** * Returns the audio input device used for this recording. * @return the audio recording device * Returns information about the audio input device used for this recording. * @return the audio recording device or null if this information cannot be retrieved */ public AudioDeviceInfo getAudioDevice() { return mRecDevice; } public AudioDeviceInfo getAudioDevice() { // build the AudioDeviceInfo from the patch handle ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>(); if (AudioManager.listAudioPatches(patches) != AudioManager.SUCCESS) { Log.e(TAG, "Error retrieving list of audio patches"); return null; } for (int i = 0 ; i < patches.size() ; i++) { final AudioPatch patch = patches.get(i); if (patch.id() == mPatchHandle) { final AudioPortConfig[] sources = patch.sources(); if ((sources != null) && (sources.length > 0)) { // not supporting multiple sources, so just look at the first source final int devId = sources[0].port().id(); final AudioDeviceInfo[] devices = AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_INPUTS); for (int j = 0; j < devices.length; j++) { if (devices[j].getId() == devId) { return devices[j]; } } } // patch handle is unique, there won't be another with the same handle break; } } Log.e(TAG, "Couldn't find device for recording, did recording end already?"); return null; } public static final Parcelable.Creator<AudioRecordConfiguration> CREATOR = new Parcelable.Creator<AudioRecordConfiguration>() { Loading Loading @@ -132,7 +151,7 @@ public class AudioRecordConfiguration implements Parcelable { dest.writeInt(mClientSource); mClientFormat.writeToParcel(dest, 0); mDeviceFormat.writeToParcel(dest, 0); //TODO marshall device info dest.writeInt(mPatchHandle); } private AudioRecordConfiguration(Parcel in) { Loading @@ -140,8 +159,7 @@ public class AudioRecordConfiguration implements Parcelable { mClientSource = in.readInt(); mClientFormat = AudioFormat.CREATOR.createFromParcel(in); mDeviceFormat = AudioFormat.CREATOR.createFromParcel(in); //TODO unmarshall device info mRecDevice = null; mPatchHandle = in.readInt(); } @Override Loading @@ -149,8 +167,12 @@ public class AudioRecordConfiguration implements Parcelable { if (this == o) return true; if (o == null || !(o instanceof AudioRecordConfiguration)) return false; final AudioRecordConfiguration that = (AudioRecordConfiguration) o; AudioRecordConfiguration that = (AudioRecordConfiguration) o; return ((mSessionId == that.mSessionId) && (mClientSource == that.mClientSource)); && (mClientSource == that.mClientSource) && (mPatchHandle == that.mPatchHandle) && (mClientFormat.equals(that.mClientFormat)) && (mDeviceFormat.equals(that.mDeviceFormat))); } } No newline at end of file media/java/android/media/AudioSystem.java +8 −2 Original line number Diff line number Diff line Loading @@ -279,8 +279,14 @@ public class AudioSystem * @param session * @param source * @param recordingFormat an array of ints containing respectively the client and device * recording configuration. Each set of parameters contains the following parameters * in this order: format, channel mask, sample rate * recording configurations (2*3 ints), followed by the patch handle: * index 0: client format * 1: client channel mask * 2: client sample rate * 3: device format * 4: device channel mask * 5: device sample rate * 6: patch handle */ void onRecordingConfigurationChanged(int event, int session, int source, int[] recordingFormat); Loading Loading
core/jni/android_media_AudioSystem.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -389,7 +389,8 @@ android_media_AudioSystem_dyn_policy_callback(int event, String8 regId, int val) static void android_media_AudioSystem_recording_callback(int event, int session, int source, const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig) const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig, audio_patch_handle_t patchHandle) { JNIEnv *env = AndroidRuntime::getJNIEnv(); if (env == NULL) { Loading @@ -401,12 +402,14 @@ android_media_AudioSystem_recording_callback(int event, int session, int source, } // create an array for 2*3 integers to store the record configurations (client + device) jintArray recParamArray = env->NewIntArray(6); // plus 1 integer for the patch handle const int REC_PARAM_SIZE = 7; jintArray recParamArray = env->NewIntArray(REC_PARAM_SIZE); if (recParamArray == NULL) { ALOGE("recording callback: Couldn't allocate int array for configuration data"); return; } jint recParamData[6]; jint recParamData[REC_PARAM_SIZE]; recParamData[0] = (jint) audioFormatFromNative(clientConfig->format); // FIXME this doesn't support index-based masks recParamData[1] = (jint) inChannelMaskFromNative(clientConfig->channel_mask); Loading @@ -415,7 +418,8 @@ android_media_AudioSystem_recording_callback(int event, int session, int source, // FIXME this doesn't support index-based masks recParamData[4] = (jint) inChannelMaskFromNative(deviceConfig->channel_mask); recParamData[5] = (jint) deviceConfig->sample_rate; env->SetIntArrayRegion(recParamArray, 0, 6, recParamData); recParamData[6] = (jint) patchHandle; env->SetIntArrayRegion(recParamArray, 0, REC_PARAM_SIZE, recParamData); // callback into java jclass clazz = env->FindClass(kClassPathName); Loading
media/java/android/media/AudioFormat.java +20 −0 Original line number Diff line number Diff line Loading @@ -897,6 +897,26 @@ public class AudioFormat implements Parcelable { } } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AudioFormat that = (AudioFormat) o; if (mPropertySetMask != that.mPropertySetMask) return false; // return false if any of the properties is set and the values differ return !((((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_ENCODING) != 0) && (mEncoding != that.mEncoding)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_SAMPLE_RATE) != 0) && (mSampleRate != that.mSampleRate)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_MASK) != 0) && (mChannelMask != that.mChannelMask)) || (((mPropertySetMask & AUDIO_FORMAT_HAS_PROPERTY_CHANNEL_INDEX_MASK) != 0) && (mChannelIndexMask != that.mChannelIndexMask))); } @Override public int hashCode() { return Objects.hash(mPropertySetMask, mSampleRate, mEncoding, mChannelMask, Loading
media/java/android/media/AudioPatch.java +7 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,13 @@ public class AudioPatch { return mSinks; } /** * Get the system unique patch ID. */ public int id() { return mHandle.id(); } @Override public String toString() { StringBuilder s = new StringBuilder(); Loading
media/java/android/media/AudioRecordConfiguration.java +46 −24 Original line number Diff line number Diff line Loading @@ -18,7 +18,9 @@ package android.media; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import java.util.ArrayList; import java.util.Objects; /** Loading @@ -28,6 +30,7 @@ import java.util.Objects; * */ public class AudioRecordConfiguration implements Parcelable { private final static String TAG = new String("AudioRecordConfiguration"); private final int mSessionId; Loading @@ -36,30 +39,18 @@ public class AudioRecordConfiguration implements Parcelable { private final AudioFormat mDeviceFormat; private final AudioFormat mClientFormat; private final AudioDeviceInfo mRecDevice; /** * @hide */ public AudioRecordConfiguration(int session, int source, AudioFormat clientFormat, AudioFormat deviceFormat) { mSessionId = session; mClientSource = source; mDeviceFormat = deviceFormat; mClientFormat = clientFormat; mRecDevice = null; } private final int mPatchHandle; /** * @hide */ public AudioRecordConfiguration(int session, int source, AudioFormat devFormat, AudioFormat clientFormat, AudioDeviceInfo device) { AudioFormat clientFormat, int patchHandle) { mSessionId = session; mClientSource = source; mDeviceFormat = devFormat; mClientFormat = clientFormat; mRecDevice = device; mPatchHandle = patchHandle; } /** Loading Loading @@ -96,10 +87,38 @@ public class AudioRecordConfiguration implements Parcelable { public AudioFormat getClientFormat() { return mClientFormat; } /** * Returns the audio input device used for this recording. * @return the audio recording device * Returns information about the audio input device used for this recording. * @return the audio recording device or null if this information cannot be retrieved */ public AudioDeviceInfo getAudioDevice() { return mRecDevice; } public AudioDeviceInfo getAudioDevice() { // build the AudioDeviceInfo from the patch handle ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>(); if (AudioManager.listAudioPatches(patches) != AudioManager.SUCCESS) { Log.e(TAG, "Error retrieving list of audio patches"); return null; } for (int i = 0 ; i < patches.size() ; i++) { final AudioPatch patch = patches.get(i); if (patch.id() == mPatchHandle) { final AudioPortConfig[] sources = patch.sources(); if ((sources != null) && (sources.length > 0)) { // not supporting multiple sources, so just look at the first source final int devId = sources[0].port().id(); final AudioDeviceInfo[] devices = AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_INPUTS); for (int j = 0; j < devices.length; j++) { if (devices[j].getId() == devId) { return devices[j]; } } } // patch handle is unique, there won't be another with the same handle break; } } Log.e(TAG, "Couldn't find device for recording, did recording end already?"); return null; } public static final Parcelable.Creator<AudioRecordConfiguration> CREATOR = new Parcelable.Creator<AudioRecordConfiguration>() { Loading Loading @@ -132,7 +151,7 @@ public class AudioRecordConfiguration implements Parcelable { dest.writeInt(mClientSource); mClientFormat.writeToParcel(dest, 0); mDeviceFormat.writeToParcel(dest, 0); //TODO marshall device info dest.writeInt(mPatchHandle); } private AudioRecordConfiguration(Parcel in) { Loading @@ -140,8 +159,7 @@ public class AudioRecordConfiguration implements Parcelable { mClientSource = in.readInt(); mClientFormat = AudioFormat.CREATOR.createFromParcel(in); mDeviceFormat = AudioFormat.CREATOR.createFromParcel(in); //TODO unmarshall device info mRecDevice = null; mPatchHandle = in.readInt(); } @Override Loading @@ -149,8 +167,12 @@ public class AudioRecordConfiguration implements Parcelable { if (this == o) return true; if (o == null || !(o instanceof AudioRecordConfiguration)) return false; final AudioRecordConfiguration that = (AudioRecordConfiguration) o; AudioRecordConfiguration that = (AudioRecordConfiguration) o; return ((mSessionId == that.mSessionId) && (mClientSource == that.mClientSource)); && (mClientSource == that.mClientSource) && (mPatchHandle == that.mPatchHandle) && (mClientFormat.equals(that.mClientFormat)) && (mDeviceFormat.equals(that.mDeviceFormat))); } } No newline at end of file
media/java/android/media/AudioSystem.java +8 −2 Original line number Diff line number Diff line Loading @@ -279,8 +279,14 @@ public class AudioSystem * @param session * @param source * @param recordingFormat an array of ints containing respectively the client and device * recording configuration. Each set of parameters contains the following parameters * in this order: format, channel mask, sample rate * recording configurations (2*3 ints), followed by the patch handle: * index 0: client format * 1: client channel mask * 2: client sample rate * 3: device format * 4: device channel mask * 5: device sample rate * 6: patch handle */ void onRecordingConfigurationChanged(int event, int session, int source, int[] recordingFormat); Loading