am 660c8a11: Merge "Add support for controlling remote submix audio routing" into jb-mr1-dev

* commit '660c8a115bdc92bed4bc8380407f2ac3333c42e1':
  Add support for controlling remote submix audio routing
This commit is contained in:
Jean-Michel Trivi
2012-09-11 10:38:55 -07:00
committed by Android Git Automerger
5 changed files with 65 additions and 3 deletions

View File

@@ -1164,7 +1164,7 @@ public class AudioManager {
/** /**
* Indicates if current platform supports use of SCO for off call use cases. * Indicates if current platform supports use of SCO for off call use cases.
* Application wanted to use bluetooth SCO audio when the phone is not in call * Application wanted to use bluetooth SCO audio when the phone is not in call
* must first call thsi method to make sure that the platform supports this * must first call this method to make sure that the platform supports this
* feature. * feature.
* @return true if bluetooth SCO can be used for audio when not in call * @return true if bluetooth SCO can be used for audio when not in call
* false otherwise * false otherwise
@@ -1299,6 +1299,19 @@ public class AudioManager {
} }
} }
/**
* @hide
* Signals whether remote submix audio rerouting is enabled.
*/
public void setRemoteSubmixOn(boolean on, int address) {
IAudioService service = getService();
try {
service.setRemoteSubmixOn(on, address);
} catch (RemoteException e) {
Log.e(TAG, "Dead object in setRemoteSubmixOn", e);
}
}
/** /**
* Sets audio routing to the wired headset on or off. * Sets audio routing to the wired headset on or off.
* *

View File

@@ -151,6 +151,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
private static final int MSG_SET_WIRED_DEVICE_CONNECTION_STATE = 21; private static final int MSG_SET_WIRED_DEVICE_CONNECTION_STATE = 21;
private static final int MSG_SET_A2DP_CONNECTION_STATE = 22; private static final int MSG_SET_A2DP_CONNECTION_STATE = 22;
// end of messages handled under wakelock // end of messages handled under wakelock
private static final int MSG_SET_RSX_CONNECTION_STATE = 23; // change remote submix connection
private static final int MSG_SET_FORCE_RSX_USE = 24; // force remote submix audio routing
// flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
// persisted // persisted
@@ -2109,6 +2111,33 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
} }
}; };
/** see AudioManager.setRemoteSubmixOn(boolean on) */
public void setRemoteSubmixOn(boolean on, int address) {
sendMsg(mAudioHandler, MSG_SET_RSX_CONNECTION_STATE,
SENDMSG_REPLACE /* replace with QUEUE when multiple addresses are supported */,
on ? 1 : 0 /*arg1*/,
address /*arg2*/,
null/*obj*/, 0/*delay*/);
// Note that we are currently forcing use of remote submix as soon as corresponding device
// is made available
sendMsg(mAudioHandler, MSG_SET_FORCE_RSX_USE, SENDMSG_REPLACE,
AudioSystem.FOR_MEDIA,
on ? AudioSystem.FORCE_REMOTE_SUBMIX : AudioSystem.FORCE_NONE,
null/*obj*/, 0/*delay*/);
}
private void onSetRsxConnectionState(int available, int address) {
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_REMOTE_SUBMIX,
available == 1 ?
AudioSystem.DEVICE_STATE_AVAILABLE : AudioSystem.DEVICE_STATE_UNAVAILABLE,
String.valueOf(address) /*device_address*/);
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX,
available == 1 ?
AudioSystem.DEVICE_STATE_AVAILABLE : AudioSystem.DEVICE_STATE_UNAVAILABLE,
String.valueOf(address) /*device_address*/);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Internal methods // Internal methods
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -3072,6 +3101,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
case MSG_SET_FORCE_USE: case MSG_SET_FORCE_USE:
case MSG_SET_FORCE_BT_A2DP_USE: case MSG_SET_FORCE_BT_A2DP_USE:
case MSG_SET_FORCE_RSX_USE:
setForceUse(msg.arg1, msg.arg2); setForceUse(msg.arg1, msg.arg2);
break; break;
@@ -3134,6 +3164,10 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
onRegisterVolumeObserverForRcc(msg.arg1 /* rccId */, onRegisterVolumeObserverForRcc(msg.arg1 /* rccId */,
(IRemoteVolumeObserver)msg.obj /* rvo */); (IRemoteVolumeObserver)msg.obj /* rvo */);
break; break;
case MSG_SET_RSX_CONNECTION_STATE:
onSetRsxConnectionState(msg.arg1/*available*/, msg.arg2/*address*/);
break;
} }
} }
} }

View File

@@ -214,6 +214,7 @@ public class AudioSystem
public static final int DEVICE_OUT_REMOTE_SUBMIX = 0x8000; public static final int DEVICE_OUT_REMOTE_SUBMIX = 0x8000;
public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT; public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
public static final int DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | public static final int DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE |
DEVICE_OUT_SPEAKER | DEVICE_OUT_SPEAKER |
DEVICE_OUT_WIRED_HEADSET | DEVICE_OUT_WIRED_HEADSET |
@@ -352,7 +353,8 @@ public class AudioSystem
public static final int FORCE_ANALOG_DOCK = 8; public static final int FORCE_ANALOG_DOCK = 8;
public static final int FORCE_DIGITAL_DOCK = 9; public static final int FORCE_DIGITAL_DOCK = 9;
public static final int FORCE_NO_BT_A2DP = 10; public static final int FORCE_NO_BT_A2DP = 10;
private static final int NUM_FORCE_CONFIG = 11; public static final int FORCE_REMOTE_SUBMIX = 11;
private static final int NUM_FORCE_CONFIG = 12;
public static final int FORCE_DEFAULT = FORCE_NONE; public static final int FORCE_DEFAULT = FORCE_NONE;
// usage for setForceUse, must match AudioSystem::force_use // usage for setForceUse, must match AudioSystem::force_use

View File

@@ -108,6 +108,8 @@ interface IAudioService {
boolean isBluetoothA2dpOn(); boolean isBluetoothA2dpOn();
oneway void setRemoteSubmixOn(boolean on, int address);
int requestAudioFocus(int mainStreamType, int durationHint, IBinder cb, IAudioFocusDispatcher l, int requestAudioFocus(int mainStreamType, int durationHint, IBinder cb, IAudioFocusDispatcher l,
String clientId, String callingPackageName); String clientId, String callingPackageName);

View File

@@ -177,6 +177,12 @@ public class MediaRecorder
* is applied. * is applied.
*/ */
public static final int VOICE_COMMUNICATION = 7; public static final int VOICE_COMMUNICATION = 7;
/**
* @hide
* Audio source for remote submix.
*/
public static final int REMOTE_SUBMIX_SOURCE = 8;
} }
/** /**
@@ -291,7 +297,12 @@ public class MediaRecorder
* Gets the maximum value for audio sources. * Gets the maximum value for audio sources.
* @see android.media.MediaRecorder.AudioSource * @see android.media.MediaRecorder.AudioSource
*/ */
public static final int getAudioSourceMax() { return AudioSource.VOICE_COMMUNICATION; } public static final int getAudioSourceMax() {
// FIXME disable selection of the remote submxi source selection once test code
// doesn't rely on it
return AudioSource.REMOTE_SUBMIX_SOURCE;
//return AudioSource.VOICE_COMMUNICATION;
}
/** /**
* Sets the video source to be used for recording. If this method is not * Sets the video source to be used for recording. If this method is not