Loading media/java/android/media/AudioDevicePort.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioDevicePort is a specialized type of AudioPort * describing an input (e.g microphone) or output device (e.g speaker) * of the system. * An AudioDevicePort is an AudioPort controlled by the audio HAL, almost always a physical * device at the boundary of the audio system. * In addition to base audio port attributes, the device descriptor contains: * - the device type (e.g AudioManager.DEVICE_OUT_SPEAKER) * - the device address (e.g MAC adddress for AD2P sink). * @see AudioPort * @hide */ public class AudioDevicePort extends AudioPort { private final int mType; private final String mAddress; AudioDevicePort(AudioHandle handle, int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains, int type, String address) { super(handle, (AudioManager.isInputDevice(type) == true) ? AudioPort.ROLE_SOURCE : AudioPort.ROLE_SINK, samplingRates, channelMasks, formats, gains); mType = type; mAddress = address; } /** * Get the device type (e.g AudioManager.DEVICE_OUT_SPEAKER) */ public int type() { return mType; } /** * Get the device address. Address format varies with the device type. * - USB devices ({@link AudioManager#DEVICE_OUT_USB_DEVICE}, * {@link AudioManager#DEVICE_IN_USB_DEVICE}) use an address composed of the ALSA card number * and device number: "card=2;device=1" * - Bluetooth devices ({@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO}, * {@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO}, {@link AudioManager#DEVICE_OUT_BLUETOOTH_A2DP}) * use the MAC address of the bluetooth device in the form "00:11:22:AA:BB:CC" as reported by * {@link BluetoothDevice#getAddress()}. * - Deivces that do not have an address will indicate an empty string "". */ public String address() { return mAddress; } /** * Build a specific configuration of this audio device port for use by methods * like AudioManager.connectAudioPatch(). */ public AudioDevicePortConfig buildConfig(int samplingRate, int channelMask, int format, AudioGainConfig gain) { return new AudioDevicePortConfig(this, samplingRate, channelMask, format, gain); } @Override public boolean equals(Object o) { if (o == null || !(o instanceof AudioDevicePort)) { return false; } return super.equals(o); } } media/java/android/media/AudioDevicePortConfig.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * An AudioDevicePortConfig describes a possible configuration of an output or input device * (speaker, headphone, microphone ...). * It is used to specify a sink or source when creating a connection with * AudioManager.connectAudioPatch(). * An AudioDevicePortConfig is obtained from AudioDevicePort.buildConfig(). * @hide */ public class AudioDevicePortConfig extends AudioPortConfig { AudioDevicePortConfig(AudioDevicePort devicePort, int samplingRate, int channelMask, int format, AudioGainConfig gain) { super((AudioPort)devicePort, samplingRate, channelMask, format, gain); } /** * Returns the audio device port this AudioDevicePortConfig is issued from. */ public AudioDevicePort port() { return (AudioDevicePort)mPort; } } media/java/android/media/AudioGain.java 0 → 100644 +159 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioGain describes a gain controller. Gain controllers are exposed by * audio ports when the gain is configurable at this port's input or output. * Gain values are expressed in millibels. * A gain controller has the following attributes: * - mode: defines modes of operation or features * MODE_JOINT: all channel gains are controlled simultaneously * MODE_CHANNELS: each channel gain is controlled individually * MODE_RAMP: ramps can be applied when gain changes * - channel mask: indicates for which channels the gain can be controlled * - min value: minimum gain value in millibel * - max value: maximum gain value in millibel * - default value: gain value after reset in millibel * - step value: granularity of gain control in millibel * - min ramp duration: minimum ramp duration in milliseconds * - max ramp duration: maximum ramp duration in milliseconds * * This object is always created by the framework and read only by applications. * Applications get a list of AudioGainDescriptors from AudioPortDescriptor.gains() and can build a * valid gain configuration from AudioGain.buildConfig() * @hide */ public class AudioGain { /** * Bit of AudioGain.mode() field indicating that * all channel gains are controlled simultaneously */ public static final int MODE_JOINT = 1; /** * Bit of AudioGain.mode() field indicating that * each channel gain is controlled individually */ public static final int MODE_CHANNELS = 2; /** * Bit of AudioGain.mode() field indicating that * ramps can be applied when gain changes. The type of ramp (linear, log etc...) is * implementation specific. */ public static final int MODE_RAMP = 4; private final int mIndex; private final int mMode; private final int mChannelMask; private final int mMinValue; private final int mMaxValue; private final int mDefaultValue; private final int mStepValue; private final int mRampDurationMinMs; private final int mRampDurationMaxMs; // The channel mask passed to the constructor is as specified in AudioFormat // (e.g. AudioFormat.CHANNEL_OUT_STEREO) AudioGain(int index, int mode, int channelMask, int minValue, int maxValue, int defaultValue, int stepValue, int rampDurationMinMs, int rampDurationMaxMs) { mIndex = index; mMode = mode; mChannelMask = channelMask; mMinValue = minValue; mMaxValue = maxValue; mDefaultValue = defaultValue; mStepValue = stepValue; mRampDurationMinMs = rampDurationMinMs; mRampDurationMaxMs = rampDurationMaxMs; } /** * Bit field indicating supported modes of operation */ public int mode() { return mMode; } /** * Indicates for which channels the gain can be controlled * (e.g. AudioFormat.CHANNEL_OUT_STEREO) */ public int channelMask() { return mChannelMask; } /** * Minimum gain value in millibel */ public int minValue() { return mMinValue; } /** * Maximum gain value in millibel */ public int maxValue() { return mMaxValue; } /** * Default gain value in millibel */ public int defaultValue() { return mDefaultValue; } /** * Granularity of gain control in millibel */ public int stepValue() { return mStepValue; } /** * Minimum ramp duration in milliseconds * 0 if MODE_RAMP not set */ public int rampDurationMinMs() { return mRampDurationMinMs; } /** * Maximum ramp duration in milliseconds * 0 if MODE_RAMP not set */ public int rampDurationMaxMs() { return mRampDurationMaxMs; } /** * Build a valid gain configuration for this gain controller for use by * AudioPortDescriptor.setGain() * @param mode: desired mode of operation * @param channelMask: channels of which the gain should be modified. * @param values: gain values for each channels. * @param rampDurationMs: ramp duration if mode MODE_RAMP is set. * ignored if MODE_JOINT. */ public AudioGainConfig buildConfig(int mode, int channelMask, int[] values, int rampDurationMs) { //TODO: check params here return new AudioGainConfig(mIndex, this, mode, channelMask, values, rampDurationMs); } } media/java/android/media/AudioGainConfig.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioGainConfig is used by APIs setting or getting values on a given gain * controller. It contains a valid configuration (value, channels...) for a gain controller * exposed by an audio port. * @see AudioGain * @see AudioPort * @hide */ public class AudioGainConfig { AudioGain mGain; private final int mIndex; private final int mMode; private final int mChannelMask; private final int mValues[]; private final int mRampDurationMs; AudioGainConfig(int index, AudioGain gain, int mode, int channelMask, int[] values, int rampDurationMs) { mIndex = index; mGain = gain; mMode = mode; mChannelMask = channelMask; mValues = values; mRampDurationMs = rampDurationMs; } /** * get the index of the parent gain. * frameworks use only. */ int index() { return mIndex; } /** * Bit field indicating requested modes of operation. See {@link AudioGain#MODE_JOINT}, * {@link AudioGain#MODE_CHANNELS}, {@link AudioGain#MODE_RAMP} */ public int mode() { return mMode; } /** * Indicates for which channels the gain is set. * See {@link AudioFormat#CHANNEL_OUT_STEREO}, {@link AudioFormat#CHANNEL_OUT_MONO} ... */ public int channelMask() { return mChannelMask; } /** * Gain values for each channel in the order of bits set in * channelMask() from LSB to MSB */ public int[] values() { return mValues; } /** * Ramp duration in milliseconds. N/A if mode() does not * specify MODE_RAMP. */ public int rampDurationMs() { return mRampDurationMs; } } media/java/android/media/AudioHandle.java 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioHandle is used by the audio framework implementation to * uniquely identify a particular component of the routing topology * (AudioPort or AudioPatch) * It is not visible or used at the API. */ class AudioHandle { private final int mId; AudioHandle(int id) { mId = id; } int id() { return mId; } @Override public boolean equals(Object o) { if (o == null || !(o instanceof AudioHandle)) { return false; } AudioHandle ah = (AudioHandle)o; return mId == ah.id(); } @Override public int hashCode() { return mId; } } Loading
media/java/android/media/AudioDevicePort.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioDevicePort is a specialized type of AudioPort * describing an input (e.g microphone) or output device (e.g speaker) * of the system. * An AudioDevicePort is an AudioPort controlled by the audio HAL, almost always a physical * device at the boundary of the audio system. * In addition to base audio port attributes, the device descriptor contains: * - the device type (e.g AudioManager.DEVICE_OUT_SPEAKER) * - the device address (e.g MAC adddress for AD2P sink). * @see AudioPort * @hide */ public class AudioDevicePort extends AudioPort { private final int mType; private final String mAddress; AudioDevicePort(AudioHandle handle, int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains, int type, String address) { super(handle, (AudioManager.isInputDevice(type) == true) ? AudioPort.ROLE_SOURCE : AudioPort.ROLE_SINK, samplingRates, channelMasks, formats, gains); mType = type; mAddress = address; } /** * Get the device type (e.g AudioManager.DEVICE_OUT_SPEAKER) */ public int type() { return mType; } /** * Get the device address. Address format varies with the device type. * - USB devices ({@link AudioManager#DEVICE_OUT_USB_DEVICE}, * {@link AudioManager#DEVICE_IN_USB_DEVICE}) use an address composed of the ALSA card number * and device number: "card=2;device=1" * - Bluetooth devices ({@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO}, * {@link AudioManager#DEVICE_OUT_BLUETOOTH_SCO}, {@link AudioManager#DEVICE_OUT_BLUETOOTH_A2DP}) * use the MAC address of the bluetooth device in the form "00:11:22:AA:BB:CC" as reported by * {@link BluetoothDevice#getAddress()}. * - Deivces that do not have an address will indicate an empty string "". */ public String address() { return mAddress; } /** * Build a specific configuration of this audio device port for use by methods * like AudioManager.connectAudioPatch(). */ public AudioDevicePortConfig buildConfig(int samplingRate, int channelMask, int format, AudioGainConfig gain) { return new AudioDevicePortConfig(this, samplingRate, channelMask, format, gain); } @Override public boolean equals(Object o) { if (o == null || !(o instanceof AudioDevicePort)) { return false; } return super.equals(o); } }
media/java/android/media/AudioDevicePortConfig.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * An AudioDevicePortConfig describes a possible configuration of an output or input device * (speaker, headphone, microphone ...). * It is used to specify a sink or source when creating a connection with * AudioManager.connectAudioPatch(). * An AudioDevicePortConfig is obtained from AudioDevicePort.buildConfig(). * @hide */ public class AudioDevicePortConfig extends AudioPortConfig { AudioDevicePortConfig(AudioDevicePort devicePort, int samplingRate, int channelMask, int format, AudioGainConfig gain) { super((AudioPort)devicePort, samplingRate, channelMask, format, gain); } /** * Returns the audio device port this AudioDevicePortConfig is issued from. */ public AudioDevicePort port() { return (AudioDevicePort)mPort; } }
media/java/android/media/AudioGain.java 0 → 100644 +159 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioGain describes a gain controller. Gain controllers are exposed by * audio ports when the gain is configurable at this port's input or output. * Gain values are expressed in millibels. * A gain controller has the following attributes: * - mode: defines modes of operation or features * MODE_JOINT: all channel gains are controlled simultaneously * MODE_CHANNELS: each channel gain is controlled individually * MODE_RAMP: ramps can be applied when gain changes * - channel mask: indicates for which channels the gain can be controlled * - min value: minimum gain value in millibel * - max value: maximum gain value in millibel * - default value: gain value after reset in millibel * - step value: granularity of gain control in millibel * - min ramp duration: minimum ramp duration in milliseconds * - max ramp duration: maximum ramp duration in milliseconds * * This object is always created by the framework and read only by applications. * Applications get a list of AudioGainDescriptors from AudioPortDescriptor.gains() and can build a * valid gain configuration from AudioGain.buildConfig() * @hide */ public class AudioGain { /** * Bit of AudioGain.mode() field indicating that * all channel gains are controlled simultaneously */ public static final int MODE_JOINT = 1; /** * Bit of AudioGain.mode() field indicating that * each channel gain is controlled individually */ public static final int MODE_CHANNELS = 2; /** * Bit of AudioGain.mode() field indicating that * ramps can be applied when gain changes. The type of ramp (linear, log etc...) is * implementation specific. */ public static final int MODE_RAMP = 4; private final int mIndex; private final int mMode; private final int mChannelMask; private final int mMinValue; private final int mMaxValue; private final int mDefaultValue; private final int mStepValue; private final int mRampDurationMinMs; private final int mRampDurationMaxMs; // The channel mask passed to the constructor is as specified in AudioFormat // (e.g. AudioFormat.CHANNEL_OUT_STEREO) AudioGain(int index, int mode, int channelMask, int minValue, int maxValue, int defaultValue, int stepValue, int rampDurationMinMs, int rampDurationMaxMs) { mIndex = index; mMode = mode; mChannelMask = channelMask; mMinValue = minValue; mMaxValue = maxValue; mDefaultValue = defaultValue; mStepValue = stepValue; mRampDurationMinMs = rampDurationMinMs; mRampDurationMaxMs = rampDurationMaxMs; } /** * Bit field indicating supported modes of operation */ public int mode() { return mMode; } /** * Indicates for which channels the gain can be controlled * (e.g. AudioFormat.CHANNEL_OUT_STEREO) */ public int channelMask() { return mChannelMask; } /** * Minimum gain value in millibel */ public int minValue() { return mMinValue; } /** * Maximum gain value in millibel */ public int maxValue() { return mMaxValue; } /** * Default gain value in millibel */ public int defaultValue() { return mDefaultValue; } /** * Granularity of gain control in millibel */ public int stepValue() { return mStepValue; } /** * Minimum ramp duration in milliseconds * 0 if MODE_RAMP not set */ public int rampDurationMinMs() { return mRampDurationMinMs; } /** * Maximum ramp duration in milliseconds * 0 if MODE_RAMP not set */ public int rampDurationMaxMs() { return mRampDurationMaxMs; } /** * Build a valid gain configuration for this gain controller for use by * AudioPortDescriptor.setGain() * @param mode: desired mode of operation * @param channelMask: channels of which the gain should be modified. * @param values: gain values for each channels. * @param rampDurationMs: ramp duration if mode MODE_RAMP is set. * ignored if MODE_JOINT. */ public AudioGainConfig buildConfig(int mode, int channelMask, int[] values, int rampDurationMs) { //TODO: check params here return new AudioGainConfig(mIndex, this, mode, channelMask, values, rampDurationMs); } }
media/java/android/media/AudioGainConfig.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioGainConfig is used by APIs setting or getting values on a given gain * controller. It contains a valid configuration (value, channels...) for a gain controller * exposed by an audio port. * @see AudioGain * @see AudioPort * @hide */ public class AudioGainConfig { AudioGain mGain; private final int mIndex; private final int mMode; private final int mChannelMask; private final int mValues[]; private final int mRampDurationMs; AudioGainConfig(int index, AudioGain gain, int mode, int channelMask, int[] values, int rampDurationMs) { mIndex = index; mGain = gain; mMode = mode; mChannelMask = channelMask; mValues = values; mRampDurationMs = rampDurationMs; } /** * get the index of the parent gain. * frameworks use only. */ int index() { return mIndex; } /** * Bit field indicating requested modes of operation. See {@link AudioGain#MODE_JOINT}, * {@link AudioGain#MODE_CHANNELS}, {@link AudioGain#MODE_RAMP} */ public int mode() { return mMode; } /** * Indicates for which channels the gain is set. * See {@link AudioFormat#CHANNEL_OUT_STEREO}, {@link AudioFormat#CHANNEL_OUT_MONO} ... */ public int channelMask() { return mChannelMask; } /** * Gain values for each channel in the order of bits set in * channelMask() from LSB to MSB */ public int[] values() { return mValues; } /** * Ramp duration in milliseconds. N/A if mode() does not * specify MODE_RAMP. */ public int rampDurationMs() { return mRampDurationMs; } }
media/java/android/media/AudioHandle.java 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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 and * limitations under the License. */ package android.media; /** * The AudioHandle is used by the audio framework implementation to * uniquely identify a particular component of the routing topology * (AudioPort or AudioPatch) * It is not visible or used at the API. */ class AudioHandle { private final int mId; AudioHandle(int id) { mId = id; } int id() { return mId; } @Override public boolean equals(Object o) { if (o == null || !(o instanceof AudioHandle)) { return false; } AudioHandle ah = (AudioHandle)o; return mId == ah.id(); } @Override public int hashCode() { return mId; } }