support changing audio-hw-sync-id during playback.

Bug: 151997287
Bug: 183968006
Test: Manual
Change-Id: I3ca8a1efbf8a1942fd54e2f892bc76fee847da4c
This commit is contained in:
Houxiang Dai
2021-03-22 18:03:55 +08:00
committed by Henry Fang
parent 2a5efce2d7
commit 6e3d3605dd

View File

@@ -4412,14 +4412,25 @@ final public class MediaCodec {
int i = 0;
for (final String key: params.keySet()) {
keys[i] = key;
Object value = params.get(key);
// Bundle's byte array is a byte[], JNI layer only takes ByteBuffer
if (value instanceof byte[]) {
values[i] = ByteBuffer.wrap((byte[])value);
if (key.equals(MediaFormat.KEY_AUDIO_SESSION_ID)) {
int sessionId = 0;
try {
sessionId = (Integer)params.get(key);
} catch (Exception e) {
throw new IllegalArgumentException("Wrong Session ID Parameter!");
}
keys[i] = "audio-hw-sync";
values[i] = AudioSystem.getAudioHwSyncForSession(sessionId);
} else {
values[i] = value;
keys[i] = key;
Object value = params.get(key);
// Bundle's byte array is a byte[], JNI layer only takes ByteBuffer
if (value instanceof byte[]) {
values[i] = ByteBuffer.wrap((byte[])value);
} else {
values[i] = value;
}
}
++i;
}