mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

The new callback allows an app to read data from the content timeline to populate the `AdPlaybackState`. To avoid a deadlock between the `AdMediaSource` waiting for the `AdPlaybackState` and the app waiting for the content `Timeline`, a boolean flag `useLazyContentSourcePreparation` is introduced to tell the `AdsMediaSource` to prepare the content source immediately to make the `Timeline` available. A unit test verifies that in none of the cases (lazy preparation or immediate preparation) a `Timeline` without ad data is leaked to the caller. This ensures that in the case of a preroll, the player won't initially and accidentally read content media data before starting to load the preroll ad. While the content source is prepared early, no content media period must be created before the preroll starts. PiperOrigin-RevId: 696885392