summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioAttributes.java45
-rw-r--r--media/java/android/media/AudioDeviceCallback.java20
-rw-r--r--media/java/android/media/AudioDeviceInfo.java2
-rw-r--r--media/java/android/media/AudioFormat.java69
-rw-r--r--media/java/android/media/AudioManager.java50
-rw-r--r--media/java/android/media/AudioRecord.java32
-rw-r--r--media/java/android/media/AudioSystem.java1
-rw-r--r--media/java/android/media/AudioTrack.java57
-rw-r--r--media/java/android/media/midi/package.html4
-rw-r--r--media/java/android/media/tv/ITvInputSessionWrapper.java5
10 files changed, 229 insertions, 56 deletions
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java
index 4526839..0f1be6b 100644
--- a/media/java/android/media/AudioAttributes.java
+++ b/media/java/android/media/AudioAttributes.java
@@ -17,6 +17,7 @@
package android.media;
import android.annotation.IntDef;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -724,6 +725,26 @@ public final class AudioAttributes implements Parcelable {
return USAGE_UNKNOWN;
}
}
+ /**
+ * @hide
+ * CANDIDATE FOR PUBLIC (or at least SYSTEM) API
+ * Returns the stream type matching the given attributes for volume control.
+ * Use this method to derive the stream type needed to configure the volume
+ * control slider in an {@link Activity} with {@link Activity#setVolumeControlStream(int)}.
+ * <BR>Do not use this method to set the stream type on an audio player object
+ * (e.g. {@link AudioTrack}, {@link MediaPlayer}), use <code>AudioAttributes</code> instead.
+ * @param aa non-null AudioAttributes.
+ * @return a valid stream type for <code>Activity</code> or stream volume control that matches
+ * the attributes, or {@link AudioManager#USE_DEFAULT_STREAM_TYPE} if there isn't a direct
+ * match. Note that <code>USE_DEFAULT_STREAM_TYPE</code> is not a valid value
+ * for {@link AudioManager#setStreamVolume(int, int, int)}.
+ */
+ public static int getVolumeControlStream(@NonNull AudioAttributes aa) {
+ if (aa == null) {
+ throw new IllegalArgumentException("Invalid null audio attributes");
+ }
+ return toVolumeStreamType(true /*fromGetVolumeControlStream*/, aa);
+ }
/**
* @hide
@@ -732,13 +753,19 @@ public final class AudioAttributes implements Parcelable {
* @param aa non-null AudioAttributes.
* @return a valid stream type for volume control that matches the attributes.
*/
- public static int toLegacyStreamType(AudioAttributes aa) {
+ public static int toLegacyStreamType(@NonNull AudioAttributes aa) {
+ return toVolumeStreamType(false /*fromGetVolumeControlStream*/, aa);
+ }
+
+ private static int toVolumeStreamType(boolean fromGetVolumeControlStream, AudioAttributes aa) {
// flags to stream type mapping
if ((aa.getFlags() & FLAG_AUDIBILITY_ENFORCED) == FLAG_AUDIBILITY_ENFORCED) {
- return AudioSystem.STREAM_SYSTEM_ENFORCED;
+ return fromGetVolumeControlStream ?
+ AudioSystem.STREAM_SYSTEM : AudioSystem.STREAM_SYSTEM_ENFORCED;
}
if ((aa.getFlags() & FLAG_SCO) == FLAG_SCO) {
- return AudioSystem.STREAM_BLUETOOTH_SCO;
+ return fromGetVolumeControlStream ?
+ AudioSystem.STREAM_VOICE_CALL : AudioSystem.STREAM_BLUETOOTH_SCO;
}
// usage to stream type mapping
@@ -753,7 +780,8 @@ public final class AudioAttributes implements Parcelable {
case USAGE_VOICE_COMMUNICATION:
return AudioSystem.STREAM_VOICE_CALL;
case USAGE_VOICE_COMMUNICATION_SIGNALLING:
- return AudioSystem.STREAM_DTMF;
+ return fromGetVolumeControlStream ?
+ AudioSystem.STREAM_VOICE_CALL : AudioSystem.STREAM_DTMF;
case USAGE_ALARM:
return AudioSystem.STREAM_ALARM;
case USAGE_NOTIFICATION_RINGTONE:
@@ -765,8 +793,15 @@ public final class AudioAttributes implements Parcelable {
case USAGE_NOTIFICATION_EVENT:
return AudioSystem.STREAM_NOTIFICATION;
case USAGE_UNKNOWN:
+ return fromGetVolumeControlStream ?
+ AudioManager.USE_DEFAULT_STREAM_TYPE : AudioSystem.STREAM_MUSIC;
default:
- return AudioSystem.STREAM_MUSIC;
+ if (fromGetVolumeControlStream) {
+ throw new IllegalArgumentException("Unknown usage value " + aa.getUsage() +
+ " in audio attributes");
+ } else {
+ return AudioSystem.STREAM_MUSIC;
+ }
}
}
diff --git a/media/java/android/media/AudioDeviceCallback.java b/media/java/android/media/AudioDeviceCallback.java
index d7fa492..d9f0037 100644
--- a/media/java/android/media/AudioDeviceCallback.java
+++ b/media/java/android/media/AudioDeviceCallback.java
@@ -17,16 +17,24 @@
package android.media;
/**
- * OnAudioDeviceConnectionListener defines the interface for notification listeners in the
- * {@link AudioManager}
+ * AudioDeviceCallback defines the mechanism by which applications can receive notifications
+ * of audio device connection and disconnection events.
+ * @see AudioManager#registerAudioDeviceCallback.
*/
public abstract class AudioDeviceCallback {
/**
- * Called by the {@link AudioManager} to indicate that an audio device has been
- * connected or disconnected. A listener will probably call the
- * {@link AudioManager#getDevices} method to retrieve the current list of audio
- * devices.
+ * Called by the {@link AudioManager} to indicate that one or more audio devices have been
+ * connected.
+ * @param addedDevices An array of {@link AudioDeviceInfo} objects corresponding to any
+ * newly added audio devices.
*/
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {}
+
+ /**
+ * Called by the {@link AudioManager} to indicate that one or more audio devices have been
+ * disconnected.
+ * @param removedDevices An array of {@link AudioDeviceInfo} objects corresponding to any
+ * newly removed audio devices.
+ */
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {}
}
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java
index 2099bd0..431d37e 100644
--- a/media/java/android/media/AudioDeviceInfo.java
+++ b/media/java/android/media/AudioDeviceInfo.java
@@ -204,7 +204,7 @@ public final class AudioDeviceInfo {
* @see AudioFormat
*/
public @NonNull int[] getEncodings() {
- return mPort.formats();
+ return AudioFormat.filterPublicFormats(mPort.formats());
}
/**
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java
index a7e092f..16ae58c 100644
--- a/media/java/android/media/AudioFormat.java
+++ b/media/java/android/media/AudioFormat.java
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
/**
* The AudioFormat class is used to access a number of audio format and
@@ -53,6 +54,22 @@ public class AudioFormat {
public static final int ENCODING_DTS = 7;
/** Audio data format: DTS HD compressed */
public static final int ENCODING_DTS_HD = 8;
+ /** Audio data format: MP3 compressed
+ * @hide
+ * */
+ public static final int ENCODING_MP3 = 9;
+ /** Audio data format: AAC LC compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_LC = 10;
+ /** Audio data format: AAC HE V1 compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_HE_V1 = 11;
+ /** Audio data format: AAC HE V2 compressed
+ * @hide
+ * */
+ public static final int ENCODING_AAC_HE_V2 = 12;
/** Invalid audio channel configuration */
/** @deprecated Use {@link #CHANNEL_INVALID} instead. */
@@ -241,6 +258,27 @@ public class AudioFormat {
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
+ case ENCODING_MP3:
+ case ENCODING_AAC_LC:
+ case ENCODING_AAC_HE_V1:
+ case ENCODING_AAC_HE_V2:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /** @hide */
+ public static boolean isPublicEncoding(int audioFormat)
+ {
+ switch (audioFormat) {
+ case ENCODING_PCM_8BIT:
+ case ENCODING_PCM_16BIT:
+ case ENCODING_PCM_FLOAT:
+ case ENCODING_AC3:
+ case ENCODING_E_AC3:
+ case ENCODING_DTS:
+ case ENCODING_DTS_HD:
return true;
default:
return false;
@@ -260,6 +298,10 @@ public class AudioFormat {
case ENCODING_E_AC3:
case ENCODING_DTS:
case ENCODING_DTS_HD:
+ case ENCODING_MP3:
+ case ENCODING_AAC_LC:
+ case ENCODING_AAC_HE_V1:
+ case ENCODING_AAC_HE_V2:
return false;
case ENCODING_INVALID:
default:
@@ -267,6 +309,28 @@ public class AudioFormat {
}
}
+ /**
+ * Returns an array of public encoding values extracted from an array of
+ * encoding values.
+ * @hide
+ */
+ public static int[] filterPublicFormats(int[] formats) {
+ if (formats == null) {
+ return null;
+ }
+ int[] myCopy = Arrays.copyOf(formats, formats.length);
+ int size = 0;
+ for (int i = 0; i < myCopy.length; i++) {
+ if (isPublicEncoding(myCopy[i])) {
+ if (size != i) {
+ myCopy[size] = myCopy[i];
+ }
+ size++;
+ }
+ }
+ return Arrays.copyOf(myCopy, size);
+ }
+
/** @removed */
public AudioFormat()
{
@@ -503,7 +567,7 @@ public class AudioFormat {
* if both channel index mask and channel position mask
* are specified but do not have the same channel count.
*/
- public @NonNull Builder setChannelMask(int channelMask) throws IllegalArgumentException {
+ public @NonNull Builder setChannelMask(int channelMask) {
if (channelMask == 0) {
throw new IllegalArgumentException("Invalid zero channel mask");
} else if (/* channelMask != 0 && */ mChannelIndexMask != 0 &&
@@ -555,8 +619,7 @@ public class AudioFormat {
* if both channel index mask and channel position mask
* are specified but do not have the same channel count.
*/
- public @NonNull Builder setChannelIndexMask(int channelIndexMask)
- throws IllegalArgumentException {
+ public @NonNull Builder setChannelIndexMask(int channelIndexMask) {
if (channelIndexMask == 0) {
throw new IllegalArgumentException("Invalid zero channel index mask");
} else if (/* channelIndexMask != 0 && */ mChannelMask != 0 &&
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index e7013a5..316ccf6 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -3713,11 +3713,18 @@ public class AudioManager {
private final static int MSG_DEVICES_DEVICES_ADDED = 0;
private final static int MSG_DEVICES_DEVICES_REMOVED = 1;
+ /**
+ * The list of {@link AudioDeviceCallback} objects to receive add/remove notifications.
+ */
private ArrayMap<AudioDeviceCallback, NativeEventHandlerDelegate>
mDeviceCallbacks =
new ArrayMap<AudioDeviceCallback, NativeEventHandlerDelegate>();
/**
+ * The following are flags to allow users of {@link AudioManager#getDevices(int)} to filter
+ * the results list to only those device types they are interested in.
+ */
+ /**
* Specifies to the {@link AudioManager#getDevices(int)} method to include
* source (i.e. input) audio devices.
*/
@@ -3747,21 +3754,25 @@ public class AudioManager {
}
/**
- * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
- * connected to the system and meeting the criteria specified in the <code>flags</code>
- * parameter.
+ * Returns an array of {@link AudioDeviceInfo} objects corresponding to the audio devices
+ * currently connected to the system and meeting the criteria specified in the
+ * <code>flags</code> parameter.
* @param flags A set of bitflags specifying the criteria to test.
- * @see {@link GET_DEVICES_OUTPUTS}, {@link GET_DEVICES_INPUTS} and {@lGET_DEVICES_CES_ALL}.
+ * @see {@link GET_DEVICES_OUTPUTS}, {@link GET_DEVICES_INPUTS} and {@link GET_DEVICES_ALL}.
* @return A (possibly zero-length) array of AudioDeviceInfo objects.
*/
public AudioDeviceInfo[] getDevices(int flags) {
return getDevicesStatic(flags);
}
+ /**
+ * Does the actual computation to generate an array of (externally-visible) AudioDeviceInfo
+ * objects from the current (internal) AudioDevicePort list.
+ */
private static AudioDeviceInfo[]
infoListFromPortList(ArrayList<AudioDevicePort> ports, int flags) {
- // figure out how many AudioDeviceInfo we need space for
+ // figure out how many AudioDeviceInfo we need space for...
int numRecs = 0;
for (AudioDevicePort port : ports) {
if (checkFlags(port, flags)) {
@@ -3769,7 +3780,7 @@ public class AudioManager {
}
}
- // Now load them up
+ // Now load them up...
AudioDeviceInfo[] deviceList = new AudioDeviceInfo[numRecs];
int slot = 0;
for (AudioDevicePort port : ports) {
@@ -3782,7 +3793,12 @@ public class AudioManager {
}
/*
- * Calculate the list of ports that are in ports_B, but not in ports_A
+ * Calculate the list of ports that are in ports_B, but not in ports_A. This is used by
+ * the add/remove callback mechanism to provide a list of the newly added or removed devices
+ * rather than the whole list and make the app figure it out.
+ * Note that calling this method with:
+ * ports_A == PREVIOUS_ports and ports_B == CURRENT_ports will calculated ADDED ports.
+ * ports_A == CURRENT_ports and ports_B == PREVIOUS_ports will calculated REMOVED ports.
*/
private static AudioDeviceInfo[] calcListDeltas(
ArrayList<AudioDevicePort> ports_A, ArrayList<AudioDevicePort> ports_B, int flags) {
@@ -3811,6 +3827,7 @@ public class AudioManager {
* Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
* connected to the system and meeting the criteria specified in the <code>flags</code>
* parameter.
+ * This is an internal function. The public API front is getDevices(int).
* @param flags A set of bitflags specifying the criteria to test.
* @see {@link GET_DEVICES_OUTPUTS}, {@link GET_DEVICES_INPUTS} and {@link GET_DEVICES_ALL}.
* @return A (possibly zero-length) array of AudioDeviceInfo objects.
@@ -3821,15 +3838,20 @@ public class AudioManager {
int status = AudioManager.listAudioDevicePorts(ports);
if (status != AudioManager.SUCCESS) {
// fail and bail!
- return new AudioDeviceInfo[0];
+ return new AudioDeviceInfo[0]; // Always return an array.
}
return infoListFromPortList(ports, flags);
}
/**
- * Adds an {@link AudioDeviceCallback} to receive notifications of changes
+ * Registers an {@link AudioDeviceCallback} object to receive notifications of changes
* to the set of connected audio devices.
+ * @param callback The {@link AudioDeviceCallback} object to receive connect/disconnect
+ * notifications.
+ * @param handler Specifies the {@link Handler} object for the thread on which to execute
+ * the callback. If <code>null</code>, the {@link Handler} associated with the main
+ * {@link Looper} will be used.
*/
public void registerAudioDeviceCallback(AudioDeviceCallback callback,
android.os.Handler handler) {
@@ -3842,8 +3864,10 @@ public class AudioManager {
}
/**
- * Removes an {@link AudioDeviceCallback} which has been previously registered
+ * Unregisters an {@link AudioDeviceCallback} object which has been previously registered
* to receive notifications of changes to the set of connected audio devices.
+ * @param callback The {@link AudioDeviceCallback} object that was previously registered
+ * with {@link AudioManager#registerAudioDeviceCallback) to be unregistered.
*/
public void unregisterAudioDeviceCallback(AudioDeviceCallback callback) {
synchronized (mDeviceCallbacks) {
@@ -3854,7 +3878,8 @@ public class AudioManager {
}
/**
- * Sends device list change notification to all listeners.
+ * Internal method to compute and generate add/remove messages and then send to any
+ * registered callbacks.
*/
private void broadcastDeviceListChange() {
int status;
@@ -3908,7 +3933,8 @@ public class AudioManager {
/**
* Callback method called upon audio patch list update.
- * @param patchList the updated list of audio patches
+ * Note: We don't do anything with Patches at this time, so ignore this notification.
+ * @param patchList the updated list of audio patches.
*/
public void onAudioPatchListUpdate(AudioPatch[] patchList) {}
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index c0bc6d6..7eb1357 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -494,7 +494,7 @@ public class AudioRecord
* than this size. See {@link #getMinBufferSize(int, int, int)} to determine the minimum
* required buffer size for the successful creation of an AudioRecord instance.
* Since bufferSizeInBytes may be internally increased to accommodate the source
- * requirements, use {@link #getNativeFrameCount()} to determine the actual buffer size
+ * requirements, use {@link #getBufferSizeInFrames()} to determine the actual buffer size
* in frames.
* @param bufferSizeInBytes a value strictly greater than 0
* @return the same Builder instance.
@@ -777,7 +777,7 @@ public class AudioRecord
}
/**
- * Returns the "native frame count" of the <code>AudioRecord</code> buffer.
+ * Returns the frame count of the native <code>AudioRecord</code> buffer.
* This is greater than or equal to the bufferSizeInBytes converted to frame units
* specified in the <code>AudioRecord</code> constructor or Builder.
* The native frame count may be enlarged to accommodate the requirements of the
@@ -786,8 +786,8 @@ public class AudioRecord
* @return current size in frames of the <code>AudioRecord</code> buffer.
* @throws IllegalStateException
*/
- public int getNativeFrameCount() throws IllegalStateException {
- return native_get_native_frame_count();
+ public int getBufferSizeInFrames() {
+ return native_get_buffer_size_in_frames();
}
/**
@@ -1218,16 +1218,23 @@ public class AudioRecord
//--------------------------------------------------------------------------
// (Re)Routing Info
//--------------------
+ /**
+ * Defines the interface by which applications can receive notifications of routing
+ * changes for the associated {@link AudioRecord}.
+ */
public interface OnRoutingChangedListener {
/**
* Called when the routing of an AudioRecord changes from either and explicit or
- * policy rerouting.
+ * policy rerouting. Use {@link #getRoutedDevice()} to retrieve the newly routed-from
+ * device.
*/
public void onRoutingChanged(AudioRecord audioRecord);
}
/**
* Returns an {@link AudioDeviceInfo} identifying the current routing of this AudioRecord.
+ * Note: The query is only valid if the AudioRecord is currently recording. If it is not,
+ * <code>getRoutedDevice()</code> will return null.
*/
public AudioDeviceInfo getRoutedDevice() {
int deviceId = native_getRoutedDeviceId();
@@ -1245,8 +1252,9 @@ public class AudioRecord
}
/**
- * The message sent to apps when the routing of this AudioRecord changes if they provide
- * a {#link Handler} object to addOnRoutingChangeListener().
+ * The list of AudioRecord.OnRoutingChangedListener interface added (with
+ * {@link AudioRecord#addOnRoutingChangedListener(OnRoutingChangedListener,android.os.Handler)}
+ * by an app to receive (re)routing notifications.
*/
private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
mRoutingChangeListeners =
@@ -1255,6 +1263,11 @@ public class AudioRecord
/**
* Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
* on this AudioRecord.
+ * @param listener The {@link OnRoutingChangedListener} interface to receive notifications
+ * of rerouting events.
+ * @param handler Specifies the {@link Handler} object for the thread on which to execute
+ * the callback. If <code>null</code>, the {@link Handler} associated with the main
+ * {@link Looper} will be used.
*/
public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
android.os.Handler handler) {
@@ -1271,7 +1284,8 @@ public class AudioRecord
/**
* Removes an {@link OnRoutingChangedListener} which has been previously added
- * to receive notifications of changes to the set of connected audio devices.
+ * to receive rerouting notifications.
+ * @param listener The previously added {@link OnRoutingChangedListener} interface to remove.
*/
public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
synchronized (mRoutingChangeListeners) {
@@ -1528,7 +1542,7 @@ public class AudioRecord
private native final int native_read_in_direct_buffer(Object jBuffer,
int sizeInBytes, boolean isBlocking);
- private native final int native_get_native_frame_count();
+ private native final int native_get_buffer_size_in_frames();
private native final int native_set_marker_pos(int marker);
private native final int native_get_marker_pos();
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index ee12374..373f3fd 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -634,6 +634,7 @@ public class AudioSystem
public static native int registerPolicyMixes(ArrayList<AudioMix> mixes, boolean register);
+ public static native int systemReady();
// Items shared with audio service
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index b8bbab0..f76189c 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -229,7 +229,7 @@ public class AudioTrack
/**
* Sizes of the native audio buffer.
* These values are set during construction and can be stale.
- * To obtain the current native audio buffer frame count use {@link #getNativeFrameCount()}.
+ * To obtain the current native audio buffer frame count use {@link #getBufferSizeInFrames()}.
*/
private int mNativeBufferSizeInBytes = 0;
private int mNativeBufferSizeInFrames = 0;
@@ -346,7 +346,7 @@ public class AudioTrack
* If <code>bufferSizeInBytes</code> is less than the
* minimum buffer size for the output sink, it is automatically increased to the minimum
* buffer size.
- * The method {@link #getNativeFrameCount()} returns the
+ * The method {@link #getBufferSizeInFrames()} returns the
* actual size in frames of the native buffer created, which
* determines the frequency to write
* to the streaming <code>AudioTrack</code> to avoid underrun.
@@ -775,7 +775,7 @@ public class AudioTrack
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
}
- if (!AudioFormat.isValidEncoding(audioFormat)) {
+ if (!AudioFormat.isPublicEncoding(audioFormat)) {
throw new IllegalArgumentException("Unsupported audio encoding.");
}
mAudioFormat = audioFormat;
@@ -1009,7 +1009,7 @@ public class AudioTrack
}
/**
- * Returns the "native frame count" of the <code>AudioTrack</code> buffer.
+ * Returns the frame count of the native <code>AudioTrack</code> buffer.
* <p> If the track's creation mode is {@link #MODE_STATIC},
* it is equal to the specified bufferSizeInBytes on construction, converted to frame units.
* A static track's native frame count will not change.
@@ -1019,12 +1019,26 @@ public class AudioTrack
* the target output sink, and
* if the track is subsequently routed to a different output sink, the native
* frame count may enlarge to accommodate.
- * See also {@link AudioManager#getProperty(String)} for key
+ * <p> If the <code>AudioTrack</code> encoding indicates compressed data,
+ * e.g. {@link AudioFormat#ENCODING_AC3}, then the frame count returned is
+ * the size of the native <code>AudioTrack</code> buffer in bytes.
+ * <p> See also {@link AudioManager#getProperty(String)} for key
* {@link AudioManager#PROPERTY_OUTPUT_FRAMES_PER_BUFFER}.
- * @return current size in frames of the audio track buffer.
+ * @return current size in frames of the <code>AudioTrack</code> buffer.
* @throws IllegalStateException
*/
- public int getNativeFrameCount() throws IllegalStateException {
+ public int getBufferSizeInFrames() {
+ return native_get_native_frame_count();
+ }
+
+ /**
+ * Returns the frame count of the native <code>AudioTrack</code> buffer.
+ * @return current size in frames of the <code>AudioTrack</code> buffer.
+ * @throws IllegalStateException
+ * @deprecated Use the identical public method {@link #getBufferSizeInFrames()} instead.
+ */
+ @Deprecated
+ protected int getNativeFrameCount() {
return native_get_native_frame_count();
}
@@ -1119,7 +1133,7 @@ public class AudioTrack
}
}
- if (!AudioFormat.isValidEncoding(audioFormat)) {
+ if (!AudioFormat.isPublicEncoding(audioFormat)) {
loge("getMinBufferSize(): Invalid audio format.");
return ERROR_BAD_VALUE;
}
@@ -1305,6 +1319,9 @@ public class AudioTrack
* The valid sample rate range is from 1 Hz to twice the value returned by
* {@link #getNativeOutputSampleRate(int)}.
* Use {@link #setPlaybackParams(PlaybackParams)} for speed control.
+ * <p> This method may also be used to repurpose an existing <code>AudioTrack</code>
+ * for playback of content of differing sample rate,
+ * but with identical encoding and channel mask.
* @param sampleRateInHz the sample rate expressed in Hz
* @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE},
* {@link #ERROR_INVALID_OPERATION}
@@ -1474,7 +1491,7 @@ public class AudioTrack
* <p>
* If the mode is {@link #MODE_STREAM}, you can optionally prime the data path prior to
* calling play(), by writing up to <code>bufferSizeInBytes</code> (from constructor).
- * If you don’t call write() first, or if you call write() but with an insufficient amount of
+ * If you don't call write() first, or if you call write() but with an insufficient amount of
* data, then the track will be in underrun state at play(). In this case,
* playback will not actually start playing until the data path is filled to a
* device-specific minimum level. This requirement for the path to be filled
@@ -2153,16 +2170,23 @@ public class AudioTrack
//--------------------------------------------------------------------------
// (Re)Routing Info
//--------------------
+ /**
+ * Defines the interface by which applications can receive notifications of routing
+ * changes for the associated {@link AudioTrack}.
+ */
public interface OnRoutingChangedListener {
/**
* Called when the routing of an AudioTrack changes from either and explicit or
- * policy rerouting.
+ * policy rerouting. Use {@link #getRoutedDevice()} to retrieve the newly routed-to
+ * device.
*/
public void onRoutingChanged(AudioTrack audioTrack);
}
/**
* Returns an {@link AudioDeviceInfo} identifying the current routing of this AudioTrack.
+ * Note: The query is only valid if the AudioTrack is currently playing. If it is not,
+ * <code>getRoutedDevice()</code> will return null.
*/
public AudioDeviceInfo getRoutedDevice() {
int deviceId = native_getRoutedDeviceId();
@@ -2180,8 +2204,9 @@ public class AudioTrack
}
/**
- * The message sent to apps when the routing of this AudioTrack changes if they provide
- * a {#link Handler} object to addOnRoutingChangedListener().
+ * The list of AudioTrack.OnRoutingChangedListener interfaces added (with
+ * {@link AudioTrack#addOnRoutingChangedListener(OnRoutingChangedListener, android.os.Handler)}
+ * by an app to receive (re)routing notifications.
*/
private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
mRoutingChangeListeners =
@@ -2190,6 +2215,11 @@ public class AudioTrack
/**
* Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
* on this AudioTrack.
+ * @param listener The {@link OnRoutingChangedListener} interface to receive notifications
+ * of rerouting events.
+ * @param handler Specifies the {@link Handler} object for the thread on which to execute
+ * the callback. If <code>null</code>, the {@link Handler} associated with the main
+ * {@link Looper} will be used.
*/
public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
android.os.Handler handler) {
@@ -2206,7 +2236,8 @@ public class AudioTrack
/**
* Removes an {@link OnRoutingChangedListener} which has been previously added
- * to receive notifications of changes to the set of connected audio devices.
+ * to receive rerouting notifications.
+ * @param listener The previously added {@link OnRoutingChangedListener} interface to remove.
*/
public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
synchronized (mRoutingChangeListeners) {
diff --git a/media/java/android/media/midi/package.html b/media/java/android/media/midi/package.html
index 8850e6f..bd589a9 100644
--- a/media/java/android/media/midi/package.html
+++ b/media/java/android/media/midi/package.html
@@ -235,9 +235,7 @@ outputPort.connect(new MyReceiver());
<p>The data that arrives is not validated or aligned in any particular way. It is
raw MIDI data and can contain multiple messages or partial messages. It might
contain System Real-Time messages, which can be interleaved inside other
-messages. Some applications have their own MIDI parsers so pre-parsing the data
-would be redundant. If an application wants the data parsed and aligned then
-they can use the MidiFramer utility.</p>
+messages.</p>
<h1 id=creating_a_midi_virtual_device_service>Creating a MIDI Virtual Device Service</h1>
diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java
index 66b904b..fed0ddf 100644
--- a/media/java/android/media/tv/ITvInputSessionWrapper.java
+++ b/media/java/android/media/tv/ITvInputSessionWrapper.java
@@ -173,10 +173,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
break;
}
case DO_TIME_SHIFT_SET_PLAYBACK_PARAMS: {
- PlaybackParams params = new PlaybackParams()
- .setSpeed((Float) msg.obj)
- .setAudioFallbackMode(msg.arg1);
- mTvInputSessionImpl.timeShiftSetPlaybackParams(params);
+ mTvInputSessionImpl.timeShiftSetPlaybackParams((PlaybackParams) msg.obj);
break;
}
case DO_TIME_SHIFT_ENABLE_POSITION_TRACKING: {