Audio: fix AudioVolumeGroup JNI

Fix volume group conversion from native to java
to make sure the audio source is properly initialized
to the default java value in a playback only context.

Bug: 249966139
Test: atest com.android.audiopolicytest
Test: atet com.google.android.gts.audioservice.AudioServiceHostTest#testAudioVolumeGroups

Change-Id: If6e0b5ba576f3fdf89480205639b1c2a4b722456
This commit is contained in:
Eric Laurent
2022-10-03 21:13:46 +02:00
parent 12421fe92e
commit 2c5d09c410

View File

@@ -94,6 +94,11 @@ static jint convertAudioVolumeGroupsFromNative(
for (size_t j = 0; j < static_cast<size_t>(numAttributes); j++) {
auto attributes = group.getAudioAttributes()[j];
// Native & Java audio attributes default initializers are not aligned for the source.
// Given the volume group class concerns only playback, this field must be equal to the
// default java initializer.
attributes.source = AUDIO_SOURCE_INVALID;
jStatus = JNIAudioAttributeHelper::nativeToJava(env, &jAudioAttribute, attributes);
if (jStatus != AUDIO_JAVA_SUCCESS) {
goto exit;