diff options
Diffstat (limited to 'media/java')
| -rw-r--r-- | media/java/android/media/AudioDeviceInfo.java | 3 | ||||
| -rw-r--r-- | media/java/android/media/AudioDevicePort.java | 4 | ||||
| -rw-r--r-- | media/java/android/media/AudioMixPort.java | 5 | ||||
| -rw-r--r-- | media/java/android/media/AudioPort.java | 13 | ||||
| -rw-r--r-- | media/java/android/media/AudioRecord.java | 15 | ||||
| -rw-r--r-- | media/java/android/media/AudioTrack.java | 13 | ||||
| -rw-r--r-- | media/java/android/mtp/MtpDevice.java | 3 |
7 files changed, 41 insertions, 15 deletions
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java index 431d37e..173d349 100644 --- a/media/java/android/media/AudioDeviceInfo.java +++ b/media/java/android/media/AudioDeviceInfo.java @@ -173,8 +173,7 @@ public final class AudioDeviceInfo { * @see AudioFormat */ public @NonNull int[] getChannelIndexMasks() { - // TODO: implement - return new int[0]; + return mPort.channelIndexMasks(); } /** diff --git a/media/java/android/media/AudioDevicePort.java b/media/java/android/media/AudioDevicePort.java index c078260..aea39a3 100644 --- a/media/java/android/media/AudioDevicePort.java +++ b/media/java/android/media/AudioDevicePort.java @@ -37,12 +37,12 @@ public class AudioDevicePort extends AudioPort { private final String mAddress; AudioDevicePort(AudioHandle handle, String deviceName, - int[] samplingRates, int[] channelMasks, + int[] samplingRates, int[] channelMasks, int[] channelIndexMasks, int[] formats, AudioGain[] gains, int type, String address) { super(handle, (AudioManager.isInputDevice(type) == true) ? AudioPort.ROLE_SOURCE : AudioPort.ROLE_SINK, - deviceName, samplingRates, channelMasks, formats, gains); + deviceName, samplingRates, channelMasks, channelIndexMasks, formats, gains); mType = type; mAddress = address; } diff --git a/media/java/android/media/AudioMixPort.java b/media/java/android/media/AudioMixPort.java index ab55c8d..ba144bf 100644 --- a/media/java/android/media/AudioMixPort.java +++ b/media/java/android/media/AudioMixPort.java @@ -31,9 +31,10 @@ public class AudioMixPort extends AudioPort { private final int mIoHandle; AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName, - int[] samplingRates, int[] channelMasks, + int[] samplingRates, int[] channelMasks, int[] channelIndexMasks, int[] formats, AudioGain[] gains) { - super(handle, role, deviceName, samplingRates, channelMasks, formats, gains); + super(handle, role, deviceName, samplingRates, channelMasks, channelIndexMasks, + formats, gains); mIoHandle = ioHandle; } diff --git a/media/java/android/media/AudioPort.java b/media/java/android/media/AudioPort.java index 7328d7a..19bf51d 100644 --- a/media/java/android/media/AudioPort.java +++ b/media/java/android/media/AudioPort.java @@ -71,12 +71,13 @@ public class AudioPort { private final String mName; private final int[] mSamplingRates; private final int[] mChannelMasks; + private final int[] mChannelIndexMasks; private final int[] mFormats; private final AudioGain[] mGains; private AudioPortConfig mActiveConfig; AudioPort(AudioHandle handle, int role, String name, - int[] samplingRates, int[] channelMasks, + int[] samplingRates, int[] channelMasks, int[] channelIndexMasks, int[] formats, AudioGain[] gains) { mHandle = handle; @@ -84,6 +85,7 @@ public class AudioPort { mName = name; mSamplingRates = samplingRates; mChannelMasks = channelMasks; + mChannelIndexMasks = channelIndexMasks; mFormats = formats; mGains = gains; } @@ -133,6 +135,15 @@ public class AudioPort { } /** + * Get the list of supported channel index mask configurations + * (e.g 0x0003 means 2 channel, 0x000F means 4 channel....) + * Empty array if channel index mask is not relevant for this audio port + */ + public int[] channelIndexMasks() { + return mChannelIndexMasks; + } + + /** * Get the list of supported audio format configurations * (e.g AudioFormat.ENCODING_PCM_16BIT) * Empty array if format is not relevant for this audio port diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 3cbc405..974b62e 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -527,10 +527,11 @@ public class AudioRecord } /** - * @return a new {@link AudioRecord} instance initialized with all the parameters set - * on this <code>Builder</code> + * @return a new {@link AudioRecord} instance successfully initialized with all + * the parameters set on this <code>Builder</code>. * @throws UnsupportedOperationException if the parameters set on the <code>Builder</code> - * were incompatible, or if they are not supported by the device. + * were incompatible, or if they are not supported by the device, + * or if the device was not available. */ public AudioRecord build() throws UnsupportedOperationException { if (mFormat == null) { @@ -564,7 +565,13 @@ public class AudioRecord mBufferSizeInBytes = mFormat.getChannelCount() * mFormat.getBytesPerSample(mFormat.getEncoding()); } - return new AudioRecord(mAttributes, mFormat, mBufferSizeInBytes, mSessionId); + final AudioRecord record = new AudioRecord( + mAttributes, mFormat, mBufferSizeInBytes, mSessionId); + if (record.getState() == STATE_UNINITIALIZED) { + // release is not necessary + throw new UnsupportedOperationException("Cannot create AudioRecord"); + } + return record; } catch (IllegalArgumentException e) { throw new UnsupportedOperationException(e.getMessage()); } diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index f395cb3..62810c6 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -661,9 +661,10 @@ public class AudioTrack /** * Builds an {@link AudioTrack} instance initialized with all the parameters set * on this <code>Builder</code>. - * @return a new {@link AudioTrack} instance. + * @return a new successfully initialized {@link AudioTrack} instance. * @throws UnsupportedOperationException if the parameters set on the <code>Builder</code> - * were incompatible, or if they are not supported by the device. + * were incompatible, or if they are not supported by the device, + * or if the device was not available. */ public @NonNull AudioTrack build() throws UnsupportedOperationException { if (mAttributes == null) { @@ -686,7 +687,13 @@ public class AudioTrack mBufferSizeInBytes = mFormat.getChannelCount() * mFormat.getBytesPerSample(mFormat.getEncoding()); } - return new AudioTrack(mAttributes, mFormat, mBufferSizeInBytes, mMode, mSessionId); + final AudioTrack track = new AudioTrack( + mAttributes, mFormat, mBufferSizeInBytes, mMode, mSessionId); + if (track.getState() == STATE_UNINITIALIZED) { + // release is not necessary + throw new UnsupportedOperationException("Cannot create AudioTrack"); + } + return track; } catch (IllegalArgumentException e) { throw new UnsupportedOperationException(e.getMessage()); } diff --git a/media/java/android/mtp/MtpDevice.java b/media/java/android/mtp/MtpDevice.java index 72dcaa8..a68361b 100644 --- a/media/java/android/mtp/MtpDevice.java +++ b/media/java/android/mtp/MtpDevice.java @@ -132,7 +132,8 @@ public final class MtpDevice { * * @param storageId the storage unit to query * @param format the format of the object to return, or zero for all formats - * @param objectHandle the parent object to query, or zero for the storage root + * @param objectHandle the parent object to query, -1 for the storage root, + * or zero for all objects * @return the object handles */ public int[] getObjectHandles(int storageId, int format, int objectHandle) { |
