1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.media; 18 19 import static android.media.audio.Flags.FLAG_ENABLE_MULTICHANNEL_GROUP_DEVICE; 20 import static android.media.audio.Flags.FLAG_SPEAKER_LAYOUT_API; 21 22 import android.Manifest; 23 import android.annotation.FlaggedApi; 24 import android.annotation.IntDef; 25 import android.annotation.NonNull; 26 import android.annotation.RequiresPermission; 27 import android.annotation.TestApi; 28 import android.media.audio.Flags; 29 import android.util.SparseIntArray; 30 31 import com.android.internal.annotations.VisibleForTesting; 32 33 import java.lang.annotation.Retention; 34 import java.lang.annotation.RetentionPolicy; 35 import java.util.List; 36 import java.util.Objects; 37 import java.util.TreeSet; 38 39 /** 40 * Provides information about an audio device. 41 */ 42 public final class AudioDeviceInfo { 43 44 /** 45 * A device type associated with an unknown or uninitialized device. 46 */ 47 public static final int TYPE_UNKNOWN = 0; 48 /** 49 * A device type describing the attached earphone speaker. 50 */ 51 public static final int TYPE_BUILTIN_EARPIECE = 1; 52 /** 53 * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built 54 * in a device. 55 */ 56 public static final int TYPE_BUILTIN_SPEAKER = 2; 57 /** 58 * A device type describing a headset, which is the combination of a headphones and microphone. 59 */ 60 public static final int TYPE_WIRED_HEADSET = 3; 61 /** 62 * A device type describing a pair of wired headphones. 63 */ 64 public static final int TYPE_WIRED_HEADPHONES = 4; 65 /** 66 * A device type describing an analog line-level connection. 67 */ 68 public static final int TYPE_LINE_ANALOG = 5; 69 /** 70 * A device type describing a digital line connection (e.g. SPDIF). 71 */ 72 public static final int TYPE_LINE_DIGITAL = 6; 73 /** 74 * A device type describing a Bluetooth device typically used for telephony. 75 */ 76 public static final int TYPE_BLUETOOTH_SCO = 7; 77 /** 78 * A device type describing a Bluetooth device supporting the A2DP profile. 79 */ 80 public static final int TYPE_BLUETOOTH_A2DP = 8; 81 /** 82 * A device type describing an HDMI connection . 83 */ 84 public static final int TYPE_HDMI = 9; 85 /** 86 * A device type describing the Audio Return Channel of an HDMI connection. 87 */ 88 public static final int TYPE_HDMI_ARC = 10; 89 /** 90 * A device type describing a USB audio device. 91 */ 92 public static final int TYPE_USB_DEVICE = 11; 93 /** 94 * A device type describing a USB audio device in accessory mode. 95 */ 96 public static final int TYPE_USB_ACCESSORY = 12; 97 /** 98 * A device type describing the audio device associated with a dock. 99 * Starting at API 34, this device type only represents digital docks, while docks with an 100 * analog connection are represented with {@link #TYPE_DOCK_ANALOG}. 101 * @see #TYPE_DOCK_ANALOG 102 */ 103 public static final int TYPE_DOCK = 13; 104 /** 105 * A device type associated with the transmission of audio signals over FM. 106 */ 107 public static final int TYPE_FM = 14; 108 /** 109 * A device type describing the microphone(s) built in a device. 110 */ 111 public static final int TYPE_BUILTIN_MIC = 15; 112 /** 113 * A device type for accessing the audio content transmitted over FM. 114 */ 115 public static final int TYPE_FM_TUNER = 16; 116 /** 117 * A device type for accessing the audio content transmitted over the TV tuner system. 118 */ 119 public static final int TYPE_TV_TUNER = 17; 120 /** 121 * A device type describing the transmission of audio signals over the telephony network. 122 */ 123 public static final int TYPE_TELEPHONY = 18; 124 /** 125 * A device type describing the auxiliary line-level connectors. 126 */ 127 public static final int TYPE_AUX_LINE = 19; 128 /** 129 * A device type connected over IP. 130 */ 131 public static final int TYPE_IP = 20; 132 /** 133 * A type-agnostic device used for communication with external audio systems 134 */ 135 public static final int TYPE_BUS = 21; 136 /** 137 * A device type describing a USB audio headset. 138 */ 139 public static final int TYPE_USB_HEADSET = 22; 140 /** 141 * A device type describing a Hearing Aid. 142 */ 143 public static final int TYPE_HEARING_AID = 23; 144 /** 145 * A device type describing the speaker system (i.e. a mono speaker or stereo speakers) built 146 * in a device, that is specifically tuned for outputting sounds like notifications and alarms 147 * (i.e. sounds the user couldn't necessarily anticipate). 148 * <p>Note that this physical audio device may be the same as {@link #TYPE_BUILTIN_SPEAKER} 149 * but is driven differently to safely accommodate the different use case.</p> 150 */ 151 public static final int TYPE_BUILTIN_SPEAKER_SAFE = 24; 152 /** 153 * A device type for rerouting audio within the Android framework between mixes and 154 * system applications. 155 * This type is for instance encountered when querying the output device of a track 156 * (with {@link AudioTrack#getRoutedDevice()} playing from a device in screen mirroring mode, 157 * where the audio is not heard on the device, but on the remote device. 158 */ 159 // Typically created when using 160 // {@link android.media.audiopolicy.AudioPolicy} for mixes created with the 161 // {@link android.media.audiopolicy.AudioMix#ROUTE_FLAG_LOOP_BACK} flag. 162 public static final int TYPE_REMOTE_SUBMIX = 25; 163 164 /** 165 * A device type describing a Bluetooth Low Energy (BLE) audio headset or headphones. 166 * Headphones are grouped with headsets when the device is a sink: 167 * the features of headsets and headphones with regard to playback are the same. 168 */ 169 public static final int TYPE_BLE_HEADSET = 26; 170 171 /** 172 * A device type describing a Bluetooth Low Energy (BLE) audio speaker. 173 */ 174 public static final int TYPE_BLE_SPEAKER = 27; 175 176 /** 177 * A device type describing an Echo Canceller loopback Reference. 178 * This device is only used when capturing with MediaRecorder.AudioSource.ECHO_REFERENCE, 179 * which requires privileged permission 180 * {@link android.Manifest.permission#CAPTURE_AUDIO_OUTPUT}. 181 * @hide */ 182 @RequiresPermission(Manifest.permission.CAPTURE_AUDIO_OUTPUT) 183 public static final int TYPE_ECHO_REFERENCE = 28; 184 185 /** 186 * A device type describing the Enhanced Audio Return Channel of an HDMI connection. 187 */ 188 public static final int TYPE_HDMI_EARC = 29; 189 190 /** 191 * A device type describing a Bluetooth Low Energy (BLE) broadcast group. 192 */ 193 public static final int TYPE_BLE_BROADCAST = 30; 194 195 /** 196 * A device type describing the audio device associated with a dock using an analog connection. 197 */ 198 public static final int TYPE_DOCK_ANALOG = 31; 199 200 /** 201 * A device type describing a speaker group that supports multichannel contents. The speakers in 202 * the group are connected together using local network based protocols. The speaker group 203 * requires additional input of the physical positions of each individual speaker to provide a 204 * better experience on multichannel contents. 205 */ 206 @FlaggedApi(FLAG_ENABLE_MULTICHANNEL_GROUP_DEVICE) 207 public static final int TYPE_MULTICHANNEL_GROUP = 32; 208 209 /** @hide */ 210 @IntDef(flag = false, prefix = "TYPE", value = { 211 TYPE_BUILTIN_EARPIECE, 212 TYPE_BUILTIN_SPEAKER, 213 TYPE_WIRED_HEADSET, 214 TYPE_WIRED_HEADPHONES, 215 TYPE_BLUETOOTH_SCO, 216 TYPE_BLUETOOTH_A2DP, 217 TYPE_HDMI, 218 TYPE_DOCK, 219 TYPE_USB_ACCESSORY, 220 TYPE_USB_DEVICE, 221 TYPE_USB_HEADSET, 222 TYPE_TELEPHONY, 223 TYPE_LINE_ANALOG, 224 TYPE_HDMI_ARC, 225 TYPE_HDMI_EARC, 226 TYPE_LINE_DIGITAL, 227 TYPE_FM, 228 TYPE_AUX_LINE, 229 TYPE_IP, 230 TYPE_BUS, 231 TYPE_HEARING_AID, 232 TYPE_BUILTIN_MIC, 233 TYPE_FM_TUNER, 234 TYPE_TV_TUNER, 235 TYPE_BUILTIN_SPEAKER_SAFE, 236 TYPE_REMOTE_SUBMIX, 237 TYPE_BLE_HEADSET, 238 TYPE_BLE_SPEAKER, 239 TYPE_ECHO_REFERENCE, 240 TYPE_BLE_BROADCAST, 241 TYPE_DOCK_ANALOG, 242 TYPE_MULTICHANNEL_GROUP} 243 ) 244 @Retention(RetentionPolicy.SOURCE) 245 public @interface AudioDeviceType {} 246 247 /** @hide */ 248 @IntDef(flag = false, prefix = "TYPE", value = { 249 TYPE_BUILTIN_MIC, 250 TYPE_BLUETOOTH_SCO, 251 TYPE_BLUETOOTH_A2DP, 252 TYPE_WIRED_HEADSET, 253 TYPE_HDMI, 254 TYPE_TELEPHONY, 255 TYPE_DOCK, 256 TYPE_USB_ACCESSORY, 257 TYPE_USB_DEVICE, 258 TYPE_USB_HEADSET, 259 TYPE_FM_TUNER, 260 TYPE_TV_TUNER, 261 TYPE_LINE_ANALOG, 262 TYPE_LINE_DIGITAL, 263 TYPE_IP, 264 TYPE_BUS, 265 TYPE_REMOTE_SUBMIX, 266 TYPE_BLE_HEADSET, 267 TYPE_HDMI_ARC, 268 TYPE_HDMI_EARC, 269 TYPE_ECHO_REFERENCE, 270 TYPE_DOCK_ANALOG} 271 ) 272 @Retention(RetentionPolicy.SOURCE) 273 public @interface AudioDeviceTypeIn {} 274 275 /** @hide */ 276 @IntDef(flag = false, prefix = "TYPE", value = { 277 TYPE_BUILTIN_EARPIECE, 278 TYPE_BUILTIN_SPEAKER, 279 TYPE_WIRED_HEADSET, 280 TYPE_WIRED_HEADPHONES, 281 TYPE_BLUETOOTH_SCO, 282 TYPE_BLUETOOTH_A2DP, 283 TYPE_HDMI, 284 TYPE_DOCK, 285 TYPE_USB_ACCESSORY, 286 TYPE_USB_DEVICE, 287 TYPE_USB_HEADSET, 288 TYPE_TELEPHONY, 289 TYPE_LINE_ANALOG, 290 TYPE_HDMI_ARC, 291 TYPE_HDMI_EARC, 292 TYPE_LINE_DIGITAL, 293 TYPE_FM, 294 TYPE_AUX_LINE, 295 TYPE_IP, 296 TYPE_BUS, 297 TYPE_REMOTE_SUBMIX, 298 TYPE_HEARING_AID, 299 TYPE_BUILTIN_SPEAKER_SAFE, 300 TYPE_BLE_HEADSET, 301 TYPE_BLE_SPEAKER, 302 TYPE_BLE_BROADCAST, 303 TYPE_DOCK_ANALOG, 304 TYPE_MULTICHANNEL_GROUP} 305 ) 306 @Retention(RetentionPolicy.SOURCE) 307 public @interface AudioDeviceTypeOut {} 308 309 /** @hide */ isValidAudioDeviceTypeOut(int type)310 /*package*/ static boolean isValidAudioDeviceTypeOut(int type) { 311 switch (type) { 312 case TYPE_BUILTIN_EARPIECE: 313 case TYPE_BUILTIN_SPEAKER: 314 case TYPE_WIRED_HEADSET: 315 case TYPE_WIRED_HEADPHONES: 316 case TYPE_BLUETOOTH_SCO: 317 case TYPE_BLUETOOTH_A2DP: 318 case TYPE_HDMI: 319 case TYPE_DOCK: 320 case TYPE_USB_ACCESSORY: 321 case TYPE_USB_DEVICE: 322 case TYPE_USB_HEADSET: 323 case TYPE_TELEPHONY: 324 case TYPE_LINE_ANALOG: 325 case TYPE_HDMI_ARC: 326 case TYPE_HDMI_EARC: 327 case TYPE_LINE_DIGITAL: 328 case TYPE_FM: 329 case TYPE_AUX_LINE: 330 case TYPE_IP: 331 case TYPE_BUS: 332 case TYPE_REMOTE_SUBMIX: 333 case TYPE_HEARING_AID: 334 case TYPE_BUILTIN_SPEAKER_SAFE: 335 case TYPE_BLE_HEADSET: 336 case TYPE_BLE_SPEAKER: 337 case TYPE_BLE_BROADCAST: 338 case TYPE_DOCK_ANALOG: 339 return true; 340 341 default: 342 if (Flags.enableMultichannelGroupDevice()) { 343 if (type == TYPE_MULTICHANNEL_GROUP) { 344 return true; 345 } 346 } 347 return false; 348 } 349 } 350 351 /** @hide */ isValidAudioDeviceTypeIn(int type)352 /*package*/ static boolean isValidAudioDeviceTypeIn(int type) { 353 switch (type) { 354 case TYPE_BUILTIN_MIC: 355 case TYPE_BLUETOOTH_SCO: 356 case TYPE_BLUETOOTH_A2DP: 357 case TYPE_WIRED_HEADSET: 358 case TYPE_HDMI: 359 case TYPE_TELEPHONY: 360 case TYPE_DOCK: 361 case TYPE_USB_ACCESSORY: 362 case TYPE_USB_DEVICE: 363 case TYPE_USB_HEADSET: 364 case TYPE_FM_TUNER: 365 case TYPE_TV_TUNER: 366 case TYPE_LINE_ANALOG: 367 case TYPE_LINE_DIGITAL: 368 case TYPE_IP: 369 case TYPE_BUS: 370 case TYPE_REMOTE_SUBMIX: 371 case TYPE_BLE_HEADSET: 372 case TYPE_HDMI_ARC: 373 case TYPE_HDMI_EARC: 374 case TYPE_ECHO_REFERENCE: 375 case TYPE_DOCK_ANALOG: 376 return true; 377 default: 378 return false; 379 } 380 } 381 382 /** 383 * @hide 384 * Enforces whether the audio device type is acceptable for output. 385 * 386 * A vendor implemented output type should modify isValidAudioDeviceTypeOut() 387 * appropriately to accept the new type. Do not remove already acceptable types. 388 * 389 * @throws IllegalArgumentException on an invalid output device type. 390 * @param type 391 */ 392 @TestApi enforceValidAudioDeviceTypeOut(int type)393 public static void enforceValidAudioDeviceTypeOut(int type) { 394 if (!isValidAudioDeviceTypeOut(type)) { 395 throw new IllegalArgumentException("Illegal output device type " + type); 396 } 397 } 398 399 /** 400 * @hide 401 * Enforces whether the audio device type is acceptable for input. 402 * 403 * A vendor implemented input type should modify isValidAudioDeviceTypeIn() 404 * appropriately to accept the new type. Do not remove already acceptable types. 405 * 406 * @throws IllegalArgumentException on an invalid input device type. 407 * @param type 408 */ 409 @TestApi enforceValidAudioDeviceTypeIn(int type)410 public static void enforceValidAudioDeviceTypeIn(int type) { 411 if (!isValidAudioDeviceTypeIn(type)) { 412 throw new IllegalArgumentException("Illegal input device type " + type); 413 } 414 } 415 416 @Override equals(Object o)417 public boolean equals(Object o) { 418 if (this == o) return true; 419 if (o == null || getClass() != o.getClass()) return false; 420 AudioDeviceInfo that = (AudioDeviceInfo) o; 421 return Objects.equals(getPort(), that.getPort()); 422 } 423 424 @Override hashCode()425 public int hashCode() { 426 return Objects.hash(getPort()); 427 } 428 429 private final AudioDevicePort mPort; 430 431 /** @hide */ 432 @VisibleForTesting AudioDeviceInfo(AudioDevicePort port)433 public AudioDeviceInfo(AudioDevicePort port) { 434 mPort = port; 435 } 436 437 /** 438 * @hide 439 * @return The underlying {@link AudioDevicePort} instance. 440 */ getPort()441 public AudioDevicePort getPort() { 442 return mPort; 443 } 444 445 /** 446 * @hide 447 * @return the internal device type 448 */ getInternalType()449 public int getInternalType() { 450 return mPort.type(); 451 } 452 453 /** 454 * @return The internal device ID. 455 */ getId()456 public int getId() { 457 return mPort.handle().id(); 458 } 459 460 /** 461 * @return The human-readable name of the audio device. 462 */ getProductName()463 public CharSequence getProductName() { 464 String portName = mPort.name(); 465 return (portName != null && portName.length() != 0) ? portName : android.os.Build.MODEL; 466 } 467 468 /** 469 * @return The "address" string of the device. This generally contains device-specific 470 * parameters. 471 */ getAddress()472 public @NonNull String getAddress() { 473 return mPort.address(); 474 } 475 476 /** 477 * @return true if the audio device is a source for audio data (e.e an input). 478 */ isSource()479 public boolean isSource() { 480 return mPort.role() == AudioPort.ROLE_SOURCE; 481 } 482 483 /** 484 * @return true if the audio device is a sink for audio data (i.e. an output). 485 */ isSink()486 public boolean isSink() { 487 return mPort.role() == AudioPort.ROLE_SINK; 488 } 489 490 /** 491 * @return An array of sample rates supported by the audio device. 492 * 493 * Note: an empty array indicates that the device supports arbitrary rates. 494 */ getSampleRates()495 public @NonNull int[] getSampleRates() { 496 return mPort.samplingRates(); 497 } 498 499 /** 500 * @return An array of channel position masks (e.g. {@link AudioFormat#CHANNEL_IN_STEREO}, 501 * {@link AudioFormat#CHANNEL_OUT_7POINT1}) for which this audio device can be configured. 502 * 503 * @see AudioFormat 504 * 505 * Note: an empty array indicates that the device supports arbitrary channel masks. 506 */ getChannelMasks()507 public @NonNull int[] getChannelMasks() { 508 return mPort.channelMasks(); 509 } 510 511 /** 512 * @return An array of channel index masks for which this audio device can be configured. 513 * 514 * @see AudioFormat 515 * 516 * Note: an empty array indicates that the device supports arbitrary channel index masks. 517 */ getChannelIndexMasks()518 public @NonNull int[] getChannelIndexMasks() { 519 return mPort.channelIndexMasks(); 520 } 521 522 /** 523 * @return An array of channel counts (1, 2, 4, ...) for which this audio device 524 * can be configured. 525 * 526 * Note: an empty array indicates that the device supports arbitrary channel counts. 527 */ getChannelCounts()528 public @NonNull int[] getChannelCounts() { 529 TreeSet<Integer> countSet = new TreeSet<Integer>(); 530 531 // Channel Masks 532 for (int mask : getChannelMasks()) { 533 countSet.add(isSink() ? 534 AudioFormat.channelCountFromOutChannelMask(mask) 535 : AudioFormat.channelCountFromInChannelMask(mask)); 536 } 537 538 // Index Masks 539 for (int index_mask : getChannelIndexMasks()) { 540 countSet.add(Integer.bitCount(index_mask)); 541 } 542 543 int[] counts = new int[countSet.size()]; 544 int index = 0; 545 for (int count : countSet) { 546 counts[index++] = count; 547 } 548 return counts; 549 } 550 551 /** @hide */ 552 @IntDef(flag = true, prefix = "AudioFormat.CHANNEL_OUT_", value = { 553 AudioFormat.CHANNEL_INVALID, 554 AudioFormat.CHANNEL_OUT_DEFAULT, 555 AudioFormat.CHANNEL_OUT_FRONT_LEFT, 556 AudioFormat.CHANNEL_OUT_FRONT_RIGHT, 557 AudioFormat.CHANNEL_OUT_FRONT_CENTER, 558 AudioFormat.CHANNEL_OUT_LOW_FREQUENCY, 559 AudioFormat.CHANNEL_OUT_BACK_LEFT, 560 AudioFormat.CHANNEL_OUT_BACK_RIGHT, 561 AudioFormat.CHANNEL_OUT_FRONT_LEFT_OF_CENTER, 562 AudioFormat.CHANNEL_OUT_FRONT_RIGHT_OF_CENTER, 563 AudioFormat.CHANNEL_OUT_BACK_CENTER, 564 AudioFormat.CHANNEL_OUT_SIDE_LEFT, 565 AudioFormat.CHANNEL_OUT_SIDE_RIGHT, 566 AudioFormat.CHANNEL_OUT_TOP_CENTER, 567 AudioFormat.CHANNEL_OUT_TOP_FRONT_LEFT, 568 AudioFormat.CHANNEL_OUT_TOP_FRONT_CENTER, 569 AudioFormat.CHANNEL_OUT_TOP_FRONT_RIGHT, 570 AudioFormat.CHANNEL_OUT_TOP_BACK_LEFT, 571 AudioFormat.CHANNEL_OUT_TOP_BACK_CENTER, 572 AudioFormat.CHANNEL_OUT_TOP_BACK_RIGHT, 573 AudioFormat.CHANNEL_OUT_TOP_SIDE_LEFT, 574 AudioFormat.CHANNEL_OUT_TOP_SIDE_RIGHT, 575 AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_LEFT, 576 AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_CENTER, 577 AudioFormat.CHANNEL_OUT_BOTTOM_FRONT_RIGHT, 578 AudioFormat.CHANNEL_OUT_LOW_FREQUENCY_2, 579 AudioFormat.CHANNEL_OUT_FRONT_WIDE_LEFT, 580 AudioFormat.CHANNEL_OUT_FRONT_WIDE_RIGHT} 581 ) 582 @Retention(RetentionPolicy.SOURCE) 583 @FlaggedApi(FLAG_SPEAKER_LAYOUT_API) 584 public @interface SpeakerLayoutChannelMask {} 585 586 /** 587 * @return A ChannelMask representing the speaker layout of a TYPE_BUILTIN_SPEAKER device. 588 * 589 * Valid only for speakers built-in to the device. 590 * 591 * The layout channel mask only indicates which speaker channels are present, the 592 * physical layout of the speakers should be informed by a standard for multi-channel 593 * sound playback systems, such as ITU-R BS.2051. 594 * @see AudioFormat 595 */ 596 @FlaggedApi(FLAG_SPEAKER_LAYOUT_API) 597 @SpeakerLayoutChannelMask getSpeakerLayoutChannelMask()598 public int getSpeakerLayoutChannelMask() { 599 return mPort.speakerLayoutChannelMask(); 600 } 601 602 /** 603 * @return An array of audio encodings (e.g. {@link AudioFormat#ENCODING_PCM_16BIT}, 604 * {@link AudioFormat#ENCODING_PCM_FLOAT}) supported by the audio device. 605 * <code>ENCODING_PCM_FLOAT</code> indicates the device supports more 606 * than 16 bits of integer precision. As there is no AudioFormat constant 607 * specifically defined for 24-bit PCM, the value <code>ENCODING_PCM_FLOAT</code> 608 * indicates that {@link AudioTrack} or {@link AudioRecord} can preserve at least 24 bits of 609 * integer precision to that device. 610 * 611 * @see AudioFormat 612 * 613 * Note: an empty array indicates that the device supports arbitrary encodings. 614 * For forward compatibility, applications should ignore entries it does not recognize. 615 */ getEncodings()616 public @NonNull int[] getEncodings() { 617 return AudioFormat.filterPublicFormats(mPort.formats()); 618 } 619 620 /** 621 * @return A list of {@link AudioProfile} supported by the audio devices. 622 */ getAudioProfiles()623 public @NonNull List<AudioProfile> getAudioProfiles() { 624 return mPort.profiles(); 625 } 626 627 /** 628 * @return A list of {@link AudioDescriptor} supported by the audio devices. 629 */ getAudioDescriptors()630 public @NonNull List<AudioDescriptor> getAudioDescriptors() { 631 return mPort.audioDescriptors(); 632 } 633 634 /** 635 * Returns an array of supported encapsulation modes for the device. 636 * 637 * The array can include any of the {@code AudioTrack} encapsulation modes, 638 * e.g. {@link AudioTrack#ENCAPSULATION_MODE_ELEMENTARY_STREAM}. 639 * 640 * @return An array of supported encapsulation modes for the device. This 641 * may be an empty array if no encapsulation modes are supported. 642 */ getEncapsulationModes()643 public @NonNull @AudioTrack.EncapsulationMode int[] getEncapsulationModes() { 644 return mPort.encapsulationModes(); 645 } 646 647 /** 648 * Returns an array of supported encapsulation metadata types for the device. 649 * 650 * The metadata type returned should be allowed for all encapsulation modes supported 651 * by the device. Some metadata types may apply only to certain 652 * compressed stream formats, the returned list is the union of subsets. 653 * 654 * The array can include any of 655 * {@link AudioTrack#ENCAPSULATION_METADATA_TYPE_FRAMEWORK_TUNER}, 656 * {@link AudioTrack#ENCAPSULATION_METADATA_TYPE_DVB_AD_DESCRIPTOR}. 657 * 658 * @return An array of supported encapsulation metadata types for the device. This 659 * may be an empty array if no metadata types are supported. 660 */ getEncapsulationMetadataTypes()661 public @NonNull @AudioTrack.EncapsulationMetadataType int[] getEncapsulationMetadataTypes() { 662 return mPort.encapsulationMetadataTypes(); 663 } 664 665 /** 666 * @return The device type identifier of the audio device (i.e. TYPE_BUILTIN_SPEAKER). 667 */ getType()668 public @AudioDeviceType int getType() { 669 return INT_TO_EXT_DEVICE_MAPPING.get(mPort.type(), TYPE_UNKNOWN); 670 } 671 672 /** @hide */ convertDeviceTypeToInternalDevice(@udioDeviceType int deviceType)673 public static int convertDeviceTypeToInternalDevice(@AudioDeviceType int deviceType) { 674 return EXT_TO_INT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE); 675 } 676 677 /** @hide */ convertInternalDeviceToDeviceType(int intDevice)678 public static @AudioDeviceType int convertInternalDeviceToDeviceType(int intDevice) { 679 return INT_TO_EXT_DEVICE_MAPPING.get(intDevice, TYPE_UNKNOWN); 680 } 681 682 /** @hide */ convertDeviceTypeToInternalInputDevice(@udioDeviceType int deviceType)683 public static int convertDeviceTypeToInternalInputDevice(@AudioDeviceType int deviceType) { 684 return convertDeviceTypeToInternalInputDevice(deviceType, ""); 685 } 686 /** @hide */ convertDeviceTypeToInternalInputDevice(@udioDeviceType int deviceType, String address)687 public static int convertDeviceTypeToInternalInputDevice(@AudioDeviceType int deviceType, 688 String address) { 689 int internalType = EXT_TO_INT_INPUT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE); 690 if (internalType == AudioSystem.DEVICE_IN_BUILTIN_MIC 691 && "back".equals(address)) { 692 internalType = AudioSystem.DEVICE_IN_BACK_MIC; 693 } 694 return internalType; 695 } 696 697 private static final SparseIntArray INT_TO_EXT_DEVICE_MAPPING; 698 699 private static final SparseIntArray EXT_TO_INT_DEVICE_MAPPING; 700 701 /** 702 * EXT_TO_INT_INPUT_DEVICE_MAPPING aims at mapping external device type to internal input device 703 * type. 704 */ 705 private static final SparseIntArray EXT_TO_INT_INPUT_DEVICE_MAPPING; 706 707 static { 708 INT_TO_EXT_DEVICE_MAPPING = new SparseIntArray(); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_EARPIECE, TYPE_BUILTIN_EARPIECE)709 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_EARPIECE, TYPE_BUILTIN_EARPIECE); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPEAKER, TYPE_BUILTIN_SPEAKER)710 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPEAKER, TYPE_BUILTIN_SPEAKER); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_WIRED_HEADSET, TYPE_WIRED_HEADSET)711 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_WIRED_HEADSET, TYPE_WIRED_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE, TYPE_WIRED_HEADPHONES)712 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE, TYPE_WIRED_HEADPHONES); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO, TYPE_BLUETOOTH_SCO)713 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO, TYPE_BLUETOOTH_SCO); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO)714 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT, TYPE_BLUETOOTH_SCO)715 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT, TYPE_BLUETOOTH_SCO); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP)716 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, TYPE_BLUETOOTH_A2DP)717 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, TYPE_BLUETOOTH_A2DP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, TYPE_BLUETOOTH_A2DP)718 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, TYPE_BLUETOOTH_A2DP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI, TYPE_HDMI)719 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI, TYPE_HDMI); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET, TYPE_DOCK_ANALOG)720 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET, TYPE_DOCK_ANALOG); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET, TYPE_DOCK)721 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET, TYPE_DOCK); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_ACCESSORY, TYPE_USB_ACCESSORY)722 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_ACCESSORY, TYPE_USB_ACCESSORY); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_DEVICE, TYPE_USB_DEVICE)723 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_DEVICE, TYPE_USB_DEVICE); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_HEADSET, TYPE_USB_HEADSET)724 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_USB_HEADSET, TYPE_USB_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_TELEPHONY_TX, TYPE_TELEPHONY)725 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_TELEPHONY_TX, TYPE_TELEPHONY); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_LINE, TYPE_LINE_ANALOG)726 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_LINE, TYPE_LINE_ANALOG); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI_ARC, TYPE_HDMI_ARC)727 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI_ARC, TYPE_HDMI_ARC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI_EARC, TYPE_HDMI_EARC)728 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HDMI_EARC, TYPE_HDMI_EARC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPDIF, TYPE_LINE_DIGITAL)729 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPDIF, TYPE_LINE_DIGITAL); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_FM, TYPE_FM)730 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_FM, TYPE_FM); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_AUX_LINE, TYPE_AUX_LINE)731 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_AUX_LINE, TYPE_AUX_LINE); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_IP, TYPE_IP)732 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_IP, TYPE_IP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BUS, TYPE_BUS)733 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BUS, TYPE_BUS); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HEARING_AID, TYPE_HEARING_AID)734 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_HEARING_AID, TYPE_HEARING_AID); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPEAKER_SAFE, TYPE_BUILTIN_SPEAKER_SAFE)735 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_SPEAKER_SAFE, 736 TYPE_BUILTIN_SPEAKER_SAFE); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX)737 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_HEADSET, TYPE_BLE_HEADSET)738 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_HEADSET, TYPE_BLE_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_SPEAKER, TYPE_BLE_SPEAKER)739 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_SPEAKER, TYPE_BLE_SPEAKER); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_BROADCAST, TYPE_BLE_BROADCAST)740 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_OUT_BLE_BROADCAST, TYPE_BLE_BROADCAST); 741 if (Flags.enableMultichannelGroupDevice()) { INT_TO_EXT_DEVICE_MAPPING.put( AudioSystem.DEVICE_OUT_MULTICHANNEL_GROUP, TYPE_MULTICHANNEL_GROUP)742 INT_TO_EXT_DEVICE_MAPPING.put( 743 AudioSystem.DEVICE_OUT_MULTICHANNEL_GROUP, TYPE_MULTICHANNEL_GROUP); 744 } 745 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUILTIN_MIC, TYPE_BUILTIN_MIC)746 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUILTIN_MIC, TYPE_BUILTIN_MIC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO)747 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET, TYPE_BLUETOOTH_SCO); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_WIRED_HEADSET, TYPE_WIRED_HEADSET)748 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_WIRED_HEADSET, TYPE_WIRED_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI, TYPE_HDMI)749 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI, TYPE_HDMI); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_TELEPHONY_RX, TYPE_TELEPHONY)750 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_TELEPHONY_RX, TYPE_TELEPHONY); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BACK_MIC, TYPE_BUILTIN_MIC)751 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BACK_MIC, TYPE_BUILTIN_MIC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_ANLG_DOCK_HEADSET, TYPE_DOCK_ANALOG)752 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_ANLG_DOCK_HEADSET, TYPE_DOCK_ANALOG); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_DGTL_DOCK_HEADSET, TYPE_DOCK)753 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_DGTL_DOCK_HEADSET, TYPE_DOCK); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_ACCESSORY, TYPE_USB_ACCESSORY)754 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_ACCESSORY, TYPE_USB_ACCESSORY); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_DEVICE, TYPE_USB_DEVICE)755 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_DEVICE, TYPE_USB_DEVICE); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_HEADSET, TYPE_USB_HEADSET)756 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_USB_HEADSET, TYPE_USB_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_FM_TUNER, TYPE_FM_TUNER)757 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_FM_TUNER, TYPE_FM_TUNER); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_TV_TUNER, TYPE_TV_TUNER)758 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_TV_TUNER, TYPE_TV_TUNER); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_LINE, TYPE_LINE_ANALOG)759 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_LINE, TYPE_LINE_ANALOG); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_SPDIF, TYPE_LINE_DIGITAL)760 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_SPDIF, TYPE_LINE_DIGITAL); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP)761 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, TYPE_BLUETOOTH_A2DP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_IP, TYPE_IP)762 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_IP, TYPE_IP); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUS, TYPE_BUS)763 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BUS, TYPE_BUS); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX)764 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_REMOTE_SUBMIX, TYPE_REMOTE_SUBMIX); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLE_HEADSET, TYPE_BLE_HEADSET)765 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_BLE_HEADSET, TYPE_BLE_HEADSET); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI_ARC, TYPE_HDMI_ARC)766 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI_ARC, TYPE_HDMI_ARC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI_EARC, TYPE_HDMI_EARC)767 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_HDMI_EARC, TYPE_HDMI_EARC); INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_ECHO_REFERENCE, TYPE_ECHO_REFERENCE)768 INT_TO_EXT_DEVICE_MAPPING.put(AudioSystem.DEVICE_IN_ECHO_REFERENCE, TYPE_ECHO_REFERENCE); 769 770 771 // privileges mapping to output device 772 EXT_TO_INT_DEVICE_MAPPING = new SparseIntArray(); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_EARPIECE, AudioSystem.DEVICE_OUT_EARPIECE)773 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_EARPIECE, AudioSystem.DEVICE_OUT_EARPIECE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_SPEAKER, AudioSystem.DEVICE_OUT_SPEAKER)774 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_SPEAKER, AudioSystem.DEVICE_OUT_SPEAKER); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_WIRED_HEADSET, AudioSystem.DEVICE_OUT_WIRED_HEADSET)775 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_WIRED_HEADSET, AudioSystem.DEVICE_OUT_WIRED_HEADSET); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_WIRED_HEADPHONES, AudioSystem.DEVICE_OUT_WIRED_HEADPHONE)776 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_WIRED_HEADPHONES, AudioSystem.DEVICE_OUT_WIRED_HEADPHONE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_LINE_ANALOG, AudioSystem.DEVICE_OUT_LINE)777 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_LINE_ANALOG, AudioSystem.DEVICE_OUT_LINE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_LINE_DIGITAL, AudioSystem.DEVICE_OUT_SPDIF)778 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_LINE_DIGITAL, AudioSystem.DEVICE_OUT_SPDIF); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLUETOOTH_SCO, AudioSystem.DEVICE_OUT_BLUETOOTH_SCO)779 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLUETOOTH_SCO, AudioSystem.DEVICE_OUT_BLUETOOTH_SCO); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLUETOOTH_A2DP, AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)780 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLUETOOTH_A2DP, AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI, AudioSystem.DEVICE_OUT_HDMI)781 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI, AudioSystem.DEVICE_OUT_HDMI); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI_ARC, AudioSystem.DEVICE_OUT_HDMI_ARC)782 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI_ARC, AudioSystem.DEVICE_OUT_HDMI_ARC); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI_EARC, AudioSystem.DEVICE_OUT_HDMI_EARC)783 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HDMI_EARC, AudioSystem.DEVICE_OUT_HDMI_EARC); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_DEVICE, AudioSystem.DEVICE_OUT_USB_DEVICE)784 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_DEVICE, AudioSystem.DEVICE_OUT_USB_DEVICE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_HEADSET, AudioSystem.DEVICE_OUT_USB_HEADSET)785 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_HEADSET, AudioSystem.DEVICE_OUT_USB_HEADSET); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_ACCESSORY, AudioSystem.DEVICE_OUT_USB_ACCESSORY)786 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_ACCESSORY, AudioSystem.DEVICE_OUT_USB_ACCESSORY); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET)787 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK_ANALOG, AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET)788 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK_ANALOG, AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM, AudioSystem.DEVICE_OUT_FM)789 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM, AudioSystem.DEVICE_OUT_FM); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_OUT_TELEPHONY_TX)790 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_OUT_TELEPHONY_TX); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_AUX_LINE, AudioSystem.DEVICE_OUT_AUX_LINE)791 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_AUX_LINE, AudioSystem.DEVICE_OUT_AUX_LINE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_OUT_IP)792 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_OUT_IP); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUS, AudioSystem.DEVICE_OUT_BUS)793 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUS, AudioSystem.DEVICE_OUT_BUS); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HEARING_AID, AudioSystem.DEVICE_OUT_HEARING_AID)794 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_HEARING_AID, AudioSystem.DEVICE_OUT_HEARING_AID); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_SPEAKER_SAFE, AudioSystem.DEVICE_OUT_SPEAKER_SAFE)795 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_SPEAKER_SAFE, 796 AudioSystem.DEVICE_OUT_SPEAKER_SAFE); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_REMOTE_SUBMIX, AudioSystem.DEVICE_OUT_REMOTE_SUBMIX)797 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_REMOTE_SUBMIX, AudioSystem.DEVICE_OUT_REMOTE_SUBMIX); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_HEADSET, AudioSystem.DEVICE_OUT_BLE_HEADSET)798 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_HEADSET, AudioSystem.DEVICE_OUT_BLE_HEADSET); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_SPEAKER, AudioSystem.DEVICE_OUT_BLE_SPEAKER)799 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_SPEAKER, AudioSystem.DEVICE_OUT_BLE_SPEAKER); EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_BROADCAST, AudioSystem.DEVICE_OUT_BLE_BROADCAST)800 EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BLE_BROADCAST, AudioSystem.DEVICE_OUT_BLE_BROADCAST); 801 if (Flags.enableMultichannelGroupDevice()) { EXT_TO_INT_DEVICE_MAPPING.put( TYPE_MULTICHANNEL_GROUP, AudioSystem.DEVICE_OUT_MULTICHANNEL_GROUP)802 EXT_TO_INT_DEVICE_MAPPING.put( 803 TYPE_MULTICHANNEL_GROUP, AudioSystem.DEVICE_OUT_MULTICHANNEL_GROUP); 804 } 805 806 // privileges mapping to input device 807 EXT_TO_INT_INPUT_DEVICE_MAPPING = new SparseIntArray(); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BUILTIN_MIC, AudioSystem.DEVICE_IN_BUILTIN_MIC)808 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BUILTIN_MIC, AudioSystem.DEVICE_IN_BUILTIN_MIC); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_BLUETOOTH_SCO, AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET)809 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 810 TYPE_BLUETOOTH_SCO, AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_WIRED_HEADSET, AudioSystem.DEVICE_IN_WIRED_HEADSET)811 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 812 TYPE_WIRED_HEADSET, AudioSystem.DEVICE_IN_WIRED_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI, AudioSystem.DEVICE_IN_HDMI)813 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI, AudioSystem.DEVICE_IN_HDMI); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_IN_TELEPHONY_RX)814 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_IN_TELEPHONY_RX); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_IN_DGTL_DOCK_HEADSET)815 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_IN_DGTL_DOCK_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_DOCK_ANALOG, AudioSystem.DEVICE_IN_ANLG_DOCK_HEADSET)816 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 817 TYPE_DOCK_ANALOG, AudioSystem.DEVICE_IN_ANLG_DOCK_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_USB_ACCESSORY, AudioSystem.DEVICE_IN_USB_ACCESSORY)818 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 819 TYPE_USB_ACCESSORY, AudioSystem.DEVICE_IN_USB_ACCESSORY); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_USB_DEVICE, AudioSystem.DEVICE_IN_USB_DEVICE)820 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_USB_DEVICE, AudioSystem.DEVICE_IN_USB_DEVICE); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_USB_HEADSET, AudioSystem.DEVICE_IN_USB_HEADSET)821 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_USB_HEADSET, AudioSystem.DEVICE_IN_USB_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_FM_TUNER, AudioSystem.DEVICE_IN_FM_TUNER)822 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_FM_TUNER, AudioSystem.DEVICE_IN_FM_TUNER); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_TV_TUNER, AudioSystem.DEVICE_IN_TV_TUNER)823 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_TV_TUNER, AudioSystem.DEVICE_IN_TV_TUNER); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_LINE_ANALOG, AudioSystem.DEVICE_IN_LINE)824 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_LINE_ANALOG, AudioSystem.DEVICE_IN_LINE); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_LINE_DIGITAL, AudioSystem.DEVICE_IN_SPDIF)825 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_LINE_DIGITAL, AudioSystem.DEVICE_IN_SPDIF); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_BLUETOOTH_A2DP, AudioSystem.DEVICE_IN_BLUETOOTH_A2DP)826 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 827 TYPE_BLUETOOTH_A2DP, AudioSystem.DEVICE_IN_BLUETOOTH_A2DP); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_IN_IP)828 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_IN_IP); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BUS, AudioSystem.DEVICE_IN_BUS)829 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BUS, AudioSystem.DEVICE_IN_BUS); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_REMOTE_SUBMIX, AudioSystem.DEVICE_IN_REMOTE_SUBMIX)830 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 831 TYPE_REMOTE_SUBMIX, AudioSystem.DEVICE_IN_REMOTE_SUBMIX); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BLE_HEADSET, AudioSystem.DEVICE_IN_BLE_HEADSET)832 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_BLE_HEADSET, AudioSystem.DEVICE_IN_BLE_HEADSET); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI_ARC, AudioSystem.DEVICE_IN_HDMI_ARC)833 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI_ARC, AudioSystem.DEVICE_IN_HDMI_ARC); EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI_EARC, AudioSystem.DEVICE_IN_HDMI_EARC)834 EXT_TO_INT_INPUT_DEVICE_MAPPING.put(TYPE_HDMI_EARC, AudioSystem.DEVICE_IN_HDMI_EARC); EXT_TO_INT_INPUT_DEVICE_MAPPING.put( TYPE_ECHO_REFERENCE, AudioSystem.DEVICE_IN_ECHO_REFERENCE)835 EXT_TO_INT_INPUT_DEVICE_MAPPING.put( 836 TYPE_ECHO_REFERENCE, AudioSystem.DEVICE_IN_ECHO_REFERENCE); 837 838 } 839 } 840 841