Merge "API changes for audio recording notifications" into nyc-dev am: b74926232e
am: 6bc51e0e5c
* commit '6bc51e0e5cb318bc9c1c92a1f70a434614a741fc':
API changes for audio recording notifications
This commit is contained in:
@@ -19870,7 +19870,7 @@ package android.media {
|
||||
|
||||
public static abstract class AudioManager.AudioRecordingCallback {
|
||||
ctor public AudioManager.AudioRecordingCallback();
|
||||
method public void onRecordConfigChanged();
|
||||
method public void onRecordConfigChanged(android.media.AudioRecordConfiguration[]);
|
||||
}
|
||||
|
||||
public static abstract interface AudioManager.OnAudioFocusChangeListener {
|
||||
|
||||
@@ -21359,7 +21359,7 @@ package android.media {
|
||||
|
||||
public static abstract class AudioManager.AudioRecordingCallback {
|
||||
ctor public AudioManager.AudioRecordingCallback();
|
||||
method public void onRecordConfigChanged();
|
||||
method public void onRecordConfigChanged(android.media.AudioRecordConfiguration[]);
|
||||
}
|
||||
|
||||
public static abstract interface AudioManager.OnAudioFocusChangeListener {
|
||||
|
||||
@@ -19881,7 +19881,7 @@ package android.media {
|
||||
|
||||
public static abstract class AudioManager.AudioRecordingCallback {
|
||||
ctor public AudioManager.AudioRecordingCallback();
|
||||
method public void onRecordConfigChanged();
|
||||
method public void onRecordConfigChanged(android.media.AudioRecordConfiguration[]);
|
||||
}
|
||||
|
||||
public static abstract interface AudioManager.OnAudioFocusChangeListener {
|
||||
|
||||
@@ -2147,9 +2147,10 @@ public class AudioManager {
|
||||
}
|
||||
break;
|
||||
case MSSG_RECORDING_CONFIG_CHANGE:
|
||||
final AudioRecordingCallback cb = (AudioRecordingCallback) msg.obj;
|
||||
if (cb != null) {
|
||||
cb.onRecordConfigChanged();
|
||||
final RecordConfigChangeCallbackData cbData =
|
||||
(RecordConfigChangeCallbackData) msg.obj;
|
||||
if (cbData.mCb != null) {
|
||||
cbData.mCb.onRecordConfigChanged(cbData.mConfigs);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -2734,8 +2735,10 @@ public class AudioManager {
|
||||
public static abstract class AudioRecordingCallback {
|
||||
/**
|
||||
* Called whenever the device recording configuration has changed.
|
||||
* @param configs array containing the results of
|
||||
* {@link AudioManager#getActiveRecordConfigurations()}.
|
||||
*/
|
||||
public void onRecordConfigChanged() {}
|
||||
public void onRecordConfigChanged(AudioRecordConfiguration[] configs) {}
|
||||
}
|
||||
|
||||
private static class AudioRecordingCallbackInfo {
|
||||
@@ -2747,6 +2750,17 @@ public class AudioManager {
|
||||
}
|
||||
}
|
||||
|
||||
private final static class RecordConfigChangeCallbackData {
|
||||
final AudioRecordingCallback mCb;
|
||||
final AudioRecordConfiguration[] mConfigs;
|
||||
|
||||
RecordConfigChangeCallbackData(AudioRecordingCallback cb,
|
||||
AudioRecordConfiguration[] configs) {
|
||||
mCb = cb;
|
||||
mConfigs = configs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be notified of audio recording changes through
|
||||
* {@link AudioRecordingCallback}
|
||||
@@ -2882,14 +2896,15 @@ public class AudioManager {
|
||||
|
||||
private final IRecordingConfigDispatcher mRecCb = new IRecordingConfigDispatcher.Stub() {
|
||||
|
||||
public void dispatchRecordingConfigChange() {
|
||||
public void dispatchRecordingConfigChange(AudioRecordConfiguration[] configs) {
|
||||
synchronized(mRecordCallbackLock) {
|
||||
if (mRecordCallbackList != null) {
|
||||
for (int i=0 ; i < mRecordCallbackList.size() ; i++) {
|
||||
final AudioRecordingCallbackInfo arci = mRecordCallbackList.get(i);
|
||||
if (arci.mHandler != null) {
|
||||
final Message m = arci.mHandler.obtainMessage(
|
||||
MSSG_RECORDING_CONFIG_CHANGE/*what*/, arci.mCb/*obj*/);
|
||||
MSSG_RECORDING_CONFIG_CHANGE/*what*/,
|
||||
new RecordConfigChangeCallbackData(arci.mCb, configs)/*obj*/);
|
||||
arci.mHandler.sendMessage(m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package android.media;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -53,6 +56,19 @@ public final class AudioRecordConfiguration implements Parcelable {
|
||||
mPatchHandle = patchHandle;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@IntDef({
|
||||
MediaRecorder.AudioSource.DEFAULT,
|
||||
MediaRecorder.AudioSource.VOICE_UPLINK,
|
||||
MediaRecorder.AudioSource.VOICE_DOWNLINK,
|
||||
MediaRecorder.AudioSource.VOICE_CALL,
|
||||
MediaRecorder.AudioSource.CAMCORDER,
|
||||
MediaRecorder.AudioSource.VOICE_RECOGNITION,
|
||||
MediaRecorder.AudioSource.VOICE_COMMUNICATION
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AudioSource {}
|
||||
|
||||
/**
|
||||
* Returns the audio source being used for the recording.
|
||||
* @return one of {@link MediaRecorder.AudioSource#MIC},
|
||||
@@ -63,7 +79,7 @@ public final class AudioRecordConfiguration implements Parcelable {
|
||||
* {@link MediaRecorder.AudioSource#VOICE_RECOGNITION},
|
||||
* {@link MediaRecorder.AudioSource#VOICE_COMMUNICATION}.
|
||||
*/
|
||||
public int getClientAudioSource() { return mClientSource; }
|
||||
public @AudioSource int getClientAudioSource() { return mClientSource; }
|
||||
|
||||
/**
|
||||
* Returns the session number of the recording, see {@link AudioRecord#getAudioSessionId()}.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.media;
|
||||
|
||||
import android.media.AudioRecordConfiguration;
|
||||
|
||||
/**
|
||||
* AIDL for the RecordingActivity monitor in AudioService to signal audio recording updates.
|
||||
*
|
||||
@@ -23,6 +25,6 @@ package android.media;
|
||||
*/
|
||||
oneway interface IRecordingConfigDispatcher {
|
||||
|
||||
void dispatchRecordingConfigChange();
|
||||
void dispatchRecordingConfigChange(in AudioRecordConfiguration[] configs);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,12 +54,15 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin
|
||||
if (MediaRecorder.isSystemOnlyAudioSource(source)) {
|
||||
return;
|
||||
}
|
||||
if (updateSnapshot(event, session, source, recordingInfo)) {
|
||||
final Iterator<RecMonitorClient> clientIterator = mClients.iterator();
|
||||
final AudioRecordConfiguration[] configs =
|
||||
updateSnapshot(event, session, source, recordingInfo);
|
||||
if (configs != null){
|
||||
synchronized(mClients) {
|
||||
final Iterator<RecMonitorClient> clientIterator = mClients.iterator();
|
||||
while (clientIterator.hasNext()) {
|
||||
try {
|
||||
clientIterator.next().mDispatcherCb.dispatchRecordingConfigChange();
|
||||
clientIterator.next().mDispatcherCb.dispatchRecordingConfigChange(
|
||||
configs);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Could not call dispatchRecordingConfigChange() on client", e);
|
||||
}
|
||||
@@ -115,14 +118,19 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin
|
||||
* @param recordingFormat see
|
||||
* {@link AudioSystem.AudioRecordingCallback#onRecordingConfigurationChanged(int, int, int, int[])}
|
||||
* for the definition of the contents of the array
|
||||
* @return true if the list of active recording sessions has been modified, false otherwise.
|
||||
* @return null if the list of active recording sessions has not been modified, an array
|
||||
* with the current active configurations otherwise.
|
||||
*/
|
||||
private boolean updateSnapshot(int event, int session, int source, int[] recordingInfo) {
|
||||
private AudioRecordConfiguration[] updateSnapshot(int event, int session, int source,
|
||||
int[] recordingInfo) {
|
||||
final boolean configChanged;
|
||||
final AudioRecordConfiguration[] configs;
|
||||
synchronized(mRecordConfigs) {
|
||||
switch (event) {
|
||||
case AudioManager.RECORD_CONFIG_EVENT_STOP:
|
||||
// return failure if an unknown recording session stopped
|
||||
return (mRecordConfigs.remove(new Integer(session)) != null);
|
||||
configChanged = (mRecordConfigs.remove(new Integer(session)) != null);
|
||||
break;
|
||||
case AudioManager.RECORD_CONFIG_EVENT_START:
|
||||
final AudioFormat clientFormat = new AudioFormat.Builder()
|
||||
.setEncoding(recordingInfo[0])
|
||||
@@ -143,25 +151,32 @@ public final class RecordingActivityMonitor implements AudioSystem.AudioRecordin
|
||||
new AudioRecordConfiguration(session, source,
|
||||
clientFormat, deviceFormat, patchHandle);
|
||||
if (updatedConfig.equals(mRecordConfigs.get(sessionKey))) {
|
||||
return false;
|
||||
configChanged = false;
|
||||
} else {
|
||||
// config exists but has been modified
|
||||
mRecordConfigs.remove(sessionKey);
|
||||
mRecordConfigs.put(sessionKey, updatedConfig);
|
||||
return true;
|
||||
configChanged = true;
|
||||
}
|
||||
} else {
|
||||
mRecordConfigs.put(sessionKey,
|
||||
new AudioRecordConfiguration(session, source,
|
||||
clientFormat, deviceFormat, patchHandle));
|
||||
return true;
|
||||
configChanged = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, String.format("Unknown event %d for session %d, source %d",
|
||||
event, session, source));
|
||||
return false;
|
||||
configChanged = false;
|
||||
}
|
||||
if (configChanged) {
|
||||
configs = mRecordConfigs.values().toArray(new AudioRecordConfiguration[0]);
|
||||
} else {
|
||||
configs = null;
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user