Commit fdce6abf by tonihei Committed by Ian Baker

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
parent 0dd10804
...@@ -393,7 +393,7 @@ import java.util.concurrent.TimeoutException; ...@@ -393,7 +393,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) {
...@@ -1377,7 +1377,6 @@ import java.util.concurrent.TimeoutException; ...@@ -1377,7 +1377,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);
...@@ -1415,7 +1414,6 @@ import java.util.concurrent.TimeoutException; ...@@ -1415,7 +1414,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);
...@@ -1443,7 +1441,6 @@ import java.util.concurrent.TimeoutException; ...@@ -1443,7 +1441,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);
...@@ -2470,7 +2467,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2470,7 +2467,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);
...@@ -2484,7 +2480,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2484,7 +2480,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);
...@@ -2683,7 +2678,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2683,7 +2678,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);
...@@ -2791,7 +2785,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2791,7 +2785,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);
...@@ -2802,7 +2795,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2802,7 +2795,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) {
...@@ -2900,7 +2892,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2900,7 +2892,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);
...@@ -2910,7 +2901,6 @@ import java.util.concurrent.TimeoutException; ...@@ -2910,7 +2901,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment