Skip to content

Commit

Permalink
Cleanup unused vars, assignments and expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Walch committed Mar 17, 2021
1 parent b0fa62d commit 1f7211d
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 24 deletions.
7 changes: 2 additions & 5 deletions src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ class AudioStreamController

private doTickIdle() {
const { hls, levels, media, trackId } = this;

const config = hls.config;
if (!levels) {

if (!levels || !levels[trackId]) {
return;
}

Expand All @@ -270,9 +270,6 @@ class AudioStreamController
return;
}

if (!levels || !levels[trackId]) {
return;
}
const levelInfo = levels[trackId];

const trackDetails = levelInfo.details;
Expand Down
10 changes: 6 additions & 4 deletions src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import type { HlsEventEmitter } from '../events';
import type { NetworkComponentAPI } from '../types/component-api';
import type { SourceBufferName } from '../types/buffer';

type ResolveFragLoaded = (FragLoadedEndData) => void;
type RejectFragLoaded = (LoadError) => void;

export const State = {
STOPPED: 'STOPPED',
IDLE: 'IDLE',
Expand Down Expand Up @@ -478,9 +481,8 @@ export default class BaseStreamController
// If we did not load parts, or loaded all parts, we have complete (not partial) fragment data
const complete =
!partsLoaded ||
(partsLoaded &&
(partsLoaded.length === 0 ||
partsLoaded.some((fragLoaded) => !fragLoaded)));
partsLoaded.length === 0 ||
partsLoaded.some((fragLoaded) => !fragLoaded);
const chunkMeta = new ChunkMetadata(
frag.level,
frag.sn as number,
Expand Down Expand Up @@ -570,7 +572,7 @@ export default class BaseStreamController
progressCallback: FragmentLoadProgressCallback
): Promise<PartsLoadedData | null> {
return new Promise(
(resolve: (FragLoadedEndData) => void, reject: (LoadError) => void) => {
(resolve: ResolveFragLoaded, reject: RejectFragLoaded) => {
const partsLoaded: FragLoadedData[] = [];
const loadPartIndex = (index: number) => {
const part = partList[index];
Expand Down
2 changes: 1 addition & 1 deletion src/controller/cap-level-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class CapLevelController implements ComponentAPI {
width: number,
height: number
): number {
if (!levels || (levels && !levels.length)) {
if (!levels || !levels.length) {
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/controller/level-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export function computeReloadInterval(
timeSinceLastModified > 0 && timeSinceLastModified < reloadInterval * 3;
const roundTrip = stats.loading.end - stats.loading.start;

let estimatedTimeUntilUpdate = reloadInterval;
let estimatedTimeUntilUpdate;
let availabilityDelay = newDetails.availabilityDelay;
// let estimate = 'average';

Expand Down
6 changes: 2 additions & 4 deletions src/controller/timeline-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,8 @@ export class TimelineController implements ComponentAPI {
if (data.frag.type === PlaylistLevelType.MAIN) {
const sn = data.frag.sn;
if (sn !== lastSn + 1) {
if (cea608Parser1 && cea608Parser2) {
cea608Parser1.reset();
cea608Parser2.reset();
}
cea608Parser1.reset();
cea608Parser2.reset();
}
this.lastSn = sn as number;
}
Expand Down
1 change: 0 additions & 1 deletion src/crypt/aes-decryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ export default class AESDecryptor {
(invSBOX[(s1 >> 8) & 0xff] << 8) ^
invSBOX[s2 & 0xff] ^
invKeySchedule[ksRow + 3];
ksRow = ksRow + 3;

// Write
outputInt32[offset] = swapWord(t0 ^ initVector0);
Expand Down
1 change: 0 additions & 1 deletion src/remux/mp4-remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ export default class MP4Remuxer implements Remuxer {
}
}
firstDTS = inputSamples[0].dts;
lastDTS = inputSamples[nbSamples - 1].dts;
}

// if fragment are contiguous, detect hole/overlapping between fragments
Expand Down
1 change: 0 additions & 1 deletion src/types/remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { TrackSet } from './track';
import {
DemuxedAudioTrack,
DemuxedMetadataTrack,
DemuxedTrack,
DemuxedUserdataTrack,
DemuxedVideoTrack,
MetadataSample,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/cea-608-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ class Cea608Parser {
* @returns {Object} pacData with style parameters.
*/
interpretPAC(row: number, byte: number): PACData {
let pacIndex = byte;
let pacIndex;
const pacData: PACData = {
color: null,
italics: false,
Expand Down Expand Up @@ -1353,7 +1353,7 @@ class Cea608Parser {
}
if (charCode1 >= 0x11 && charCode1 <= 0x13) {
// Special character
let oneCode = b;
let oneCode;
if (charCode1 === 0x11) {
oneCode = b + 0x50;
} else if (charCode1 === 0x12) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mp4-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type SidxInfo = {

export function parseSegmentIndex(initSegment: Uint8Array): SidxInfo | null {
const moovBox = findBox(initSegment, ['moov']);
const moov = moovBox ? moovBox[0] : null;
const moov = moovBox[0];
const moovEndOffset = moov ? moov.end : null; // we need this in case we need to chop of garbage of the end of current data

const sidxBox = findBox(initSegment, ['sidx']);
Expand Down
5 changes: 2 additions & 3 deletions tools/mp4-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,10 @@ var // this is the start of a huge multi-line var decl
flags: new Uint8Array(data.subarray(1, 4)),
handlerType: parseType(data.subarray(8, 12)),
name: '',
},
i = 8;
};

// parse out the name field
for (i = 24; i < data.byteLength; i++) {
for (var i = 24; i < data.byteLength; i++) {
if (data[i] === 0x00) {
// the name field is null-terminated
i++;
Expand Down

0 comments on commit 1f7211d

Please sign in to comment.