Avoid special-casing AnalyticsCollector when informing listeners.
In some cases (whose where we previously used EventListener), AnalyticsCollector is registered as a listener to receive updates, in other cases it is called directly. Avoid this inconsistent handling by registering it as normal listener and removing all callbacks that are handled by the normal listener flow. The remaining direct usages of AnalyticsCollector calls are those callbacks that have no equivalent in Player.Listener. #minor-release PiperOrigin-RevId: 427201525
This commit is contained in:
parent
258925d5f3
commit
6dbf9cac8c
@ -408,7 +408,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
currentCues = ImmutableList.of();
|
currentCues = ImmutableList.of();
|
||||||
throwsWhenUsingWrongThread = true;
|
throwsWhenUsingWrongThread = true;
|
||||||
|
|
||||||
listeners.add(analyticsCollector);
|
addListener(analyticsCollector);
|
||||||
bandwidthMeter.addEventListener(new Handler(applicationLooper), analyticsCollector);
|
bandwidthMeter.addEventListener(new Handler(applicationLooper), analyticsCollector);
|
||||||
addAudioOffloadListener(componentListener);
|
addAudioOffloadListener(componentListener);
|
||||||
if (builder.foregroundModeTimeoutMs > 0) {
|
if (builder.foregroundModeTimeoutMs > 0) {
|
||||||
@ -1392,7 +1392,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
this.audioAttributes = audioAttributes;
|
this.audioAttributes = audioAttributes;
|
||||||
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
|
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
|
||||||
streamVolumeManager.setStreamType(Util.getStreamTypeForAudioUsage(audioAttributes.usage));
|
streamVolumeManager.setStreamType(Util.getStreamTypeForAudioUsage(audioAttributes.usage));
|
||||||
analyticsCollector.onAudioAttributesChanged(audioAttributes);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onAudioAttributesChanged(audioAttributes);
|
listener.onAudioAttributesChanged(audioAttributes);
|
||||||
@ -1430,7 +1429,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
this.audioSessionId = audioSessionId;
|
this.audioSessionId = audioSessionId;
|
||||||
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
|
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
|
||||||
sendRendererMessage(TRACK_TYPE_VIDEO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
|
sendRendererMessage(TRACK_TYPE_VIDEO, MSG_SET_AUDIO_SESSION_ID, audioSessionId);
|
||||||
analyticsCollector.onAudioSessionIdChanged(audioSessionId);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onAudioSessionIdChanged(audioSessionId);
|
listener.onAudioSessionIdChanged(audioSessionId);
|
||||||
@ -1458,7 +1456,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
}
|
}
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
sendVolumeToRenderers();
|
sendVolumeToRenderers();
|
||||||
analyticsCollector.onVolumeChanged(volume);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onVolumeChanged(volume);
|
listener.onVolumeChanged(volume);
|
||||||
@ -2485,7 +2482,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
if (width != surfaceWidth || height != surfaceHeight) {
|
if (width != surfaceWidth || height != surfaceHeight) {
|
||||||
surfaceWidth = width;
|
surfaceWidth = width;
|
||||||
surfaceHeight = height;
|
surfaceHeight = height;
|
||||||
analyticsCollector.onSurfaceSizeChanged(width, height);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onSurfaceSizeChanged(width, height);
|
listener.onSurfaceSizeChanged(width, height);
|
||||||
@ -2499,7 +2495,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void notifySkipSilenceEnabledChanged() {
|
private void notifySkipSilenceEnabledChanged() {
|
||||||
analyticsCollector.onSkipSilenceEnabledChanged(skipSilenceEnabled);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onSkipSilenceEnabledChanged(skipSilenceEnabled);
|
listener.onSkipSilenceEnabledChanged(skipSilenceEnabled);
|
||||||
@ -2698,7 +2693,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
@Override
|
@Override
|
||||||
public void onVideoSizeChanged(VideoSize videoSize) {
|
public void onVideoSizeChanged(VideoSize videoSize) {
|
||||||
ExoPlayerImpl.this.videoSize = videoSize;
|
ExoPlayerImpl.this.videoSize = videoSize;
|
||||||
analyticsCollector.onVideoSizeChanged(videoSize);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onVideoSizeChanged(videoSize);
|
listener.onVideoSizeChanged(videoSize);
|
||||||
@ -2806,7 +2800,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
@Override
|
@Override
|
||||||
public void onCues(List<Cue> cues) {
|
public void onCues(List<Cue> cues) {
|
||||||
currentCues = cues;
|
currentCues = cues;
|
||||||
analyticsCollector.onCues(cues);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listeners : listenerArraySet) {
|
for (Listener listeners : listenerArraySet) {
|
||||||
listeners.onCues(cues);
|
listeners.onCues(cues);
|
||||||
@ -2817,7 +2810,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMetadata(Metadata metadata) {
|
public void onMetadata(Metadata metadata) {
|
||||||
analyticsCollector.onMetadata(metadata);
|
|
||||||
ExoPlayerImpl.this.onMetadata(metadata);
|
ExoPlayerImpl.this.onMetadata(metadata);
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
@ -2915,7 +2907,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
DeviceInfo deviceInfo = createDeviceInfo(streamVolumeManager);
|
DeviceInfo deviceInfo = createDeviceInfo(streamVolumeManager);
|
||||||
if (!deviceInfo.equals(ExoPlayerImpl.this.deviceInfo)) {
|
if (!deviceInfo.equals(ExoPlayerImpl.this.deviceInfo)) {
|
||||||
ExoPlayerImpl.this.deviceInfo = deviceInfo;
|
ExoPlayerImpl.this.deviceInfo = deviceInfo;
|
||||||
analyticsCollector.onDeviceInfoChanged(deviceInfo);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onDeviceInfoChanged(deviceInfo);
|
listener.onDeviceInfoChanged(deviceInfo);
|
||||||
@ -2925,7 +2916,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStreamVolumeChanged(int streamVolume, boolean streamMuted) {
|
public void onStreamVolumeChanged(int streamVolume, boolean streamMuted) {
|
||||||
analyticsCollector.onDeviceVolumeChanged(streamVolume, streamMuted);
|
|
||||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||||
for (Listener listener : listenerArraySet) {
|
for (Listener listener : listenerArraySet) {
|
||||||
listener.onDeviceVolumeChanged(streamVolume, streamMuted);
|
listener.onDeviceVolumeChanged(streamVolume, streamMuted);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user