Remove redundant initializers from WebRTC Java code.

Removes redundant field initializers such as null, 0 and false.

Bug: webrtc:9742
Change-Id: I1e54f6c6000885cf95f7af8e2701875a78445497
Reviewed-on: https://webrtc-review.googlesource.com/99481
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24676}
This commit is contained in:
Sami Kalliomäki
2018-09-11 11:11:47 +02:00
committed by Commit Bot
parent ef73f59de6
commit 3d50a31aad
35 changed files with 118 additions and 124 deletions

View File

@ -85,8 +85,8 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink {
// caller and must be used to call initDecode, decode, and release.
private ThreadChecker decoderThreadChecker;
private volatile boolean running = false;
@Nullable private volatile Exception shutdownException = null;
private volatile boolean running;
@Nullable private volatile Exception shutdownException;
// Dimensions (width, height, stride, and sliceHeight) may be accessed by either the decode thread
// or the output thread. Accesses should be protected with this lock.
@ -107,7 +107,7 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink {
private final @Nullable EglBase.Context sharedContext;
// Valid and immutable while the decoder is running.
@Nullable private SurfaceTextureHelper surfaceTextureHelper;
@Nullable private Surface surface = null;
@Nullable private Surface surface;
private static class DecodedTextureMetadata {
final long presentationTimestampUs;
@ -128,7 +128,7 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink {
@Nullable private Callback callback;
// Valid and immutable while the decoder is running.
@Nullable private MediaCodecWrapper codec = null;
@Nullable private MediaCodecWrapper codec;
AndroidVideoDecoder(MediaCodecWrapperFactory mediaCodecWrapperFactory, String codecName,
VideoCodecType codecType, int colorFormat, @Nullable EglBase.Context sharedContext) {

View File

@ -12,8 +12,8 @@ package org.webrtc;
/** BitrateAdjuster that tracks bitrate and framerate but does not adjust them. */
class BaseBitrateAdjuster implements BitrateAdjuster {
protected int targetBitrateBps = 0;
protected int targetFps = 0;
protected int targetBitrateBps;
protected int targetFps;
@Override
public void setTargets(int targetBitrateBps, int targetFps) {

View File

@ -49,7 +49,7 @@ class Camera1Session implements CameraSession {
private final long constructionTimeNs; // Construction time of this class.
private SessionState state;
private boolean firstFrameReported = false;
private boolean firstFrameReported;
// TODO(titovartem) make correct fix during webrtc:9175
@SuppressWarnings("ByteBufferBackingArray")

View File

@ -71,7 +71,7 @@ class Camera2Session implements CameraSession {
// State
private SessionState state = SessionState.RUNNING;
private boolean firstFrameReported = false;
private boolean firstFrameReported;
// Used only for stats. Only used on the camera thread.
private final long constructionTimeNs; // Construction time of this class.

View File

@ -26,9 +26,9 @@ class DynamicBitrateAdjuster extends BaseBitrateAdjuster {
private static final double BITS_PER_BYTE = 8.0;
// How far the codec has deviated above (or below) the target bitrate (tracked in bytes).
private double deviationBytes = 0;
private double timeSinceLastAdjustmentMs = 0;
private int bitrateAdjustmentScaleExp = 0;
private double deviationBytes;
private double timeSinceLastAdjustmentMs;
private int bitrateAdjustmentScaleExp;
@Override
public void setTargets(int targetBitrateBps, int targetFps) {

View File

@ -104,15 +104,15 @@ class HardwareVideoEncoder implements VideoEncoder {
// --- Only accessed on the output thread.
// Contents of the last observed config frame output by the MediaCodec. Used by H.264.
@Nullable private ByteBuffer configBuffer = null;
@Nullable private ByteBuffer configBuffer;
private int adjustedBitrate;
// Whether the encoder is running. Volatile so that the output thread can watch this value and
// exit when the encoder stops.
private volatile boolean running = false;
private volatile boolean running;
// Any exception thrown during shutdown. The output thread releases the MediaCodec and uses this
// value to send exceptions thrown during release back to the encoder thread.
@Nullable private volatile Exception shutdownException = null;
@Nullable private volatile Exception shutdownException;
/**
* Creates a new HardwareVideoEncoder with the given codecName, codecType, colorFormat, key frame

View File

@ -28,7 +28,7 @@ class NativeLibrary {
}
private static Object lock = new Object();
private static boolean libraryLoaded = false;
private static boolean libraryLoaded;
/**
* Loads the native library. Clients should call PeerConnectionFactory.initialize. It will call

View File

@ -41,18 +41,18 @@ class WebRtcAudioEffects {
// Contains the available effect descriptors returned from the
// AudioEffect.getEffects() call. This result is cached to avoid doing the
// slow OS call multiple times.
private static @Nullable Descriptor[] cachedEffects = null;
private static @Nullable Descriptor[] cachedEffects;
// Contains the audio effect objects. Created in enable() and destroyed
// in release().
private @Nullable AcousticEchoCanceler aec = null;
private @Nullable NoiseSuppressor ns = null;
private @Nullable AcousticEchoCanceler aec;
private @Nullable NoiseSuppressor ns;
// Affects the final state given to the setEnabled() method on each effect.
// The default state is set to "disabled" but each effect can also be enabled
// by calling setAEC() and setNS().
private boolean shouldEnableAec = false;
private boolean shouldEnableNs = false;
private boolean shouldEnableAec;
private boolean shouldEnableNs;
// Returns true if all conditions for supporting HW Acoustic Echo Cancellation (AEC) are
// fulfilled.

View File

@ -63,10 +63,10 @@ class WebRtcAudioRecord {
private @Nullable ByteBuffer byteBuffer;
private @Nullable AudioRecord audioRecord = null;
private @Nullable AudioRecordThread audioThread = null;
private @Nullable AudioRecord audioRecord;
private @Nullable AudioRecordThread audioThread;
private volatile boolean microphoneMute = false;
private volatile boolean microphoneMute;
private byte[] emptyBytes;
private final @Nullable AudioRecordErrorCallback errorCallback;

View File

@ -21,11 +21,11 @@ import android.os.Process;
import java.lang.Thread;
import java.nio.ByteBuffer;
import javax.annotation.Nullable;
import org.webrtc.CalledByNative;
import org.webrtc.Logging;
import org.webrtc.ThreadUtils;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackErrorCallback;
import org.webrtc.audio.JavaAudioDeviceModule.AudioTrackStartErrorCode;
import org.webrtc.CalledByNative;
class WebRtcAudioTrack {
private static final String TAG = "WebRtcAudioTrackExternal";
@ -69,13 +69,13 @@ class WebRtcAudioTrack {
private ByteBuffer byteBuffer;
private @Nullable AudioTrack audioTrack = null;
private @Nullable AudioTrackThread audioThread = null;
private @Nullable AudioTrack audioTrack;
private @Nullable AudioTrackThread audioThread;
private final VolumeLogger volumeLogger;
// Samples to be played are replaced by zeros if |speakerMute| is set to true.
// Can be used to ensure that the speaker is fully muted.
private volatile boolean speakerMute = false;
private volatile boolean speakerMute;
private byte[] emptyBytes;
private final @Nullable AudioTrackErrorCallback errorCallback;