fix comments and docs

This commit is contained in:
Radium Zheng 2018-08-08 11:58:38 +10:00
parent 4f1aaf89bf
commit 913c56c408
4 changed files with 44 additions and 20 deletions

View File

@ -251,8 +251,8 @@ export class WavAdapter extends AbstractAudioContextAdapter {
* using big endianness. Required by WAVE headers.
*
* @param {ArrayBuffer} view - The view to memory.
* @param {*} offset - Offset.
* @param {*} string - The string to be written.
* @param {number} offset - Offset.
* @param {string} string - The string to be written.
* @returns {void}
*/
function writeUTFBytes(view, offset, string) {
@ -267,9 +267,9 @@ function writeUTFBytes(view, offset, string) {
/**
* Helper function for converting Float32Array to Int16Array.
*
* @param {*} output - The output buffer.
* @param {*} offset - The offset in output buffer to write from.
* @param {*} inputBuffers - The input buffers.
* @param {DataView} output - View to the output buffer.
* @param {number} offset - The offset in output buffer to write from.
* @param {Float32Array[]} inputBuffers - The input buffers.
* @returns {void}
*/
function floatTo16BitPCM(output, offset, inputBuffers) {

View File

@ -17,17 +17,20 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
export class FlacAdapter extends AbstractAudioContextAdapter {
/**
* Instance of flacEncodeWorker.
* Instance of WebWorker (flacEncodeWorker).
*/
_encoder = null;
/**
* Resolve function of the promise returned by {@code stop()}.
* Resolve function of the Promise returned by {@code stop()}.
* This is called after the WebWorker sends back {@code WORKER_BLOB_READY}.
*/
_stopPromiseResolver = null;
_initPromiseResolver = null;
/**
* Resolve function of the Promise that initializes the flacEncodeWorker.
*/
_initWorkerPromiseResolver = null;
/**
* Initialization promise.
@ -152,8 +155,10 @@ export class FlacAdapter extends AbstractAudioContextAdapter {
reject();
}
// save the Promise's resolver to resolve it later.
this._initPromiseResolver = resolve;
// Save the Promise's resolver to resolve it later.
// This Promise is only resolved in _onWorkerMessage when we
// receive WORKER_LIBFLAC_READY from the WebWorker.
this._initWorkerPromiseResolver = resolve;
// set up listener for messages from the WebWorker
this._encoder.onmessage = this._onWorkerMessage;
@ -220,7 +225,7 @@ export class FlacAdapter extends AbstractAudioContextAdapter {
break;
case WORKER_LIBFLAC_READY:
logger.log('libflac is ready.');
this._initPromiseResolver();
this._initWorkerPromiseResolver();
break;
default:
logger.error(

View File

@ -90,8 +90,8 @@ const FLAC_COMPRESSION_LEVEL = 5;
/**
* Concat multiple Uint8Arrays into one.
*
* @param {Array} arrays - Array of Uint8 arrays.
* @param {*} totalLength - Total length of all Uint8Arrays.
* @param {Uint8Array[]} arrays - Array of Uint8 arrays.
* @param {number} totalLength - Total length of all Uint8Arrays.
* @returns {Uint8Array}
*/
function mergeUint8Arrays(arrays, totalLength) {
@ -320,8 +320,8 @@ class Encoder {
* This is invoked by libflac.
*
* @private
* @param {*} buffer - The encoded Flac data.
* @param {*} bytes - Number of bytes in the data.
* @param {Uint8Array} buffer - The encoded Flac data.
* @param {number} bytes - Number of bytes in the data.
* @returns {void}
*/
_onEncodedData(buffer, bytes) {

View File

@ -20,9 +20,28 @@ function highPrecisionTime(): number {
// Have to use string literal here, instead of Symbols,
// because these values need to be JSON-serializible.
/**
* Types of SessionEvents.
*/
const SessionEventType = Object.freeze({
/**
* Start of local recording session. This is recorded when the
* {@code RecordingController} receives the signal to start local recording,
* before the actual adapter is engaged.
*/
SESSION_STARTED: 'SESSION_STARTED',
/**
* Start of a continuous segment. This is recorded when the adapter is
* engaged. Can happen multiple times in a local recording session,
* due to browser reloads or switching of recording device.
*/
SEGMENT_STARTED: 'SEGMENT_STARTED',
/**
* End of a continuous segment. This is recorded when the adapter unengages.
*/
SEGMENT_ENDED: 'SEGMENT_ENDED'
});
@ -169,8 +188,8 @@ class SessionManager {
/**
* Creates a session if not exists.
*
* @param {string} sessionToken - .
* @param {string} format - .
* @param {string} sessionToken - The local recording session token.
* @param {string} format - The local recording format.
* @returns {void}
*/
createSession(sessionToken: string, format: string) {
@ -218,7 +237,7 @@ class SessionManager {
/**
* Removes session metadata.
*
* @param {*} sessionToken - The session token.
* @param {string} sessionToken - The session token.
* @returns {void}
*/
removeSession(sessionToken: string) {
@ -319,7 +338,7 @@ class SessionManager {
* {@code SessionEvent}s.
*
* @private
* @param {*} events - The array of {@code SessionEvent}s.
* @param {SessionEvent[]} events - The array of {@code SessionEvent}s.
* @returns {SegmentInfo[]}
*/
_constructSegments(events: SessionEvent[]): SegmentInfo[] {
@ -416,5 +435,5 @@ class SessionManager {
*/
export const sessionManager = new SessionManager();
// For debug only. Remove later.
// For debug only. To remove later.
window.sessionManager = sessionManager;