Loading api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -13739,7 +13739,9 @@ package android.media { field public static final int CHANNEL_OUT_QUAD = 204; // 0xcc field public static final int CHANNEL_OUT_STEREO = 12; // 0xc field public static final int CHANNEL_OUT_SURROUND = 1052; // 0x41c field public static final int ENCODING_AC3 = 5; // 0x5 field public static final int ENCODING_DEFAULT = 1; // 0x1 field public static final int ENCODING_E_AC3 = 6; // 0x6 field public static final int ENCODING_INVALID = 0; // 0x0 field public static final int ENCODING_PCM_16BIT = 2; // 0x2 field public static final int ENCODING_PCM_8BIT = 3; // 0x3 Loading Loading @@ -13813,6 +13815,7 @@ package android.media { field public static final int AUDIOFOCUS_REQUEST_FAILED = 0; // 0x0 field public static final int AUDIOFOCUS_REQUEST_GRANTED = 1; // 0x1 field public static final int ERROR = -1; // 0xffffffff field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa field public static final java.lang.String EXTRA_RINGER_MODE = "android.media.EXTRA_RINGER_MODE"; field public static final java.lang.String EXTRA_SCO_AUDIO_PREVIOUS_STATE = "android.media.extra.SCO_AUDIO_PREVIOUS_STATE"; field public static final java.lang.String EXTRA_SCO_AUDIO_STATE = "android.media.extra.SCO_AUDIO_STATE"; core/jni/android_media_AudioFormat.h +17 −5 Original line number Diff line number Diff line Loading @@ -23,9 +23,13 @@ #define ENCODING_PCM_16BIT 2 #define ENCODING_PCM_8BIT 3 #define ENCODING_PCM_FLOAT 4 #define ENCODING_AC3 5 #define ENCODING_E_AC3 6 #define ENCODING_INVALID 0 #define ENCODING_DEFAULT 1 #define CHANNEL_INVALID 0 #define CHANNEL_OUT_DEFAULT 1 Loading @@ -38,6 +42,10 @@ static inline audio_format_t audioFormatToNative(int audioFormat) return AUDIO_FORMAT_PCM_8_BIT; case ENCODING_PCM_FLOAT: return AUDIO_FORMAT_PCM_FLOAT; case ENCODING_AC3: return AUDIO_FORMAT_AC3; case ENCODING_E_AC3: return AUDIO_FORMAT_E_AC3; case ENCODING_DEFAULT: return AUDIO_FORMAT_DEFAULT; default: Loading @@ -54,6 +62,10 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat) return ENCODING_PCM_8BIT; case AUDIO_FORMAT_PCM_FLOAT: return ENCODING_PCM_FLOAT; case AUDIO_FORMAT_AC3: return ENCODING_AC3; case AUDIO_FORMAT_E_AC3: return ENCODING_E_AC3; case AUDIO_FORMAT_DEFAULT: return ENCODING_DEFAULT; default: Loading core/jni/android_media_AudioTrack.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -220,8 +220,13 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, } // compute the frame count size_t frameCount; if (audio_is_linear_pcm(format)) { const size_t bytesPerSample = audio_bytes_per_sample(format); size_t frameCount = buffSizeInBytes / (channelCount * bytesPerSample); frameCount = buffSizeInBytes / (channelCount * bytesPerSample); } else { frameCount = buffSizeInBytes; } jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { Loading Loading @@ -266,7 +271,7 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, format,// word length, PCM nativeChannelMask, frameCount, AUDIO_OUTPUT_FLAG_NONE, audio_is_linear_pcm(format) ? AUDIO_OUTPUT_FLAG_NONE : AUDIO_OUTPUT_FLAG_DIRECT, audioCallback, &(lpJniStorage->mCallbackData),//callback, callback data (user) 0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack 0,// shared mem Loading Loading @@ -478,14 +483,6 @@ jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const jbyte* da switch (format) { default: // TODO Currently the only possible values for format are AUDIO_FORMAT_PCM_16_BIT, // AUDIO_FORMAT_PCM_8_BIT, and AUDIO_FORMAT_PCM_FLOAT, // due to the limited set of values for audioFormat. // The next section of the switch will probably work for more formats, but it has only // been tested for AUDIO_FORMAT_PCM_16_BIT and AUDIO_FORMAT_PCM_FLOAT, // so that's why the "default" case fails. break; case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_16_BIT: { // writing to shared memory, check for capacity Loading Loading @@ -904,8 +901,12 @@ static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thi return -1; } const audio_format_t format = audioFormatToNative(audioFormat); if (audio_is_linear_pcm(format)) { const size_t bytesPerSample = audio_bytes_per_sample(format); return frameCount * channelCount * bytesPerSample; } else { return frameCount; } } // ---------------------------------------------------------------------------- Loading media/java/android/media/AudioFormat.java +48 −5 Original line number Diff line number Diff line Loading @@ -44,6 +44,10 @@ public class AudioFormat { public static final int ENCODING_PCM_8BIT = 3; /** Audio data format: single-precision floating-point per sample */ public static final int ENCODING_PCM_FLOAT = 4; /** Audio data format: AC-3 compressed */ public static final int ENCODING_AC3 = 5; /** Audio data format: E-AC-3 compressed */ public static final int ENCODING_E_AC3 = 6; /** Invalid audio channel configuration */ /** @deprecated use CHANNEL_INVALID instead */ Loading Loading @@ -152,11 +156,44 @@ public class AudioFormat { switch (audioFormat) { case ENCODING_PCM_8BIT: return 1; case ENCODING_PCM_16BIT: case ENCODING_DEFAULT: return 2; case ENCODING_PCM_FLOAT: return 4; case ENCODING_INVALID: default: throw new IllegalArgumentException("Bad audio format " + audioFormat); } } /** @hide */ public static boolean isValidEncoding(int audioFormat) { switch (audioFormat) { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_AC3: case ENCODING_E_AC3: return true; default: return false; } } /** @hide */ public static boolean isEncodingLinearPcm(int audioFormat) { switch (audioFormat) { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_DEFAULT: return 2; return true; case ENCODING_AC3: case ENCODING_E_AC3: return false; case ENCODING_INVALID: default: throw new IllegalArgumentException("Bad audio format " + audioFormat); Loading Loading @@ -236,7 +273,9 @@ public class AudioFormat { * @param encoding one of {@link AudioFormat#ENCODING_DEFAULT}, * {@link AudioFormat#ENCODING_PCM_8BIT}, * {@link AudioFormat#ENCODING_PCM_16BIT}, * {@link AudioFormat#ENCODING_PCM_FLOAT}. * {@link AudioFormat#ENCODING_PCM_FLOAT}, * {@link AudioFormat#ENCODING_AC3}, * {@link AudioFormat#ENCODING_E_AC3}. * @return the same Builder instance. * @throws java.lang.IllegalArgumentException */ Loading @@ -248,6 +287,8 @@ public class AudioFormat { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_AC3: case ENCODING_E_AC3: mEncoding = encoding; break; case ENCODING_INVALID: Loading Loading @@ -311,7 +352,9 @@ public class AudioFormat { ENCODING_DEFAULT, ENCODING_PCM_8BIT, ENCODING_PCM_16BIT, ENCODING_PCM_FLOAT ENCODING_PCM_FLOAT, ENCODING_AC3, ENCODING_E_AC3 }) @Retention(RetentionPolicy.SOURCE) public @interface Encoding {} Loading media/java/android/media/AudioManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -2974,7 +2974,9 @@ public class AudioManager { /** @hide */ public static final int ERROR_NO_INIT = AudioSystem.NO_INIT; /** @hide /** * An error code indicating that the object reporting it is no longer valid and needs to * be recreated. */ public static final int ERROR_DEAD_OBJECT = AudioSystem.DEAD_OBJECT; Loading Loading
api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -13739,7 +13739,9 @@ package android.media { field public static final int CHANNEL_OUT_QUAD = 204; // 0xcc field public static final int CHANNEL_OUT_STEREO = 12; // 0xc field public static final int CHANNEL_OUT_SURROUND = 1052; // 0x41c field public static final int ENCODING_AC3 = 5; // 0x5 field public static final int ENCODING_DEFAULT = 1; // 0x1 field public static final int ENCODING_E_AC3 = 6; // 0x6 field public static final int ENCODING_INVALID = 0; // 0x0 field public static final int ENCODING_PCM_16BIT = 2; // 0x2 field public static final int ENCODING_PCM_8BIT = 3; // 0x3 Loading Loading @@ -13813,6 +13815,7 @@ package android.media { field public static final int AUDIOFOCUS_REQUEST_FAILED = 0; // 0x0 field public static final int AUDIOFOCUS_REQUEST_GRANTED = 1; // 0x1 field public static final int ERROR = -1; // 0xffffffff field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa field public static final java.lang.String EXTRA_RINGER_MODE = "android.media.EXTRA_RINGER_MODE"; field public static final java.lang.String EXTRA_SCO_AUDIO_PREVIOUS_STATE = "android.media.extra.SCO_AUDIO_PREVIOUS_STATE"; field public static final java.lang.String EXTRA_SCO_AUDIO_STATE = "android.media.extra.SCO_AUDIO_STATE";
core/jni/android_media_AudioFormat.h +17 −5 Original line number Diff line number Diff line Loading @@ -23,9 +23,13 @@ #define ENCODING_PCM_16BIT 2 #define ENCODING_PCM_8BIT 3 #define ENCODING_PCM_FLOAT 4 #define ENCODING_AC3 5 #define ENCODING_E_AC3 6 #define ENCODING_INVALID 0 #define ENCODING_DEFAULT 1 #define CHANNEL_INVALID 0 #define CHANNEL_OUT_DEFAULT 1 Loading @@ -38,6 +42,10 @@ static inline audio_format_t audioFormatToNative(int audioFormat) return AUDIO_FORMAT_PCM_8_BIT; case ENCODING_PCM_FLOAT: return AUDIO_FORMAT_PCM_FLOAT; case ENCODING_AC3: return AUDIO_FORMAT_AC3; case ENCODING_E_AC3: return AUDIO_FORMAT_E_AC3; case ENCODING_DEFAULT: return AUDIO_FORMAT_DEFAULT; default: Loading @@ -54,6 +62,10 @@ static inline int audioFormatFromNative(audio_format_t nativeFormat) return ENCODING_PCM_8BIT; case AUDIO_FORMAT_PCM_FLOAT: return ENCODING_PCM_FLOAT; case AUDIO_FORMAT_AC3: return ENCODING_AC3; case AUDIO_FORMAT_E_AC3: return ENCODING_E_AC3; case AUDIO_FORMAT_DEFAULT: return ENCODING_DEFAULT; default: Loading
core/jni/android_media_AudioTrack.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -220,8 +220,13 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, } // compute the frame count size_t frameCount; if (audio_is_linear_pcm(format)) { const size_t bytesPerSample = audio_bytes_per_sample(format); size_t frameCount = buffSizeInBytes / (channelCount * bytesPerSample); frameCount = buffSizeInBytes / (channelCount * bytesPerSample); } else { frameCount = buffSizeInBytes; } jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { Loading Loading @@ -266,7 +271,7 @@ android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject weak_this, format,// word length, PCM nativeChannelMask, frameCount, AUDIO_OUTPUT_FLAG_NONE, audio_is_linear_pcm(format) ? AUDIO_OUTPUT_FLAG_NONE : AUDIO_OUTPUT_FLAG_DIRECT, audioCallback, &(lpJniStorage->mCallbackData),//callback, callback data (user) 0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack 0,// shared mem Loading Loading @@ -478,14 +483,6 @@ jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const jbyte* da switch (format) { default: // TODO Currently the only possible values for format are AUDIO_FORMAT_PCM_16_BIT, // AUDIO_FORMAT_PCM_8_BIT, and AUDIO_FORMAT_PCM_FLOAT, // due to the limited set of values for audioFormat. // The next section of the switch will probably work for more formats, but it has only // been tested for AUDIO_FORMAT_PCM_16_BIT and AUDIO_FORMAT_PCM_FLOAT, // so that's why the "default" case fails. break; case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_16_BIT: { // writing to shared memory, check for capacity Loading Loading @@ -904,8 +901,12 @@ static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thi return -1; } const audio_format_t format = audioFormatToNative(audioFormat); if (audio_is_linear_pcm(format)) { const size_t bytesPerSample = audio_bytes_per_sample(format); return frameCount * channelCount * bytesPerSample; } else { return frameCount; } } // ---------------------------------------------------------------------------- Loading
media/java/android/media/AudioFormat.java +48 −5 Original line number Diff line number Diff line Loading @@ -44,6 +44,10 @@ public class AudioFormat { public static final int ENCODING_PCM_8BIT = 3; /** Audio data format: single-precision floating-point per sample */ public static final int ENCODING_PCM_FLOAT = 4; /** Audio data format: AC-3 compressed */ public static final int ENCODING_AC3 = 5; /** Audio data format: E-AC-3 compressed */ public static final int ENCODING_E_AC3 = 6; /** Invalid audio channel configuration */ /** @deprecated use CHANNEL_INVALID instead */ Loading Loading @@ -152,11 +156,44 @@ public class AudioFormat { switch (audioFormat) { case ENCODING_PCM_8BIT: return 1; case ENCODING_PCM_16BIT: case ENCODING_DEFAULT: return 2; case ENCODING_PCM_FLOAT: return 4; case ENCODING_INVALID: default: throw new IllegalArgumentException("Bad audio format " + audioFormat); } } /** @hide */ public static boolean isValidEncoding(int audioFormat) { switch (audioFormat) { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_AC3: case ENCODING_E_AC3: return true; default: return false; } } /** @hide */ public static boolean isEncodingLinearPcm(int audioFormat) { switch (audioFormat) { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_DEFAULT: return 2; return true; case ENCODING_AC3: case ENCODING_E_AC3: return false; case ENCODING_INVALID: default: throw new IllegalArgumentException("Bad audio format " + audioFormat); Loading Loading @@ -236,7 +273,9 @@ public class AudioFormat { * @param encoding one of {@link AudioFormat#ENCODING_DEFAULT}, * {@link AudioFormat#ENCODING_PCM_8BIT}, * {@link AudioFormat#ENCODING_PCM_16BIT}, * {@link AudioFormat#ENCODING_PCM_FLOAT}. * {@link AudioFormat#ENCODING_PCM_FLOAT}, * {@link AudioFormat#ENCODING_AC3}, * {@link AudioFormat#ENCODING_E_AC3}. * @return the same Builder instance. * @throws java.lang.IllegalArgumentException */ Loading @@ -248,6 +287,8 @@ public class AudioFormat { case ENCODING_PCM_8BIT: case ENCODING_PCM_16BIT: case ENCODING_PCM_FLOAT: case ENCODING_AC3: case ENCODING_E_AC3: mEncoding = encoding; break; case ENCODING_INVALID: Loading Loading @@ -311,7 +352,9 @@ public class AudioFormat { ENCODING_DEFAULT, ENCODING_PCM_8BIT, ENCODING_PCM_16BIT, ENCODING_PCM_FLOAT ENCODING_PCM_FLOAT, ENCODING_AC3, ENCODING_E_AC3 }) @Retention(RetentionPolicy.SOURCE) public @interface Encoding {} Loading
media/java/android/media/AudioManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -2974,7 +2974,9 @@ public class AudioManager { /** @hide */ public static final int ERROR_NO_INIT = AudioSystem.NO_INIT; /** @hide /** * An error code indicating that the object reporting it is no longer valid and needs to * be recreated. */ public static final int ERROR_DEAD_OBJECT = AudioSystem.DEAD_OBJECT; Loading