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 an 14 * limitations under the License. 15 */ 16 17 package com.android.server.usb; 18 19 public final class UsbAudioDevice { 20 private static final String TAG = "UsbAudioDevice"; 21 protected static final boolean DEBUG = false; 22 23 public int mCard; 24 public int mDevice; 25 public boolean mHasPlayback; 26 public boolean mHasCapture; 27 28 // Device "class" flags 29 public static final int kAudioDeviceClassMask = 0x00FFFFFF; 30 public static final int kAudioDeviceClass_Undefined = 0x00000000; 31 public static final int kAudioDeviceClass_Internal = 0x00000001; 32 public static final int kAudioDeviceClass_External = 0x00000002; 33 // Device meta-data flags 34 public static final int kAudioDeviceMetaMask = 0xFF000000; 35 public static final int kAudioDeviceMeta_Alsa = 0x80000000; 36 // This member is a combination of the above bit-flags 37 public int mDeviceClass; 38 39 public String mDeviceName = ""; 40 public String mDeviceDescription = ""; 41 42 public UsbAudioDevice(int card, int device, 43 boolean hasPlayback, boolean hasCapture, int deviceClass) { 44 mCard = card; 45 mDevice = device; 46 mHasPlayback = hasPlayback; 47 mHasCapture = hasCapture; 48 mDeviceClass = deviceClass; 49 } 50 51 public String toString() { 52 StringBuilder sb = new StringBuilder(); 53 sb.append("UsbAudioDevice: [card: " + mCard); 54 sb.append(", device: " + mDevice); 55 sb.append(", name: " + mDeviceName); 56 sb.append(", hasPlayback: " + mHasPlayback); 57 sb.append(", hasCapture: " + mHasCapture); 58 sb.append(", class: 0x" + Integer.toHexString(mDeviceClass) + "]"); 59 return sb.toString(); 60 } 61 62 public String toShortString() { 63 return "[card:" + mCard + " device:" + mDevice + " " + mDeviceName + "]"; 64 } 65 } 66 67