Skip to content

Commit

Permalink
Use goog.DEBUG over COMPILED.
Browse files Browse the repository at this point in the history
This allows including the extra assertions and logging in the debug
compiled library.

Change-Id: Ie8575a31b428e1985077939169bfae9254e395d5
  • Loading branch information
TheModMaker committed Sep 27, 2017
1 parent 65a90f7 commit 1224464
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 18 deletions.
12 changes: 8 additions & 4 deletions demo/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,21 @@
var combined = fields.concat(fragments);

// Very old browsers do not have Array.prototype.indexOf.
var compiledMode = false;
var compiledScript = null;
for (var i = 0; i < combined.length; ++i) {
if (combined[i] == 'compiled') {
compiledMode = true;
compiledScript = '../dist/shaka-player.compiled.js';
break;
}
if (combined[i] == 'debug_compiled') {
compiledScript = '../dist/shaka-player.compiled.debug.js';
break;
}
}

if (compiledMode) {
if (compiledScript) {
// This contains the entire library.
loadRelativeScript('../dist/shaka-player.compiled.js');
loadRelativeScript(compiledScript);
} else {
// In non-compiled mode, we load the closure library and the generated deps
// file to bootstrap the system. goog.require will load the rest.
Expand Down
3 changes: 3 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ shakaDemo.hashShouldChange_ = function() {
if ('compiled' in shakaDemo.getParams_()) {
params.push('compiled');
}
if ('debug_compiled' in shakaDemo.getParams_()) {
params.push('debug_compiled');
}

// Store values for drm configuration.
var videoRobustness =
Expand Down
2 changes: 1 addition & 1 deletion lib/cast/cast_receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ shaka.cast.CastReceiver.prototype.init_ = function() {
shaka.cast.CastUtils.SHAKA_MESSAGE_NAMESPACE);
this.shakaBus_.onMessage = this.onShakaMessage_.bind(this);

if (!COMPILED) {
if (goog.DEBUG) {
// Sometimes it is useful to load the receiver app in Chrome to work on the
// UI. To avoid log spam caused by the SDK trying to connect to web sockets
// that don't exist, in uncompiled mode we check if the hosting browser is a
Expand Down
2 changes: 1 addition & 1 deletion lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ shaka.dash.DashParser.prototype.processManifest_ =
Infinity);
// Use @maxSegmentDuration to override smaller, derived values.
presentationTimeline.notifyMaxSegmentDuration(maxSegmentDuration || 1);
if (!COMPILED) presentationTimeline.assertIsValid();
if (goog.DEBUG) presentationTimeline.assertIsValid();

if (this.manifest_) {
// This is a manifest update, so we're done.
Expand Down
2 changes: 1 addition & 1 deletion lib/debug/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ shaka.log.v2 = function() {};
// IE8 has no console unless it is opened in advance.
// IE9 console methods are not Functions and have no bind.
if (window.console && window.console.log.bind) {
if (!COMPILED) {
if (goog.DEBUG) {
/** @type {number} */
shaka.log.currentLevel;

Expand Down
6 changes: 3 additions & 3 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ shaka.media.MediaSourceEngine.prototype.destroy = function() {
this.textEngine_ = null;
this.textDisplayer_ = null;
this.sourceBuffers_ = {};
if (!COMPILED) {
if (goog.DEBUG) {
for (var contentType in this.queues_) {
goog.asserts.assert(
this.queues_[contentType].length == 0,
Expand Down Expand Up @@ -788,7 +788,7 @@ shaka.media.MediaSourceEngine.prototype.enqueueBlockingOperation_ =
// Return a Promise to the real operation, which waits to begin until there
// are no other in-progress operations on any SourceBuffers.
return Promise.all(allWaiters).then(function() {
if (!COMPILED) {
if (goog.DEBUG) {
// If we did it correctly, nothing is updating.
for (var contentType in this.sourceBuffers_) {
goog.asserts.assert(
Expand Down Expand Up @@ -822,7 +822,7 @@ shaka.media.MediaSourceEngine.prototype.enqueueBlockingOperation_ =
// destroy. What's left now should just be resolved waiters. In uncompiled
// mode, we will maintain good hygiene and make sure the assert at the end
// of destroy passes. In compiled mode, the queues are wiped in destroy.
if (!COMPILED) {
if (goog.DEBUG) {
for (var contentType in this.sourceBuffers_) {
if (this.queues_[contentType].length) {
goog.asserts.assert(
Expand Down
2 changes: 1 addition & 1 deletion lib/media/presentation_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ shaka.media.PresentationTimeline.prototype.getLiveEdge_ = function() {
};


if (!COMPILED) {
if (goog.DEBUG) {
/**
* Debug only: assert that the timeline parameters make sense for the type of
* presentation (VOD, IPR, live).
Expand Down
8 changes: 4 additions & 4 deletions lib/media/segment_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ goog.require('shaka.util.ManifestParserUtils');
* @export
*/
shaka.media.SegmentIndex = function(references) {
if (!COMPILED) {
if (goog.DEBUG) {
shaka.media.SegmentIndex.assertCorrectReferences_(references);
}

Expand Down Expand Up @@ -118,7 +118,7 @@ shaka.media.SegmentIndex.prototype.get = function(position) {
* @export
*/
shaka.media.SegmentIndex.prototype.merge = function(references) {
if (!COMPILED) {
if (goog.DEBUG) {
shaka.media.SegmentIndex.assertCorrectReferences_(references);
}

Expand Down Expand Up @@ -177,7 +177,7 @@ shaka.media.SegmentIndex.prototype.merge = function(references) {
newReferences = references;
}

if (!COMPILED) {
if (goog.DEBUG) {
shaka.media.SegmentIndex.assertCorrectReferences_(newReferences);
}

Expand Down Expand Up @@ -249,7 +249,7 @@ shaka.media.SegmentIndex.prototype.fit = function(periodDuration) {
};


if (!COMPILED) {
if (goog.DEBUG) {
/**
* Asserts that the given SegmentReferences are sorted and have continuous,
* increasing positions.
Expand Down
4 changes: 2 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ shaka.Player.prototype.switchTextStream_ = function(textStream) {
* @private
*/
shaka.Player.prototype.assertCorrectActiveStreams_ = function() {
if (!this.streamingEngine_ || !this.manifest_ || COMPILED) return;
if (!this.streamingEngine_ || !this.manifest_ || !goog.DEBUG) return;
var StreamUtils = shaka.util.StreamUtils;
var ContentType = shaka.util.ManifestParserUtils.ContentType;

Expand Down Expand Up @@ -2484,7 +2484,7 @@ shaka.Player.prototype.onChooseStreams_ = function(period) {
// Ignore deferred variant or text streams. We are starting a new period,
// so any deferred switches must logically have been from an older period.
// Verify this in uncompiled mode.
if (!COMPILED) {
if (goog.DEBUG) {
var deferredPeriodIndex;
var deferredPeriod;

Expand Down
2 changes: 1 addition & 1 deletion lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ shaka.util.Error = function(severity, category, code, var_args) {
this.handled = false;

// This improves formatting of Errors in failure messages in the tests.
if (!COMPILED) {
if (goog.DEBUG) {
var categoryName = 'UNKNOWN';
var codeName = 'UNKNOWN';

Expand Down

0 comments on commit 1224464

Please sign in to comment.