Commit 121013d3 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 279fdb52
......@@ -398,7 +398,7 @@ import java.util.concurrent.TimeoutException;
currentCues = ImmutableList.of();
throwsWhenUsingWrongThread = true;
listeners.add(analyticsCollector);
addListener(analyticsCollector);
bandwidthMeter.addEventListener(new Handler(applicationLooper), analyticsCollector);
addAudioOffloadListener(componentListener);
if (builder.foregroundModeTimeoutMs > 0) {
......@@ -1382,7 +1382,6 @@ import java.util.concurrent.TimeoutException;
this.audioAttributes = audioAttributes;
sendRendererMessage(TRACK_TYPE_AUDIO, MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
streamVolumeManager.setStreamType(Util.getStreamTypeForAudioUsage(audioAttributes.usage));
analyticsCollector.onAudioAttributesChanged(audioAttributes);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onAudioAttributesChanged(audioAttributes);
......@@ -1420,7 +1419,6 @@ import java.util.concurrent.TimeoutException;
this.audioSessionId = audioSessionId;
sendRendererMessage(TRACK_TYPE_AUDIO, 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
for (Listener listener : listenerArraySet) {
listener.onAudioSessionIdChanged(audioSessionId);
......@@ -1448,7 +1446,6 @@ import java.util.concurrent.TimeoutException;
}
this.volume = volume;
sendVolumeToRenderers();
analyticsCollector.onVolumeChanged(volume);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onVolumeChanged(volume);
......@@ -2475,7 +2472,6 @@ import java.util.concurrent.TimeoutException;
if (width != surfaceWidth || height != surfaceHeight) {
surfaceWidth = width;
surfaceHeight = height;
analyticsCollector.onSurfaceSizeChanged(width, height);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onSurfaceSizeChanged(width, height);
......@@ -2489,7 +2485,6 @@ import java.util.concurrent.TimeoutException;
}
private void notifySkipSilenceEnabledChanged() {
analyticsCollector.onSkipSilenceEnabledChanged(skipSilenceEnabled);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onSkipSilenceEnabledChanged(skipSilenceEnabled);
......@@ -2688,7 +2683,6 @@ import java.util.concurrent.TimeoutException;
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
ExoPlayerImpl.this.videoSize = videoSize;
analyticsCollector.onVideoSizeChanged(videoSize);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onVideoSizeChanged(videoSize);
......@@ -2796,7 +2790,6 @@ import java.util.concurrent.TimeoutException;
@Override
public void onCues(List<Cue> cues) {
currentCues = cues;
analyticsCollector.onCues(cues);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listeners : listenerArraySet) {
listeners.onCues(cues);
......@@ -2807,7 +2800,6 @@ import java.util.concurrent.TimeoutException;
@Override
public void onMetadata(Metadata metadata) {
analyticsCollector.onMetadata(metadata);
ExoPlayerImpl.this.onMetadata(metadata);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
......@@ -2905,7 +2897,6 @@ import java.util.concurrent.TimeoutException;
DeviceInfo deviceInfo = createDeviceInfo(streamVolumeManager);
if (!deviceInfo.equals(ExoPlayerImpl.this.deviceInfo)) {
ExoPlayerImpl.this.deviceInfo = deviceInfo;
analyticsCollector.onDeviceInfoChanged(deviceInfo);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
listener.onDeviceInfoChanged(deviceInfo);
......@@ -2915,7 +2906,6 @@ import java.util.concurrent.TimeoutException;
@Override
public void onStreamVolumeChanged(int streamVolume, boolean streamMuted) {
analyticsCollector.onDeviceVolumeChanged(streamVolume, streamMuted);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for (Listener listener : listenerArraySet) {
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