Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89ce768a authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "AudioFormat: Retrieve sample rate capability from framework" am: ba32f574

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

Change-Id: I35be9d48f84dea6d8a9cb356873ea30725288ebf
parents 67143814 ba32f574
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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)
+2 −2
Original line number Diff line number Diff line
@@ -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.
+12 −0
Original line number Diff line number Diff line
@@ -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;