Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ task runCheckstyle(type: Checkstyle) {
}
}

runCheckstyle.doLast {
reports.all { report ->
def outputFile = report.destination
if (outputFile.exists() && outputFile.text.contains("severity=\"error\"")) {
throw new GradleException("There were checkstyle errors! For more info check $outputFile")
}
}
}

configurations {
ktlint
}
Expand Down
31 changes: 15 additions & 16 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;

import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import org.schabi.newpipe.R;
Expand Down Expand Up @@ -267,23 +268,22 @@ private static void sortStreamList(final List<VideoStream> videoStreams,
}

/**
* Get the audio from the list with the highest quality. Format will be ignored if it yields
* no results.
* Get the audio from the list with the highest quality.
* Format will be ignored if it yields no results.
*
* @param format the format to look for
* @param audioStreams list the audio streams
* @return index of the audio with the highest average bitrate of the default format
* @param format The target format type or null if it doesn't matter
* @param audioStreams List of audio streams
* @return Index of audio stream that produces the most compact results or -1 if not found
*/
static int getHighestQualityAudioIndex(final MediaFormat format,
static int getHighestQualityAudioIndex(@Nullable MediaFormat format,
final List<AudioStream> audioStreams) {
int result = -1;
boolean hasOneFormat = false;
if (audioStreams != null) {
while (result == -1) {
AudioStream prevStream = null;
for (int idx = 0; idx < audioStreams.size(); idx++) {
AudioStream stream = audioStreams.get(idx);
if ((format == null || stream.getFormat() == format || hasOneFormat)
if ((format == null || stream.getFormat() == format)
&& (prevStream == null || compareAudioStreamBitrate(prevStream, stream,
AUDIO_FORMAT_QUALITY_RANKING) < 0)) {
prevStream = stream;
Expand All @@ -293,30 +293,29 @@ static int getHighestQualityAudioIndex(final MediaFormat format,
if (result == -1 && format == null) {
break;
}
hasOneFormat = true;
format = null;
}
}
return result;
}

/**
* Get the audio from the list with the lowest bitrate and efficient format. Format will be
* ignored if it yields no results.
* Get the audio from the list with the lowest bitrate and most efficient format.
* Format will be ignored if it yields no results.
*
* @param format The target format type or null if it doesn't matter
* @param audioStreams List of audio streams
* @return Index of audio stream that can produce the most compact results or -1 if not found
* @return Index of audio stream that produces the most compact results or -1 if not found
*/
static int getMostCompactAudioIndex(final MediaFormat format,
static int getMostCompactAudioIndex(@Nullable MediaFormat format,
final List<AudioStream> audioStreams) {
int result = -1;
boolean hasOneFormat = false;
if (audioStreams != null) {
while (result == -1) {
AudioStream prevStream = null;
for (int idx = 0; idx < audioStreams.size(); idx++) {
AudioStream stream = audioStreams.get(idx);
if ((format == null || stream.getFormat() == format || hasOneFormat)
if ((format == null || stream.getFormat() == format)
&& (prevStream == null || compareAudioStreamBitrate(prevStream, stream,
AUDIO_FORMAT_EFFICIENCY_RANKING) > 0)) {
prevStream = stream;
Expand All @@ -326,7 +325,7 @@ static int getMostCompactAudioIndex(final MediaFormat format,
if (result == -1 && format == null) {
break;
}
hasOneFormat = true;
format = null;
}
}
return result;
Expand Down
4 changes: 4 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
files="InfoListAdapter.java"
lines="253,325"/>

<suppress checks="FinalParameters"
files="ListHelper.java"
lines="278,310"/>

<!-- org.schabi.newpipe.streams -->
<suppress checks="FinalParameters"
files="DataReader.java"
Expand Down