diff options
author | Paul McLean <pmclean@google.com> | 2015-02-20 07:52:45 -0800 |
---|---|---|
committer | Paul McLean <pmclean@google.com> | 2015-04-15 10:56:49 -0600 |
commit | a33be211e768746745a0deeba71f8c6b65e72442 (patch) | |
tree | ad2370b46ba65bdda976579d4ab8da21bfde96f1 /media | |
parent | 575217fc3da38357f1d5e322bf1c7a07b909ef2a (diff) | |
download | frameworks_base-a33be211e768746745a0deeba71f8c6b65e72442.zip frameworks_base-a33be211e768746745a0deeba71f8c6b65e72442.tar.gz frameworks_base-a33be211e768746745a0deeba71f8c6b65e72442.tar.bz2 |
Audio Devices Enumeration/Notification API
Change-Id: I4eecfa43e4fecfe309ddd805ed193d078b10d5e6
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioDeviceInfo.java (renamed from media/java/android/media/AudioDevice.java) | 97 | ||||
-rw-r--r-- | media/java/android/media/AudioDevicesManager.java | 348 | ||||
-rw-r--r-- | media/java/android/media/OnAudioDeviceConnectionListener.java | 17 | ||||
-rw-r--r-- | media/java/android/media/audiofx/Virtualizer.java | 46 |
4 files changed, 274 insertions, 234 deletions
diff --git a/media/java/android/media/AudioDevice.java b/media/java/android/media/AudioDeviceInfo.java index df4d60d..d58b1d1 100644 --- a/media/java/android/media/AudioDevice.java +++ b/media/java/android/media/AudioDeviceInfo.java @@ -20,9 +20,8 @@ import android.util.SparseIntArray; /** * Class to provide information about the audio devices. - * @hide */ -public class AudioDevice { +public class AudioDeviceInfo { /** * A device type associated with an unknown or uninitialized device. @@ -42,7 +41,7 @@ public class AudioDevice { */ public static final int TYPE_WIRED_HEADSET = 3; /** - * A device type describing a pair of wired headphones . + * A device type describing a pair of wired headphones. */ public static final int TYPE_WIRED_HEADPHONES = 4; /** @@ -54,7 +53,7 @@ public class AudioDevice { */ public static final int TYPE_LINE_DIGITAL = 6; /** - * A device type describing a Bluetooth device typically used for telephony . + * A device type describing a Bluetooth device typically used for telephony. */ public static final int TYPE_BLUETOOTH_SCO = 7; /** @@ -106,46 +105,92 @@ public class AudioDevice { */ public static final int TYPE_AUX_LINE = 19; - AudioDevicePortConfig mConfig; + private final AudioDevicePort mPort; - AudioDevice(AudioDevicePortConfig config) { - mConfig = new AudioDevicePortConfig(config); + AudioDeviceInfo(AudioDevicePort port) { + mPort = port; } /** * @hide - * CANDIDATE FOR PUBLIC API - * @return + * @return The internal device ID. */ - public boolean isInputDevice() { - return (mConfig.port().role() == AudioPort.ROLE_SOURCE); + public int getId() { + return mPort.handle().id(); } /** - * @hide - * CANDIDATE FOR PUBLIC API - * @return + * @return The human-readable name of the audio device. */ - public boolean isOutputDevice() { - return (mConfig.port().role() == AudioPort.ROLE_SINK); + public String getName() { + return mPort.name(); } /** - * @hide - * CANDIDATE FOR PUBLIC API - * @return + * @return The "address" string of the device. This generally contains device-specific + * parameters. */ - public int getDeviceType() { - return INT_TO_EXT_DEVICE_MAPPING.get(mConfig.port().type(), TYPE_UNKNOWN); + // TODO Is there a compelling reason to expose this? + public String getAddress() { + return mPort.address(); + } + + /** + * @return true if the audio device is a source for audio data (e.e an input). + */ + public boolean isSource() { + return mPort.role() == AudioPort.ROLE_SOURCE; } /** - * @hide - * CANDIDATE FOR PUBLIC API - * @return + * @return true if the audio device is a sink for audio data (i.e. an output). */ - public String getAddress() { - return mConfig.port().address(); + public boolean isSink() { + return mPort.role() == AudioPort.ROLE_SINK; + } + + /** + * @return An array of sample rates supported by the audio device. + */ + public int[] getSampleRates() { + return mPort.samplingRates(); + } + + /** + * @return An array of channel masks supported by the audio device (defined in + * AudioFormat.java). + */ + public int[] getChannelMasks() { + return mPort.channelMasks(); + } + + /** + * @return An array of channel counts supported by the audio device. + */ + public int[] getChannelCounts() { + int[] masks = getChannelMasks(); + int[] counts = new int[masks.length]; + for (int mask_index = 0; mask_index < masks.length; mask_index++) { + counts[mask_index] = isSink() + ? AudioFormat.channelCountFromOutChannelMask(masks[mask_index]) + : AudioFormat.channelCountFromInChannelMask(masks[mask_index]); + } + return counts; + } + + /** + * @return An array of audio format IDs supported by the audio device (defined in + * AudioFormat.java) + */ + public int[] getFormats() { + return mPort.formats(); + } + + /** + * @return The device type identifier of the audio device (i.e. TYPE_BUILTIN_SPEAKER). + */ + public int getType() { + return INT_TO_EXT_DEVICE_MAPPING.get(mPort.type(), TYPE_UNKNOWN); } /** @hide */ diff --git a/media/java/android/media/AudioDevicesManager.java b/media/java/android/media/AudioDevicesManager.java index ee11eef..ca238d7 100644 --- a/media/java/android/media/AudioDevicesManager.java +++ b/media/java/android/media/AudioDevicesManager.java @@ -17,24 +17,54 @@ package android.media; import android.content.Context; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.ArrayMap; +import android.util.Pair; import android.util.Slog; import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.HashMap; import java.util.Iterator; -/** @hide - * API candidate +/** + * AudioDevicesManager implements the Android Media Audio device enumeration and notification + * functionality. This functionality is in two comlementary parts. + * <ol> + * <li>{@link AudioDevicesManager#listDevices(int)} gets the list of current audio devices + * </li> + * <li>{@link AudioDevicesManager#addOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener, android.os.Handler)} + * provides a mechanism for applications to be informed of audio device connect/disconnect events. + * </li> + * </ol> */ public class AudioDevicesManager { + private static String TAG = "AudioDevicesManager"; - private static boolean DEBUG = true; + + private static boolean DEBUG = false; private AudioManager mAudioManager = null; + private OnAmPortUpdateListener mPortListener = null; - /* - * Enum/Selection API + /** + * The message sent to apps when the contents of the device list changes if they provide + * a {#link Handler} object to addOnAudioDeviceConnectionListener(). + */ + private final static int MSG_DEVICES_LIST_CHANGE = 0; + + private ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate> + mDeviceConnectionListeners = + new ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate>(); + + /** + * @hide + * The AudioDevicesManager class is used to enumerate the physical audio devices connected + * to the system. See also {@link AudioDeviceInfo}. */ public AudioDevicesManager(Context context) { mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); @@ -42,214 +72,120 @@ public class AudioDevicesManager { mAudioManager.registerAudioPortUpdateListener(mPortListener); } - /** @hide - * API candidate + /** + * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include + * source (i.e. input) audio devices. */ - //TODO Merge this class into android.media.AudioDevice - public class AudioDeviceInfo { - private AudioDevicePort mPort = null; - - /** @hide */ - /* package */ AudioDeviceInfo(AudioDevicePort port) { - mPort = port; - } - - public int getId() { return mPort.handle().id(); } - - public String getName() { return mPort.name(); } - - public int getType() { - return mPort.type(); - } - - public String getAddress() { - return mPort.address(); - } - - public int getRole() { return mPort.role(); } - - public int[] getSampleRates() { return mPort.samplingRates(); } - - public int[] getChannelMasks() { return mPort.channelMasks(); } - - public int[] getChannelCounts() { - int[] masks = getChannelMasks(); - int[] counts = new int[masks.length]; - for (int mask_index = 0; mask_index < masks.length; mask_index++) { - counts[mask_index] = getRole() == AudioPort.ROLE_SINK - ? AudioFormat.channelCountFromOutChannelMask(masks[mask_index]) - : AudioFormat.channelCountFromInChannelMask(masks[mask_index]); - } - return counts; - } - - /* The format IDs are in AudioFormat.java */ - public int[] getFormats() { return mPort.formats(); } + public static final int LIST_DEVICES_INPUTS = 0x0001; - public String toString() { return "" + getId() + " - " + getName(); } - } - - /** @hide */ - public static final int LIST_DEVICES_OUTPUTS = 0x0001; - /** @hide */ - public static final int LIST_DEVICES_INPUTS = 0x0002; - /** @hide */ - public static final int LIST_DEVICES_BUILTIN = 0x0004; - /** @hide */ - public static final int LIST_DEVICES_USB = 0x0008; - // TODO implement the semantics for these. - /** @hide */ - public static final int LIST_DEVICES_WIRED = 0x0010; - /** @hide */ - public static final int LIST_DEVICES_UNWIRED = 0x0020; + /** + * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include + * sink (i.e. output) audio devices. + */ + public static final int LIST_DEVICES_OUTPUTS = 0x0002; - /** @hide */ + /** + * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include both + * source and sink devices. + */ public static final int LIST_DEVICES_ALL = LIST_DEVICES_OUTPUTS | LIST_DEVICES_INPUTS; + /** + * Determines if a given AudioDevicePort meets the specified filter criteria. + * @param port The port to test. + * @param flags A set of bitflags specifying the criteria to test. + * @see {@link LIST_DEVICES_OUTPUTS} and {@link LIST_DEVICES_INPUTS} + **/ private boolean checkFlags(AudioDevicePort port, int flags) { - // Inputs / Outputs - boolean passed = - port.role() == AudioPort.ROLE_SINK && (flags & LIST_DEVICES_OUTPUTS) != 0 || - port.role() == AudioPort.ROLE_SOURCE && (flags & LIST_DEVICES_INPUTS) != 0; - - // USB - if (passed && (flags & LIST_DEVICES_USB) != 0) { - int role = port.role(); - int type = port.type(); - Slog.i(TAG, " role:" + role + " type:0x" + Integer.toHexString(type)); - passed = - (role == AudioPort.ROLE_SINK && (type & AudioSystem.DEVICE_OUT_ALL_USB) != 0) || - (role == AudioPort.ROLE_SOURCE && (type & AudioSystem.DEVICE_IN_ALL_USB) != 0); - } - - return passed; + return port.role() == AudioPort.ROLE_SINK && (flags & LIST_DEVICES_OUTPUTS) != 0 || + port.role() == AudioPort.ROLE_SOURCE && (flags & LIST_DEVICES_INPUTS) != 0; } - /** @hide */ - public ArrayList<AudioDeviceInfo> listDevices(int flags) { - Slog.i(TAG, "AudioManager.listDevices(" + Integer.toHexString(flags) + ")"); - + /** + * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently + * connected to the system and meeting the criteria specified in the <code>flags</code> + * parameter. + * @param flags A set of bitflags specifying the criteria to test. + * @see {@link LIST_DEVICES_OUTPUTS}, {@link LIST_DEVICES_INPUTS} and {@link LIST_DEVICES_ALL}. + * @return A (possibly zero-length) array of AudioDeviceInfo objects. + */ + public AudioDeviceInfo[] listDevices(int flags) { ArrayList<AudioDevicePort> ports = new ArrayList<AudioDevicePort>(); int status = mAudioManager.listAudioDevicePorts(ports); - - Slog.i(TAG, " status:" + status + " numPorts:" + ports.size()); - - ArrayList<AudioDeviceInfo> deviceList = new ArrayList<AudioDeviceInfo>(); - - if (status == AudioManager.SUCCESS) { - deviceList = new ArrayList<AudioDeviceInfo>(); - for (AudioDevicePort port : ports) { - if (checkFlags(port, flags)) { - deviceList.add(new AudioDeviceInfo(port)); - } - } + if (status != AudioManager.SUCCESS) { + // fail and bail! + return new AudioDeviceInfo[0]; } - return deviceList; - } - private ArrayList<OnAudioDeviceConnectionListener> mDeviceConnectionListeners = - new ArrayList<OnAudioDeviceConnectionListener>(); - - private HashMap<Integer, AudioPort> mCurrentPortlist = - new HashMap<Integer, AudioPort>(); - - private ArrayList<AudioDeviceInfo> calcAddedDevices(AudioPort[] portList) { - ArrayList<AudioDeviceInfo> addedDevices = new ArrayList<AudioDeviceInfo>(); - synchronized(mCurrentPortlist) { - for(int portIndex = 0; portIndex < portList.length; portIndex++) { - if (portList[portIndex] instanceof AudioDevicePort) { - if (!mCurrentPortlist.containsKey(portList[portIndex].handle().id())) { - addedDevices.add(new AudioDeviceInfo((AudioDevicePort)portList[portIndex])); - } - } + // figure out how many AudioDeviceInfo we need space for + int numRecs = 0; + for (AudioDevicePort port : ports) { + if (checkFlags(port, flags)) { + numRecs++; } } - return addedDevices; - } - private boolean hasPortId(AudioPort[] portList, int id) { - for(int portIndex = 0; portIndex < portList.length; portIndex++) { - if (portList[portIndex].handle().id() == id) { - return true; + // Now load them up + AudioDeviceInfo[] deviceList = new AudioDeviceInfo[numRecs]; + int slot = 0; + for (AudioDevicePort port : ports) { + if (checkFlags(port, flags)) { + deviceList[slot++] = new AudioDeviceInfo(port); } } - return false; - } - - private ArrayList<AudioDeviceInfo> calcRemovedDevices(AudioPort[] portList) { - ArrayList<AudioDeviceInfo> removedDevices = new ArrayList<AudioDeviceInfo>(); - synchronized (mCurrentPortlist) { - Iterator it = mCurrentPortlist.entrySet().iterator(); - while (it.hasNext()) { - HashMap.Entry pairs = (HashMap.Entry)it.next(); - if (pairs.getValue() instanceof AudioDevicePort) { - if (!hasPortId(portList, ((Integer)pairs.getKey()).intValue())) { - removedDevices.add(new AudioDeviceInfo((AudioDevicePort)pairs.getValue())); - } - } - } - } - return removedDevices; + return deviceList; } - private void buildCurrentDevicesList(AudioPort[] portList) { - synchronized (mCurrentPortlist) { - mCurrentPortlist.clear(); - for (int portIndex = 0; portIndex < portList.length; portIndex++) { - if (portList[portIndex] instanceof AudioDevicePort) { - mCurrentPortlist.put(portList[portIndex].handle().id(), - (AudioDevicePort)portList[portIndex]); - } + /** + * Adds an {@link OnAudioDeviceConnectionListener} to receive notifications of changes + * to the set of connected audio devices. + */ + public void addOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener, + android.os.Handler handler) { + if (listener != null && !mDeviceConnectionListeners.containsKey(listener)) { + synchronized (mDeviceConnectionListeners) { + mDeviceConnectionListeners.put( + listener, new NativeEventHandlerDelegate(listener, handler)); } } } - /** @hide */ - public void addDeviceConnectionListener(OnAudioDeviceConnectionListener listener) { + /** + * Removes an {@link OnAudioDeviceConnectionListener} which has been previously registered + * to receive notifications of changes to the set of connected audio devices. + */ + public void removeOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener) { synchronized (mDeviceConnectionListeners) { - mDeviceConnectionListeners.add(listener); + if (mDeviceConnectionListeners.containsKey(listener)) { + mDeviceConnectionListeners.remove(listener); + } } } - /** @hide */ - public void removeDeviceConnectionListener(OnAudioDeviceConnectionListener listener) { + /** + * Sends device list change notification to all listeners. + */ + private void broadcastDeviceListChange() { + Collection<NativeEventHandlerDelegate> values; synchronized (mDeviceConnectionListeners) { - mDeviceConnectionListeners.remove(listener); + values = mDeviceConnectionListeners.values(); + } + for(NativeEventHandlerDelegate delegate : values) { + Handler handler = delegate.getHandler(); + if (handler != null) { + handler.sendEmptyMessage(MSG_DEVICES_LIST_CHANGE); + } } } /** - * @hide + * Handles Port list update notifications from the AudioManager */ private class OnAmPortUpdateListener implements AudioManager.OnAudioPortUpdateListener { static final String TAG = "OnAmPortUpdateListener"; public void onAudioPortListUpdate(AudioPort[] portList) { - Slog.i(TAG, "onAudioPortListUpdate() " + portList.length + " ports."); - ArrayList<AudioDeviceInfo> addedDevices = calcAddedDevices(portList); - ArrayList<AudioDeviceInfo> removedDevices = calcRemovedDevices(portList); - - ArrayList<OnAudioDeviceConnectionListener> listeners = null; - synchronized (mDeviceConnectionListeners) { - listeners = - new ArrayList<OnAudioDeviceConnectionListener>(mDeviceConnectionListeners); - } - - // Connect - if (addedDevices.size() != 0) { - for (OnAudioDeviceConnectionListener listener : listeners) { - listener.onConnect(addedDevices); - } - } - - // Disconnect? - if (removedDevices.size() != 0) { - for (OnAudioDeviceConnectionListener listener : listeners) { - listener.onDisconnect(removedDevices); - } - } - - buildCurrentDevicesList(portList); + broadcastDeviceListChange(); } /** @@ -257,14 +193,70 @@ public class AudioDevicesManager { * @param patchList the updated list of audio patches */ public void onAudioPatchListUpdate(AudioPatch[] patchList) { - Slog.i(TAG, "onAudioPatchListUpdate() " + patchList.length + " patches."); + if (DEBUG) { + Slog.d(TAG, "onAudioPatchListUpdate() " + patchList.length + " patches."); + } } /** * Callback method called when the mediaserver dies */ public void onServiceDied() { - Slog.i(TAG, "onServiceDied()"); + if (DEBUG) { + Slog.i(TAG, "onServiceDied()"); + } + + broadcastDeviceListChange(); + } + } + + //--------------------------------------------------------- + // Inner classes + //-------------------- + /** + * Helper class to handle the forwarding of native events to the appropriate listener + * (potentially) handled in a different thread. + */ + private class NativeEventHandlerDelegate { + private final Handler mHandler; + + NativeEventHandlerDelegate(final OnAudioDeviceConnectionListener listener, + Handler handler) { + // find the looper for our new event handler + Looper looper; + if (handler != null) { + looper = handler.getLooper(); + } else { + // no given handler, use the looper the addListener call was called in + looper = Looper.getMainLooper(); + } + + // construct the event handler with this looper + if (looper != null) { + // implement the event handler delegate + mHandler = new Handler(looper) { + @Override + public void handleMessage(Message msg) { + switch(msg.what) { + case MSG_DEVICES_LIST_CHANGE: + // call the OnAudioDeviceConnectionListener + if (listener != null) { + listener.onAudioDeviceConnection(); + } + break; + default: + Slog.e(TAG, "Unknown native event type: " + msg.what); + break; + } + } + }; + } else { + mHandler = null; + } + } + + Handler getHandler() { + return mHandler; } } } diff --git a/media/java/android/media/OnAudioDeviceConnectionListener.java b/media/java/android/media/OnAudioDeviceConnectionListener.java index 4bdd4d0..71c135a 100644 --- a/media/java/android/media/OnAudioDeviceConnectionListener.java +++ b/media/java/android/media/OnAudioDeviceConnectionListener.java @@ -16,13 +16,16 @@ package android.media; -import java.util.ArrayList; - /** - * @hide - * API candidate + * OnAudioDeviceConnectionListener defines the interface for notification listeners in the + * {@link AudioDevicesManager} */ -public abstract class OnAudioDeviceConnectionListener { - public void onConnect(ArrayList<AudioDevicesManager.AudioDeviceInfo> devices) {} - public void onDisconnect(ArrayList<AudioDevicesManager.AudioDeviceInfo> devices) {} +public interface OnAudioDeviceConnectionListener { + /** + * Called by the {@link AudioDevicesManager} to indicate that an audio device has been + * connected or disconnected. A listener will probably call the + * {@link AudioDevicesManager#listDevices} method to retrieve the current list of audio + * devices. + */ + public void onAudioDeviceConnection(); } diff --git a/media/java/android/media/audiofx/Virtualizer.java b/media/java/android/media/audiofx/Virtualizer.java index be5adc8..49e56bc 100644 --- a/media/java/android/media/audiofx/Virtualizer.java +++ b/media/java/android/media/audiofx/Virtualizer.java @@ -17,7 +17,7 @@ package android.media.audiofx; import android.annotation.IntDef; -import android.media.AudioDevice; +import android.media.AudioDeviceInfo; import android.media.AudioFormat; import android.media.audiofx.AudioEffect; import android.util.Log; @@ -204,7 +204,7 @@ public class Virtualizer extends AudioEffect { // convert channel mask to internal native representation paramsConverter.putInt(AudioFormat.convertChannelOutMaskToNativeMask(channelMask)); // convert Java device type to internal representation - paramsConverter.putInt(AudioDevice.convertDeviceTypeToInternalDevice(deviceType)); + paramsConverter.putInt(AudioDeviceInfo.convertDeviceTypeToInternalDevice(deviceType)); // allocate an array to store the results byte[] result = new byte[nbChannels * 4/*int to byte*/ * 3/*for mask, azimuth, elevation*/]; @@ -305,9 +305,9 @@ public class Virtualizer extends AudioEffect { throws IllegalArgumentException { switch (virtualizationMode) { case VIRTUALIZATION_MODE_BINAURAL: - return AudioDevice.TYPE_WIRED_HEADPHONES; + return AudioDeviceInfo.TYPE_WIRED_HEADPHONES; case VIRTUALIZATION_MODE_TRANSAURAL: - return AudioDevice.TYPE_BUILTIN_SPEAKER; + return AudioDeviceInfo.TYPE_BUILTIN_SPEAKER; default: throw (new IllegalArgumentException( "Virtualizer: illegal virtualization mode " + virtualizationMode)); @@ -317,7 +317,7 @@ public class Virtualizer extends AudioEffect { private static int getDeviceForModeForce(@ForceVirtualizationMode int virtualizationMode) throws IllegalArgumentException { if (virtualizationMode == VIRTUALIZATION_MODE_AUTO) { - return AudioDevice.TYPE_UNKNOWN; + return AudioDeviceInfo.TYPE_UNKNOWN; } else { return getDeviceForModeQuery(virtualizationMode); } @@ -325,24 +325,24 @@ public class Virtualizer extends AudioEffect { private static int deviceToMode(int deviceType) { switch (deviceType) { - case AudioDevice.TYPE_WIRED_HEADSET: - case AudioDevice.TYPE_WIRED_HEADPHONES: - case AudioDevice.TYPE_BLUETOOTH_SCO: - case AudioDevice.TYPE_BUILTIN_EARPIECE: + case AudioDeviceInfo.TYPE_WIRED_HEADSET: + case AudioDeviceInfo.TYPE_WIRED_HEADPHONES: + case AudioDeviceInfo.TYPE_BLUETOOTH_SCO: + case AudioDeviceInfo.TYPE_BUILTIN_EARPIECE: return VIRTUALIZATION_MODE_BINAURAL; - case AudioDevice.TYPE_BUILTIN_SPEAKER: - case AudioDevice.TYPE_LINE_ANALOG: - case AudioDevice.TYPE_LINE_DIGITAL: - case AudioDevice.TYPE_BLUETOOTH_A2DP: - case AudioDevice.TYPE_HDMI: - case AudioDevice.TYPE_HDMI_ARC: - case AudioDevice.TYPE_USB_DEVICE: - case AudioDevice.TYPE_USB_ACCESSORY: - case AudioDevice.TYPE_DOCK: - case AudioDevice.TYPE_FM: - case AudioDevice.TYPE_AUX_LINE: + case AudioDeviceInfo.TYPE_BUILTIN_SPEAKER: + case AudioDeviceInfo.TYPE_LINE_ANALOG: + case AudioDeviceInfo.TYPE_LINE_DIGITAL: + case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP: + case AudioDeviceInfo.TYPE_HDMI: + case AudioDeviceInfo.TYPE_HDMI_ARC: + case AudioDeviceInfo.TYPE_USB_DEVICE: + case AudioDeviceInfo.TYPE_USB_ACCESSORY: + case AudioDeviceInfo.TYPE_DOCK: + case AudioDeviceInfo.TYPE_FM: + case AudioDeviceInfo.TYPE_AUX_LINE: return VIRTUALIZATION_MODE_TRANSAURAL; - case AudioDevice.TYPE_UNKNOWN: + case AudioDeviceInfo.TYPE_UNKNOWN: default: return VIRTUALIZATION_MODE_OFF; } @@ -433,7 +433,7 @@ public class Virtualizer extends AudioEffect { throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException { // convert Java device type to internal representation int deviceType = getDeviceForModeForce(virtualizationMode); - int internalDevice = AudioDevice.convertDeviceTypeToInternalDevice(deviceType); + int internalDevice = AudioDeviceInfo.convertDeviceTypeToInternalDevice(deviceType); int status = setParameter(PARAM_FORCE_VIRTUALIZATION_MODE, internalDevice); @@ -470,7 +470,7 @@ public class Virtualizer extends AudioEffect { int[] value = new int[1]; int status = getParameter(PARAM_VIRTUALIZATION_MODE, value); if (status >= 0) { - return deviceToMode(AudioDevice.convertInternalDeviceToDeviceType(value[0])); + return deviceToMode(AudioDeviceInfo.convertInternalDeviceToDeviceType(value[0])); } else if (status == AudioEffect.ERROR_BAD_VALUE) { return VIRTUALIZATION_MODE_OFF; } else { |