renamed UsbAudioDevice.java to UsbAlsaDevice.java

Test: Manual, build, run... AOK.

Change-Id: Iba43f94fd74aad826891534c648e61db0d0423b2
This commit is contained in:
Paul McLean
2018-01-31 13:03:02 -07:00
parent 64b7ccee7f
commit 50c00924d8
2 changed files with 39 additions and 32 deletions

View File

@@ -10,14 +10,17 @@
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions an
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.usb;
public final class UsbAudioDevice {
private static final String TAG = "UsbAudioDevice";
/**
* Represents an instance of an Alsa-supported USB peripheral.
*/
public final class UsbAlsaDevice {
private static final String TAG = "UsbAlsaDevice";
protected static final boolean DEBUG = false;
public final int mCard;
@@ -26,20 +29,20 @@ public final class UsbAudioDevice {
public final boolean mHasCapture;
// Device "class" flags
public static final int kAudioDeviceClassMask = 0x00FFFFFF;
public static final int kAudioDeviceClass_Undefined = 0x00000000;
public static final int kAudioDeviceClass_Internal = 0x00000001;
public static final int kAudioDeviceClass_External = 0x00000002;
static final int AUDIO_DEVICE_CLASS_MASK = 0x00FFFFFF;
static final int AUDIO_DEVICE_CLASS_UNDEFINED = 0x00000000;
static final int AUDIO_DEVICE_CLASS_INTERNAL = 0x00000001;
static final int AUDIO_DEVICE_CLASS_EXTERNAL = 0x00000002;
// Device meta-data flags
public static final int kAudioDeviceMetaMask = 0xFF000000;
public static final int kAudioDeviceMeta_Alsa = 0x80000000;
static final int AUDIO_DEVICE_META_MASK = 0xFF000000;
static final int AUDIO_DEVICE_META_ALSA = 0x80000000;
// This member is a combination of the above bit-flags
public final int mDeviceClass;
private String mDeviceName = "";
private String mDeviceDescription = "";
public UsbAudioDevice(int card, int device,
public UsbAlsaDevice(int card, int device,
boolean hasPlayback, boolean hasCapture, int deviceClass) {
mCard = card;
mDevice = device;
@@ -48,9 +51,13 @@ public final class UsbAudioDevice {
mDeviceClass = deviceClass;
}
/**
* @Override
* @return a String representation of the object.
*/
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("UsbAudioDevice: [card: " + mCard);
sb.append("UsbAlsaDevice: [card: " + mCard);
sb.append(", device: " + mDevice);
sb.append(", name: " + mDeviceName);
sb.append(", hasPlayback: " + mHasPlayback);

View File

@@ -62,8 +62,8 @@ public final class UsbAlsaManager {
// this is needed to map USB devices to ALSA Audio Devices, especially to remove an
// ALSA device when we are notified that its associated USB device has been removed.
private final HashMap<UsbDevice,UsbAudioDevice>
mAudioDevices = new HashMap<UsbDevice,UsbAudioDevice>();
private final HashMap<UsbDevice, UsbAlsaDevice>
mAudioDevices = new HashMap<UsbDevice, UsbAlsaDevice>();
private boolean mIsInputHeadset; // as reported by UsbDescriptorParser
private boolean mIsOutputHeadset; // as reported by UsbDescriptorParser
@@ -74,7 +74,7 @@ public final class UsbAlsaManager {
private final HashMap<String,AlsaDevice>
mAlsaDevices = new HashMap<String,AlsaDevice>();
private UsbAudioDevice mAccessoryAudioDevice = null;
private UsbAlsaDevice mAccessoryAudioDevice = null;
// UsbMidiDevice for USB peripheral mode (gadget) device
private UsbMidiDevice mPeripheralMidiDevice = null;
@@ -155,7 +155,7 @@ public final class UsbAlsaManager {
// Notifies AudioService when a device is added or removed
// audioDevice - the AudioDevice that was added or removed
// enabled - if true, we're connecting a device (it's arrived), else disconnecting
private void notifyDeviceState(UsbAudioDevice audioDevice, boolean enabled) {
private void notifyDeviceState(UsbAlsaDevice audioDevice, boolean enabled) {
if (DEBUG) {
Slog.d(TAG, "notifyDeviceState " + enabled + " " + audioDevice);
}
@@ -307,7 +307,7 @@ public final class UsbAlsaManager {
/*
* Select the default device of the specified card.
*/
/* package */ UsbAudioDevice selectAudioCard(int card) {
/* package */ UsbAlsaDevice selectAudioCard(int card) {
if (DEBUG) {
Slog.d(TAG, "selectAudioCard() card:" + card
+ " isCardUsb(): " + mCardsParser.isCardUsb(card));
@@ -332,9 +332,9 @@ public final class UsbAlsaManager {
int deviceClass =
(mCardsParser.isCardUsb(card)
? UsbAudioDevice.kAudioDeviceClass_External
: UsbAudioDevice.kAudioDeviceClass_Internal) |
UsbAudioDevice.kAudioDeviceMeta_Alsa;
? UsbAlsaDevice.AUDIO_DEVICE_CLASS_EXTERNAL
: UsbAlsaDevice.AUDIO_DEVICE_CLASS_INTERNAL)
| UsbAlsaDevice.AUDIO_DEVICE_META_ALSA;
// Playback device file needed/present?
if (hasPlayback && (waitForAlsaDevice(card, device, AlsaDevice.TYPE_PLAYBACK) == null)) {
@@ -346,8 +346,8 @@ public final class UsbAlsaManager {
return null;
}
UsbAudioDevice audioDevice =
new UsbAudioDevice(card, device, hasPlayback, hasCapture, deviceClass);
UsbAlsaDevice audioDevice =
new UsbAlsaDevice(card, device, hasPlayback, hasCapture, deviceClass);
AlsaCardsParser.AlsaCardRecord cardRecord = mCardsParser.getCardRecordFor(card);
audioDevice.setDeviceNameAndDescription(cardRecord.mCardName, cardRecord.mCardDescription);
@@ -356,7 +356,7 @@ public final class UsbAlsaManager {
return audioDevice;
}
/* package */ UsbAudioDevice selectDefaultDevice() {
/* package */ UsbAlsaDevice selectDefaultDevice() {
if (DEBUG) {
Slog.d(TAG, "UsbAudioManager.selectDefaultDevice()");
}
@@ -402,7 +402,7 @@ public final class UsbAlsaManager {
+ mCardsParser.isCardUsb(addedCard));
}
if (mCardsParser.isCardUsb(addedCard)) {
UsbAudioDevice audioDevice = selectAudioCard(addedCard);
UsbAlsaDevice audioDevice = selectAudioCard(addedCard);
if (audioDevice != null) {
mAudioDevices.put(usbDevice, audioDevice);
Slog.i(TAG, "USB Audio Device Added: " + audioDevice);
@@ -461,7 +461,7 @@ public final class UsbAlsaManager {
" " + usbDevice.getProductName());
}
UsbAudioDevice audioDevice = mAudioDevices.remove(usbDevice);
UsbAlsaDevice audioDevice = mAudioDevices.remove(usbDevice);
Slog.i(TAG, "USB Audio Device Removed: " + audioDevice);
if (audioDevice != null) {
if (audioDevice.mHasPlayback || audioDevice.mHasCapture) {
@@ -482,8 +482,8 @@ public final class UsbAlsaManager {
Slog.d(TAG, "setAccessoryAudioState " + enabled + " " + card + " " + device);
}
if (enabled) {
mAccessoryAudioDevice = new UsbAudioDevice(card, device, true, false,
UsbAudioDevice.kAudioDeviceClass_External);
mAccessoryAudioDevice = new UsbAlsaDevice(card, device, true, false,
UsbAlsaDevice.AUDIO_DEVICE_CLASS_EXTERNAL);
notifyDeviceState(mAccessoryAudioDevice, true /*enabled*/);
} else if (mAccessoryAudioDevice != null) {
notifyDeviceState(mAccessoryAudioDevice, false /*enabled*/);
@@ -519,9 +519,9 @@ public final class UsbAlsaManager {
//
/*
//import java.util.ArrayList;
public ArrayList<UsbAudioDevice> getConnectedDevices() {
ArrayList<UsbAudioDevice> devices = new ArrayList<UsbAudioDevice>(mAudioDevices.size());
for (HashMap.Entry<UsbDevice,UsbAudioDevice> entry : mAudioDevices.entrySet()) {
public ArrayList<UsbAlsaDevice> getConnectedDevices() {
ArrayList<UsbAlsaDevice> devices = new ArrayList<UsbAlsaDevice>(mAudioDevices.size());
for (HashMap.Entry<UsbDevice,UsbAlsaDevice> entry : mAudioDevices.entrySet()) {
devices.add(entry.getValue());
}
return devices;
@@ -549,10 +549,10 @@ public final class UsbAlsaManager {
/*
public void logDevicesList(String title) {
if (DEBUG) {
for (HashMap.Entry<UsbDevice,UsbAudioDevice> entry : mAudioDevices.entrySet()) {
for (HashMap.Entry<UsbDevice,UsbAlsaDevice> entry : mAudioDevices.entrySet()) {
Slog.i(TAG, "UsbDevice-------------------");
Slog.i(TAG, "" + (entry != null ? entry.getKey() : "[none]"));
Slog.i(TAG, "UsbAudioDevice--------------");
Slog.i(TAG, "UsbAlsaDevice--------------");
Slog.i(TAG, "" + entry.getValue());
}
}
@@ -564,7 +564,7 @@ public final class UsbAlsaManager {
public void logDevices(String title) {
if (DEBUG) {
Slog.i(TAG, title);
for (HashMap.Entry<UsbDevice,UsbAudioDevice> entry : mAudioDevices.entrySet()) {
for (HashMap.Entry<UsbDevice,UsbAlsaDevice> entry : mAudioDevices.entrySet()) {
Slog.i(TAG, entry.getValue().toShortString());
}
}