Java Code Examples for android.media.AudioDeviceInfo#isSink()

The following examples show how to use android.media.AudioDeviceInfo#isSink() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioDeviceListEntry.java    From vinyl-cast with MIT License 6 votes vote down vote up
@TargetApi(23)
static List<AudioDeviceListEntry> createFilteredListFrom(AudioDeviceInfo[] devices, int directionType, Set<Integer> filteredTypes){

    List<AudioDeviceListEntry> listEntries = new Vector<>();
    for (AudioDeviceInfo info : devices) {
        if (directionType == AudioManager.GET_DEVICES_ALL ||
                (directionType == AudioManager.GET_DEVICES_OUTPUTS && info.isSink()) ||
                (directionType == AudioManager.GET_DEVICES_INPUTS && info.isSource())) {
            if (filteredTypes.contains(info.getType())) {
                continue;
            }
            listEntries.add(new AudioDeviceListEntry(info.getId(), info.getType(),
                    info.getProductName() + ": " + AudioDeviceInfoConverter.typeToString(info.getType())));
        }
    }
    return listEntries;
}
 
Example 2
Source File: AudioDeviceListEntry.java    From vinyl-cast with MIT License 5 votes vote down vote up
/**
 * Create a list of AudioDeviceListEntry objects from a list of AudioDeviceInfo objects.
 *
 * @param devices A list of {@Link AudioDeviceInfo} objects
 * @param directionType Only audio devices with this direction will be included in the list.
 *                      Valid values are GET_DEVICES_ALL, GET_DEVICES_OUTPUTS and
 *                      GET_DEVICES_INPUTS.
 * @return A list of AudioDeviceListEntry objects
 */
@TargetApi(23)
static List<AudioDeviceListEntry> createListFrom(AudioDeviceInfo[] devices, int directionType){

    List<AudioDeviceListEntry> listEntries = new Vector<>();
    for (AudioDeviceInfo info : devices) {
        if (directionType == AudioManager.GET_DEVICES_ALL ||
                (directionType == AudioManager.GET_DEVICES_OUTPUTS && info.isSink()) ||
                (directionType == AudioManager.GET_DEVICES_INPUTS && info.isSource())) {
            listEntries.add(new AudioDeviceListEntry(info.getId(), info.getType(),
                    info.getProductName() + " " + AudioDeviceInfoConverter.typeToString(info.getType())));
        }
    }
    return listEntries;
}
 
Example 3
Source File: HeadphoneStateMonitor.java    From talkback with Apache License 2.0 5 votes vote down vote up
private static boolean isExternalDevice(AudioDeviceInfo device) {
  return device.isSink()
      && (device.getType() == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
          || device.getType() == AudioDeviceInfo.TYPE_AUX_LINE
          || device.getType() == AudioDeviceInfo.TYPE_WIRED_HEADPHONES
          || device.getType() == AudioDeviceInfo.TYPE_WIRED_HEADSET
          || device.getType() == AudioDeviceInfo.TYPE_USB_HEADSET);
}