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

Commit 93ce89aa 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
parent eb806d84
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -338,7 +338,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.push_back(dev);
        env->ReleaseStringUTFChars((jstring)addrJobj, address);
    }
@@ -820,7 +820,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;
@@ -940,8 +941,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);
@@ -2334,7 +2335,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
+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.setAddress(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);