Skip to content

Commit

Permalink
getFilteredAudioStreams: make trackId more obvious
Browse files Browse the repository at this point in the history
why would you serialize objects to avoid a null check, that’s just
weird.
  • Loading branch information
Profpatsch committed Jan 6, 2024
1 parent 743e16a commit ebb9ef7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ public static boolean isHighResolutionSelected(final String selectedResolution,
* Filter the list of audio streams and return a list with the preferred stream for
* each audio track. Streams are sorted with the preferred language in the first position.
*
* The following formats cannot be played and are thus skipped:
*
* <ul>
* <li>{@literal DeliveryMethod.TORRENT}
* <li>both {@literal DeliveryMethod.HLS} AND {@literal MediaFormat.OPUS}</li>
* </ul>
*
* @param context the context to search for the track to give preference
* @param audioStreams the list of audio streams
* @return the sorted, filtered list
Expand All @@ -285,11 +292,14 @@ public static List<AudioStream> getFilteredAudioStreams(
for (final AudioStream stream : audioStreams) {
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT
|| (stream.getDeliveryMethod() == DeliveryMethod.HLS
&& stream.getFormat() == MediaFormat.OPUS)) {
&& stream.getFormat() == MediaFormat.OPUS)) {
continue;
}

final String trackId = Objects.toString(stream.getAudioTrackId(), "");
String trackId = stream.getAudioTrackId();
if (trackId == null) {
trackId = "";
}

final AudioStream presentStream = collectedStreams.get(trackId);
if (presentStream == null || cmp.compare(stream, presentStream) > 0) {
Expand Down

0 comments on commit ebb9ef7

Please sign in to comment.