Merge "AudioFormat: Retrieve sample rate capability from framework" am: ba32f57428 am: 89ce768aa1

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1700287

Change-Id: I137ad2c9e8b3f360037f312773ea8d31d8ba4bfa
This commit is contained in:
Andy Hung
2021-05-10 20:15:24 +00:00
committed by Automerger Merge Worker
3 changed files with 25 additions and 2 deletions

View File

@@ -2277,6 +2277,15 @@ static jint android_media_AudioSystem_getMaxChannelCount(JNIEnv *env, jobject th
return FCC_8;
}
static jint android_media_AudioSystem_getMaxSampleRate(JNIEnv *env, jobject thiz) {
// see frameworks/av/services/audiopolicy/common/include/policy.h
return 192000; // SAMPLE_RATE_HZ_MAX (for API)
}
static jint android_media_AudioSystem_getMinSampleRate(JNIEnv *env, jobject thiz) {
return 4000; // SAMPLE_RATE_HZ_MIN (for API)
}
static jint
android_media_AudioSystem_setAssistantUid(JNIEnv *env, jobject thiz, jint uid)
{
@@ -2674,6 +2683,8 @@ static const JNINativeMethod gEventHandlerMethods[] = {
static const JNINativeMethod gFrameworkCapabilities[] = {
{"native_getMaxChannelCount", "()I", (void *)android_media_AudioSystem_getMaxChannelCount},
{"native_getMaxSampleRate", "()I", (void *)android_media_AudioSystem_getMaxSampleRate},
{"native_getMinSampleRate", "()I", (void *)android_media_AudioSystem_getMinSampleRate},
};
int register_android_media_AudioSystem(JNIEnv *env)

View File

@@ -518,13 +518,13 @@ public final class AudioFormat implements Parcelable {
* @hide
*/
// never unhide
public static final int SAMPLE_RATE_HZ_MIN = 4000;
public static final int SAMPLE_RATE_HZ_MIN = AudioSystem.SAMPLE_RATE_HZ_MIN;
/** Maximum value for sample rate,
* assuming AudioTrack and AudioRecord share the same limitations.
* @hide
*/
// never unhide
public static final int SAMPLE_RATE_HZ_MAX = 192000;
public static final int SAMPLE_RATE_HZ_MAX = AudioSystem.SAMPLE_RATE_HZ_MAX;
/** Sample rate will be a route-dependent value.
* For AudioTrack, it is usually the sink sample rate,
* and for AudioRecord it is usually the source sample rate.

View File

@@ -115,6 +115,18 @@ public class AudioSystem
public static final int OUT_CHANNEL_COUNT_MAX = native_getMaxChannelCount();
private static native int native_getMaxChannelCount();
/** Maximum value for sample rate, used by AudioFormat.
* @hide
*/
public static final int SAMPLE_RATE_HZ_MAX = native_getMaxSampleRate();
private static native int native_getMaxSampleRate();
/** Minimum value for sample rate, used by AudioFormat.
* @hide
*/
public static final int SAMPLE_RATE_HZ_MIN = native_getMinSampleRate();
private static native int native_getMinSampleRate();
// Expose only the getter method publicly so we can change it in the future
private static final int NUM_STREAM_TYPES = 12;