Skip to content

Commit

Permalink
Make decodeAudioData more precise. (WebAudio#1781)
Browse files Browse the repository at this point in the history
* Make decodeAudioData more precise.

This explicitely refers to the algorithm to use in mimesniff, and
adjusts the algorithm structure to be able to not attempt to decode if
the mimesniff algorithm failed.

This fixes WebAudio#1563.

* Address review comments.

* address more review comments
  • Loading branch information
padenot authored and rtoy committed Jan 17, 2019
1 parent 2f3f0fe commit 0e943c1
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,21 @@ Methods</h4>
Note: Multiple <em>decoding threads</em> can run in parallel to
service multiple calls to <code>decodeAudioData</code>.

1. Attempt to decode the encoded {{BaseAudioContext/decodeAudioData(audioData, successCallback, errorCallback)/audioData!!argument}} into linear
PCM.
1. Let <var>can decode</var> be a boolean flag, initially set to true.

2. If a decoding error is encountered due to the audio format
not being recognized or supported, or because of
corrupted/unexpected/inconsistent data, then <a>queue a task</a> to
2. Attempt to determine the MIME type of
{{BaseAudioContext/decodeAudioData(audioData, successCallback,
errorCallback)/audioData!!argument}}, using
[[mimesniff#matching-an-audio-or-video-type-pattern]]. If the audio or
video type pattern matching algorithm returns <code>undefined</code>,
set <var>can decode</var> to <em>false</em>.

3. If <var>can decode</var> is <em>true</em>, attempt to decode the encoded
{{BaseAudioContext/decodeAudioData(audioData, successCallback,
errorCallback)/audioData!!argument}} into linear PCM. In case of
failure, set <var>can decode</var> to <em>false</em>.

4. If <var>can decode</var> is <em>false</em>, <a>queue a task</a> to
execute the following step, on the <a>control thread</a>'s
event loop:

Expand All @@ -1148,7 +1157,7 @@ Methods</h4>

3. If {{BaseAudioContext/decodeAudioData()/errorCallback!!argument}} is not missing, invoke {{BaseAudioContext/decodeAudioData()/errorCallback!!argument}} with <var>error</var>.

3. Otherwise:
5. Otherwise:
1. Take the result, representing the decoded linear PCM
audio data, and resample it to the sample-rate of the
{{AudioContext}} if it is different from
Expand Down

0 comments on commit 0e943c1

Please sign in to comment.