Skip to content

Commit fb080a0

Browse files
committed
Send done message instead of null page
It increases expressiveness of the interface
1 parent 716c0c7 commit fb080a0

File tree

9 files changed

+22
-25
lines changed

9 files changed

+22
-25
lines changed

dist-unminified/encoderWorker.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist-unminified/recorder.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-unminified/waveWorker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/encoderWorker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recorder.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/waveWorker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/encoderWorker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ OggOpusEncoder.prototype.encodeFinalFrame = function() {
119119
this.encode( finalFrameBuffers );
120120
this.headerType += 4;
121121
this.generatePage();
122-
global['postMessage']( {message: 'page', page: null} );
122+
global['postMessage']( {message: 'done'} );
123123
global['close']();
124124
};
125125

src/recorder.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Recorder.prototype.initWorker = function(){
138138
case 'page':
139139
onPage(e['data']['page']);
140140
break;
141+
case 'done':
142+
this.finish();
143+
break;
141144
}
142145
});
143146
this.encoder.postMessage( Object.assign({
@@ -209,31 +212,25 @@ Recorder.prototype.stop = function(){
209212
};
210213

211214
Recorder.prototype.storePage = function( page ) {
212-
if ( page === null ) {
215+
this.recordedPages.push( page );
216+
this.totalLength += page.length;
217+
};
218+
219+
Recorder.prototype.streamPage = function( page ) {
220+
this.ondataavailable( page );
221+
};
222+
223+
Recorder.prototype.finish = function() {
224+
if( !this.config.streamPages ) {
213225
var outputData = new Uint8Array( this.totalLength );
214226
this.recordedPages.reduce( function( offset, page ){
215227
outputData.set( page, offset );
216228
return offset + page.length;
217229
}, 0);
218230

219231
this.ondataavailable( outputData );
220-
this.onstop();
221-
}
222-
223-
else {
224-
this.recordedPages.push( page );
225-
this.totalLength += page.length;
226-
}
227-
};
228-
229-
Recorder.prototype.streamPage = function( page ) {
230-
if ( page === null ) {
231-
this.onstop();
232-
}
233-
234-
else {
235-
this.ondataavailable( page );
236232
}
233+
this.onstop();
237234
};
238235

239236

0 commit comments

Comments
 (0)