Add TvInputManager.Hardware overrideAudioSink with AudioDeviceInfo
The current overrideAudioSink interface expects AudioManager.DEVICE_*
values which are @hide and not available to vendor, oem or product
partition apps. To support such applications, add new interface using
the public SDK API AudioDeviceInfo.
Test: New API has been tested using our internal mock TV input HAL for
the HDMI TV input.
Run CTS test "CtsTvTestCases:BundledTvInputServiceTest#testTune"
to tune for HDMI input and invoke a createAudioPatch request in
TvInputHardwareManager.
Verify the API behavior from the following log:
=> adb logcat | grep APM
=> "APM_AudioPolicyManager: createAudioPatchInternal sink 0: id 9
role 2 type 1"
with the id 9 referring to the BUS output device.
Test: See b/183527693
Bug: 183538871
Change-Id: I54f7f26d522a8f3bb3500f3817f87a98ddf47f17
This commit is contained in:
@@ -5860,6 +5860,7 @@ package android.media.tv {
|
||||
|
||||
public static final class TvInputManager.Hardware {
|
||||
method public void overrideAudioSink(int, String, int, int, int);
|
||||
method public void overrideAudioSink(@NonNull android.media.AudioDeviceInfo, @IntRange(from=0) int, int, int);
|
||||
method public void setStreamVolume(float);
|
||||
method public boolean setSurface(android.view.Surface, android.media.tv.TvStreamConfig);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.media.tv;
|
||||
|
||||
import android.annotation.CallbackExecutor;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
@@ -27,6 +28,8 @@ import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.media.AudioDeviceInfo;
|
||||
import android.media.AudioFormat.Encoding;
|
||||
import android.media.PlaybackParams;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
@@ -59,6 +62,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
@@ -2998,6 +3002,16 @@ public final class TvInputManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default audio sink from audio policy.
|
||||
*
|
||||
* @param audioType device type of the audio sink to override with.
|
||||
* @param audioAddress device address of the audio sink to override with.
|
||||
* @param samplingRate desired sampling rate. Use default when it's 0.
|
||||
* @param channelMask desired channel mask. Use default when it's
|
||||
* AudioFormat.CHANNEL_OUT_DEFAULT.
|
||||
* @param format desired format. Use default when it's AudioFormat.ENCODING_DEFAULT.
|
||||
*/
|
||||
public void overrideAudioSink(int audioType, String audioAddress, int samplingRate,
|
||||
int channelMask, int format) {
|
||||
try {
|
||||
@@ -3007,5 +3021,27 @@ public final class TvInputManager {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default audio sink from audio policy.
|
||||
*
|
||||
* @param device {@link android.media.AudioDeviceInfo} to use.
|
||||
* @param samplingRate desired sampling rate. Use default when it's 0.
|
||||
* @param channelMask desired channel mask. Use default when it's
|
||||
* AudioFormat.CHANNEL_OUT_DEFAULT.
|
||||
* @param format desired format. Use default when it's AudioFormat.ENCODING_DEFAULT.
|
||||
*/
|
||||
public void overrideAudioSink(@NonNull AudioDeviceInfo device,
|
||||
@IntRange(from = 0) int samplingRate,
|
||||
int channelMask, @Encoding int format) {
|
||||
Objects.requireNonNull(device);
|
||||
try {
|
||||
mInterface.overrideAudioSink(
|
||||
AudioDeviceInfo.convertDeviceTypeToInternalDevice(device.getType()),
|
||||
device.getAddress(), samplingRate, channelMask, format);
|
||||
} catch (RemoteException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user