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

Commit 8c845dca authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Convert mask types from uint32_t to enum type

This applies to the following types:

- audio_gain_mode_t;
- audio_flags_mask_t;
- audio_channel_representation_t;
- audio_channel_mask_t;
- audio_devices_t.

Enum types are distinct thus proper overloading on the type
is possible in C++. Also, assignments to enum types are
less prone to errors.

Bug: 169889714
Test: basic audio functionality
Change-Id: I7f32a7c7741dea88fa2fd8a2e7fe50d0c31eb2e7
Merged-In: I7f32a7c7741dea88fa2fd8a2e7fe50d0c31eb2e7
parent 5e3a035a
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ static jint getVectorOfAudioDeviceTypeAddr(JNIEnv *env, jintArray deviceTypes,
            return (jint)AUDIO_JAVA_BAD_VALUE;
        }
        const char *address = env->GetStringUTFChars((jstring)addrJobj, NULL);
        AudioDeviceTypeAddr dev = AudioDeviceTypeAddr(typesPtr[i], address);
        AudioDeviceTypeAddr dev = AudioDeviceTypeAddr((audio_devices_t)typesPtr[i], address);
        audioDeviceTypeAddrVector.add(dev);
        env->ReleaseStringUTFChars((jstring)addrJobj, address);
    }
@@ -818,7 +818,8 @@ static void convertAudioGainConfigToNative(JNIEnv *env,
                                               bool useInMask)
{
    nAudioGainConfig->index = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mIndex);
    nAudioGainConfig->mode = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mMode);
    nAudioGainConfig->mode =
            (audio_gain_mode_t)env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mMode);
    ALOGV("convertAudioGainConfigToNative got gain index %d", nAudioGainConfig->index);
    jint jMask = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mChannelMask);
    audio_channel_mask_t nMask;
@@ -938,8 +939,8 @@ static jint convertAudioPortConfigToNativeWithDevicePort(JNIEnv *env,

    jobject jAudioDevicePort = env->GetObjectField(jAudioPortConfig,
            gAudioPortConfigFields.mPort);
    nAudioPortConfig->ext.device.type = env->GetIntField(jAudioDevicePort,
            gAudioPortFields.mType);
    nAudioPortConfig->ext.device.type =
            (audio_devices_t)env->GetIntField(jAudioDevicePort, gAudioPortFields.mType);
    jstring jDeviceAddress = (jstring)env->GetObjectField(jAudioDevicePort,
            gAudioPortFields.mAddress);
    const char *nDeviceAddress = env->GetStringUTFChars(jDeviceAddress, NULL);
@@ -2332,7 +2333,7 @@ static jint android_media_AudioSystem_setSupportedSystemUsages(JNIEnv *env, jobj

static jint
android_media_AudioSystem_setAllowedCapturePolicy(JNIEnv *env, jobject thiz, jint uid, jint flags) {
    return AudioSystem::setAllowedCapturePolicy(uid, flags);
    return AudioSystem::setAllowedCapturePolicy(uid, static_cast<audio_flags_mask_t>(flags));
}

static jint
@@ -2368,7 +2369,9 @@ android_media_AudioSystem_setPreferredDeviceForStrategy(JNIEnv *env, jobject thi
    const char *c_address = env->GetStringUTFChars(deviceAddress, NULL);
    int status = check_AudioSystem_Command(
            AudioSystem::setPreferredDeviceForStrategy((product_strategy_t)strategy,
                    AudioDeviceTypeAddr(deviceType, c_address)));
                                                       AudioDeviceTypeAddr((audio_devices_t)
                                                                                   deviceType,
                                                                           c_address)));
    env->ReleaseStringUTFChars(deviceAddress, c_address);
    return (jint) status;
}
+1 −1
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t
    }

    if (deviceType != AUDIO_DEVICE_NONE) {
        device.mType = deviceType;
        device.mType = (audio_devices_t)deviceType;
        ScopedUtfChars address(env, deviceAddress);
        device.mAddress = address.c_str();
    }
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz, jobject weakRef,
    paa->usage = (audio_usage_t) env->GetIntField(jaa, javaAudioAttrFields.fieldUsage);
    paa->content_type =
            (audio_content_type_t) env->GetIntField(jaa, javaAudioAttrFields.fieldContentType);
    paa->flags = env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
    paa->flags = (audio_flags_mask_t) env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);

    ALOGV("android_media_SoundPool_native_setup");
    auto *ap = new SoundPool(maxChannels, paa);