Bladeren bron

Don't attempt to get/set index when no buffer was written yet

phoboslab 7 jaren geleden
bovenliggende
commit
7b909ef2c5
2 gewijzigde bestanden met toevoegingen van 18 en 0 verwijderingen
  1. 9 0
      src/mp2-wasm.js
  2. 9 0
      src/mpeg1-wasm.js

+ 9 - 0
src/mp2-wasm.js Bestand weergeven

31
 };
31
 };
32
 
32
 
33
 MP2WASM.prototype.destroy = function() {
33
 MP2WASM.prototype.destroy = function() {
34
+	if (!this.decoder) {
35
+		return;
36
+	}
34
 	this.functions._mp2_decoder_destroy(this.decoder);
37
 	this.functions._mp2_decoder_destroy(this.decoder);
35
 };
38
 };
36
 
39
 
37
 MP2WASM.prototype.bufferGetIndex = function() {
40
 MP2WASM.prototype.bufferGetIndex = function() {
41
+	if (!this.decoder) {
42
+		return;
43
+	}
38
 	return this.functions._mp2_decoder_get_index(this.decoder);
44
 	return this.functions._mp2_decoder_get_index(this.decoder);
39
 };
45
 };
40
 
46
 
41
 MP2WASM.prototype.bufferSetIndex = function(index) {
47
 MP2WASM.prototype.bufferSetIndex = function(index) {
48
+	if (!this.decoder) {
49
+		return;
50
+	}
42
 	this.functions._mp2_decoder_set_index(this.decoder, index);
51
 	this.functions._mp2_decoder_set_index(this.decoder, index);
43
 };
52
 };
44
 
53
 

+ 9 - 0
src/mpeg1-wasm.js Bestand weergeven

29
 };
29
 };
30
 
30
 
31
 MPEG1WASM.prototype.destroy = function() {
31
 MPEG1WASM.prototype.destroy = function() {
32
+	if (!this.decoder) {
33
+		return;
34
+	}
32
 	this.functions._mpeg1_decoder_destroy(this.decoder);
35
 	this.functions._mpeg1_decoder_destroy(this.decoder);
33
 };
36
 };
34
 
37
 
35
 MPEG1WASM.prototype.bufferGetIndex = function() {
38
 MPEG1WASM.prototype.bufferGetIndex = function() {
39
+	if (!this.decoder) {
40
+		return;
41
+	}
36
 	return this.functions._mpeg1_decoder_get_index(this.decoder);
42
 	return this.functions._mpeg1_decoder_get_index(this.decoder);
37
 };
43
 };
38
 
44
 
39
 MPEG1WASM.prototype.bufferSetIndex = function(index) {
45
 MPEG1WASM.prototype.bufferSetIndex = function(index) {
46
+	if (!this.decoder) {
47
+		return;
48
+	}
40
 	this.functions._mpeg1_decoder_set_index(this.decoder, index);
49
 	this.functions._mpeg1_decoder_set_index(this.decoder, index);
41
 };
50
 };
42
 
51