Skip to content

Commit

Permalink
Disabled tunneling on Hi3798MV200
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Mar 31, 2021
1 parent 5739caa commit 4a9d210
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.SubtitleView;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.nostra13.universalimageloader.core.ImageLoader;
Expand Down Expand Up @@ -488,8 +489,13 @@ private void initPlayer(final boolean playOnReady) {
// Setup subtitle view
simpleExoPlayer.addTextOutput(binding.subtitleView);

// Setup audio session with onboard equalizer
trackSelector.setParameters(trackSelector.buildUponParameters().setTunnelingEnabled(true));
// enable media tunneling
if (DeviceUtils.shouldSupportMediaTunneling()) {
trackSelector.setParameters(
trackSelector.buildUponParameters().setTunnelingEnabled(true));
} else if (DEBUG) {
Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] does not support media tunneling");
}
}

private void initListeners() {
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public final class DeviceUtils {
private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
private static Boolean isTV = null;

/*
* Devices that do not support media tunneling
*/
// Formuler Z8 Pro, Z8, CC, Z Alpha, Z+ Neo
private static final boolean HI3798MV200 = Build.VERSION.SDK_INT == 24
&& Build.DEVICE.equals("Hi3798MV200");

private DeviceUtils() {
}

Expand Down Expand Up @@ -88,4 +95,15 @@ public static int spToPx(@Dimension(unit = Dimension.SP) final int sp,
sp,
context.getResources().getDisplayMetrics());
}

/**
* Some devices have broken tunneled video playback but claim to support it.
* See https://github.com/TeamNewPipe/NewPipe/issues/5911
* @return false if Kitkat (does not support tunneling) or affected device
*/
public static boolean shouldSupportMediaTunneling() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& !HI3798MV200;
}

}

0 comments on commit 4a9d210

Please sign in to comment.