* Queues an encoded audio chunk to be decoded.
(chunk: EncodedAudioChunk)
| 173 | * Queues an encoded audio chunk to be decoded. |
| 174 | */ |
| 175 | decode(chunk: EncodedAudioChunk) { |
| 176 | // Spec: If [[state]] is not "configured", throw an InvalidStateError. |
| 177 | if (this._state !== 'configured') { |
| 178 | throw new DOMException('Decoder is not configured', 'InvalidStateError'); |
| 179 | } |
| 180 | |
| 181 | // Spec: If [[key chunk required]] is true: |
| 182 | if (this._keyChunkRequired) { |
| 183 | // If chunk.type is not key, throw a DataError. |
| 184 | if (chunk.type !== 'key') { |
| 185 | throw new DOMException('Key frame required', 'DataError'); |
| 186 | } |
| 187 | // Otherwise, assign false to [[key chunk required]]. |
| 188 | this._keyChunkRequired = false; |
| 189 | } |
| 190 | |
| 191 | // Spec: Increment [[decodeQueueSize]]. |
| 192 | this._decodeQueueSize++; |
| 193 | |
| 194 | // Spec: Queue a control message to decode the chunk. |
| 195 | this.decodeInternal(chunk) |
| 196 | .catch(e => this.handleAsyncError(e)); |
| 197 | } |
| 198 | |
| 199 | private outputData(currentConfigId: number) { |
| 200 | if (this.currentConfigId !== currentConfigId) { |
no test coverage detected