Merge "Improve toString() methods for audio classes to help with debugging" into lmp-mr1-dev

automerge: ac7d8c5

* commit 'ac7d8c5cc85dc5929b5d1c9d7836aca58a4e9ea5':
  Improve toString() methods for audio classes to help with debugging
This commit is contained in:
Mike Lockwood
2014-10-27 22:18:05 +00:00
committed by android-build-merger
4 changed files with 114 additions and 5 deletions

View File

@@ -16,6 +16,8 @@
package android.media;
import android.media.AudioSystem;
/**
* The AudioDevicePort is a specialized type of AudioPort
* describing an input (e.g microphone) or output device (e.g speaker)
@@ -85,8 +87,11 @@ public class AudioDevicePort extends AudioPort {
@Override
public String toString() {
String type = (mRole == ROLE_SOURCE ?
AudioSystem.getInputDeviceName(mType) :
AudioSystem.getOutputDeviceName(mType));
return "{" + super.toString()
+ ", mType:" + mType
+ ", mType: " + type
+ ", mAddress: " + mAddress
+ "}";
}

View File

@@ -52,4 +52,25 @@ public class AudioPatch {
public AudioPortConfig[] sinks() {
return mSinks;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("mHandle: ");
s.append(mHandle.toString());
s.append(" mSources: {");
for (AudioPortConfig source : mSources) {
s.append(source.toString());
s.append(", ");
}
s.append("} mSinks: {");
for (AudioPortConfig sink : mSinks) {
s.append(sink.toString());
s.append(", ");
}
s.append("}");
return s.toString();
}
}

View File

@@ -67,7 +67,7 @@ public class AudioPort {
AudioHandle mHandle;
private final int mRole;
protected final int mRole;
private final int[] mSamplingRates;
private final int[] mChannelMasks;
private final int[] mFormats;
@@ -176,8 +176,20 @@ public class AudioPort {
@Override
public String toString() {
return "{mHandle:" + mHandle
+ ", mRole:" + mRole
String role = Integer.toString(mRole);
switch (mRole) {
case ROLE_NONE:
role = "NONE";
break;
case ROLE_SOURCE:
role = "SOURCE";
break;
case ROLE_SINK:
role = "SINK";
break;
}
return "{mHandle: " + mHandle
+ ", mRole: " + role
+ "}";
}
}

View File

@@ -255,6 +255,7 @@ public class AudioSystem
public static final int DEVICE_OUT_SPDIF = 0x80000;
public static final int DEVICE_OUT_FM = 0x100000;
public static final int DEVICE_OUT_AUX_LINE = 0x200000;
public static final int DEVICE_OUT_SPEAKER_SAFE = 0x400000;
public static final int DEVICE_OUT_DEFAULT = DEVICE_BIT_DEFAULT;
@@ -280,6 +281,7 @@ public class AudioSystem
DEVICE_OUT_SPDIF |
DEVICE_OUT_FM |
DEVICE_OUT_AUX_LINE |
DEVICE_OUT_SPEAKER_SAFE |
DEVICE_OUT_DEFAULT);
public static final int DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP |
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
@@ -372,6 +374,27 @@ public class AudioSystem
public static final String DEVICE_OUT_SPDIF_NAME = "spdif";
public static final String DEVICE_OUT_FM_NAME = "fm_transmitter";
public static final String DEVICE_OUT_AUX_LINE_NAME = "aux_line";
public static final String DEVICE_OUT_SPEAKER_SAFE_NAME = "speaker_safe";
public static final String DEVICE_IN_COMMUNICATION_NAME = "communication";
public static final String DEVICE_IN_AMBIENT_NAME = "ambient";
public static final String DEVICE_IN_BUILTIN_MIC_NAME = "mic";
public static final String DEVICE_IN_BLUETOOTH_SCO_HEADSET_NAME = "bt_sco_hs";
public static final String DEVICE_IN_WIRED_HEADSET_NAME = "headset";
public static final String DEVICE_IN_AUX_DIGITAL_NAME = "aux_digital";
public static final String DEVICE_IN_TELEPHONY_RX_NAME = "telephony_rx";
public static final String DEVICE_IN_BACK_MIC_NAME = "back_mic";
public static final String DEVICE_IN_REMOTE_SUBMIX_NAME = "remote_submix";
public static final String DEVICE_IN_ANLG_DOCK_HEADSET_NAME = "analog_dock";
public static final String DEVICE_IN_DGTL_DOCK_HEADSET_NAME = "digital_dock";
public static final String DEVICE_IN_USB_ACCESSORY_NAME = "usb_accessory";
public static final String DEVICE_IN_USB_DEVICE_NAME = "usb_device";
public static final String DEVICE_IN_FM_TUNER_NAME = "fm_tuner";
public static final String DEVICE_IN_TV_TUNER_NAME = "tv_tuner";
public static final String DEVICE_IN_LINE_NAME = "line";
public static final String DEVICE_IN_SPDIF_NAME = "spdif";
public static final String DEVICE_IN_BLUETOOTH_A2DP_NAME = "bt_a2dp";
public static final String DEVICE_IN_LOOPBACK_NAME = "loopback";
public static String getOutputDeviceName(int device)
{
@@ -420,12 +443,60 @@ public class AudioSystem
return DEVICE_OUT_FM_NAME;
case DEVICE_OUT_AUX_LINE:
return DEVICE_OUT_AUX_LINE_NAME;
case DEVICE_OUT_SPEAKER_SAFE:
return DEVICE_OUT_SPEAKER_SAFE_NAME;
case DEVICE_OUT_DEFAULT:
default:
return "";
return Integer.toString(device);
}
}
public static String getInputDeviceName(int device)
{
switch(device) {
case DEVICE_IN_COMMUNICATION:
return DEVICE_IN_COMMUNICATION_NAME;
case DEVICE_IN_AMBIENT:
return DEVICE_IN_AMBIENT_NAME;
case DEVICE_IN_BUILTIN_MIC:
return DEVICE_IN_BUILTIN_MIC_NAME;
case DEVICE_IN_BLUETOOTH_SCO_HEADSET:
return DEVICE_IN_BLUETOOTH_SCO_HEADSET_NAME;
case DEVICE_IN_WIRED_HEADSET:
return DEVICE_IN_WIRED_HEADSET_NAME;
case DEVICE_IN_AUX_DIGITAL:
return DEVICE_IN_AUX_DIGITAL_NAME;
case DEVICE_IN_TELEPHONY_RX:
return DEVICE_IN_TELEPHONY_RX_NAME;
case DEVICE_IN_BACK_MIC:
return DEVICE_IN_BACK_MIC_NAME;
case DEVICE_IN_REMOTE_SUBMIX:
return DEVICE_IN_REMOTE_SUBMIX_NAME;
case DEVICE_IN_ANLG_DOCK_HEADSET:
return DEVICE_IN_ANLG_DOCK_HEADSET_NAME;
case DEVICE_IN_DGTL_DOCK_HEADSET:
return DEVICE_IN_DGTL_DOCK_HEADSET_NAME;
case DEVICE_IN_USB_ACCESSORY:
return DEVICE_IN_USB_ACCESSORY_NAME;
case DEVICE_IN_USB_DEVICE:
return DEVICE_IN_USB_DEVICE_NAME;
case DEVICE_IN_FM_TUNER:
return DEVICE_IN_FM_TUNER_NAME;
case DEVICE_IN_TV_TUNER:
return DEVICE_IN_TV_TUNER_NAME;
case DEVICE_IN_LINE:
return DEVICE_IN_LINE_NAME;
case DEVICE_IN_SPDIF:
return DEVICE_IN_SPDIF_NAME;
case DEVICE_IN_BLUETOOTH_A2DP:
return DEVICE_IN_BLUETOOTH_A2DP_NAME;
case DEVICE_IN_LOOPBACK:
return DEVICE_IN_LOOPBACK_NAME;
case DEVICE_IN_DEFAULT:
default:
return Integer.toString(device);
}
}
// phone state, match audio_mode???
public static final int PHONE_STATE_OFFCALL = 0;