Closed Bug 1000264 Opened 11 years ago Closed 11 years ago

Implement the new prototype for decodeAudioData, that returns a promise

Categories

(Core :: Web Audio, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: padenot, Assigned: padenot)

References

Details

Attachments

(4 files, 1 obsolete file)

Yay! :-)
Boris, Ehsan told me this would work, but to ask you for this one. Basically, we need to pass in an AudioBuffer when a Promise return from AudioContext.decodeAudioData is resolved, and AudioBuffers are not inheriting from nsISupports. Do you think this is this the right thing to do?
Attachment #8509670 - Flags: review?(bzbarsky)
Assignee: nobody → padenot
Status: NEW → ASSIGNED
Attached patch decodeaudiodata-promises (obsolete) — Splinter Review
Attachment #8509676 - Flags: review?(ehsan.akhgari)
Attached patch testSplinter Review
And some tests. This is separate from test_mediaDecode.html, because it only test that the promise work properly, not that the decoding works properly.
Attachment #8509679 - Flags: review?(ehsan.akhgari)
Attachment #8509676 - Attachment is patch: true
Attachment #8509679 - Attachment is patch: true
Comment on attachment 8509676 [details] [diff] [review] decodeaudiodata-promises Review of attachment 8509676 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/media/webaudio/MediaBufferDecoder.cpp @@ +591,5 @@ > ErrorResult rv; > mFailureCallback->Call(rv); > } > > + mPromise->MaybeReject(NS_ERROR_FAILURE); The spec says that we should reject the promise with EncodingError in this case, right?
Attachment #8509676 - Flags: review?(ehsan.akhgari) → review-
Comment on attachment 8509679 [details] [diff] [review] test Review of attachment 8509679 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/media/webaudio/MediaBufferDecoder.cpp @@ +544,5 @@ > // do about it here. > ErrorResult rv; > + if (mSuccessCallback) { > + mSuccessCallback->Call(*mOutput, rv); > + } I'd collapse all of these patches into one when landing, FWIW. ::: content/media/webaudio/test/test_decodeAudioDataPromise.html @@ +30,5 @@ > + p.then(function(data) { > + ok(false, "Promise should not resolve with an invalid source buffer."); > + finish(); > + }).catch(function() { > + ok(true, "Promise should be rejected with an invalid source buffer."); Please test the error that the promise is rejected with (see my comment about the other patch.)
Attachment #8509679 - Flags: review?(ehsan.akhgari) → review+
Comment on attachment 8509670 [details] [diff] [review] Allow an object that inherits from nsWrapperCache but not nsISupports to be passed as a Promise::MaybeResolve argument. r= Yeah, this seems fine. Especially given the IsDOMBinding() assert there. r=me
Attachment #8509670 - Flags: review?(bzbarsky) → review+
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #6) > Comment on attachment 8509679 [details] [diff] [review] > test > > Review of attachment 8509679 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: content/media/webaudio/MediaBufferDecoder.cpp > @@ +544,5 @@ > > // do about it here. > > ErrorResult rv; > > + if (mSuccessCallback) { > > + mSuccessCallback->Call(*mOutput, rv); > > + } > > I'd collapse all of these patches into one when landing, FWIW. Ha yes, for some reason I qrefed C++ code in the test. But yes, I'll squash them all into one. > ::: content/media/webaudio/test/test_decodeAudioDataPromise.html > @@ +30,5 @@ > > + p.then(function(data) { > > + ok(false, "Promise should not resolve with an invalid source buffer."); > > + finish(); > > + }).catch(function() { > > + ok(true, "Promise should be rejected with an invalid source buffer."); > > Please test the error that the promise is rejected with (see my comment > about the other patch.) Hrm, yes. It confuses me that EncodingError is defined in the StringEncoding spec, whereas we use it here to refer to audio encoding. That said, the message is not wrong per se ("EncodingError: The given encoding is not supported."), but decodeAudioData could fail in other ways with legal files.
Attachment #8509676 - Attachment is obsolete: true
Attachment #8510190 - Flags: review?(ehsan.akhgari) → review+
Comment on attachment 8510190 [details] [diff] [review] Make AudioContext.decodeAudioData return a promise. r= I forgot I needed another review for the WebIDL change. Spec is here: http://webaudio.github.io/web-audio-api/#widl-AudioContext-decodeAudioData-Promise-AudioBuffer--ArrayBuffer-audioData-DecodeSuccessCallback-successCallback-DecodeErrorCallback-errorCallback According to annevk, in the spec, the callback should not be fired directly, but off a task, I filed a bug and written a patch for the spec here: https://github.com/WebAudio/web-audio-api/issues/418. This is effectively what we do in Gecko (NS_DispatchToMainThread from the decoding thread, and then call the callback from there).
Attachment #8510190 - Flags: review+ → review?(bzbarsky)
Comment on attachment 8510190 [details] [diff] [review] Make AudioContext.decodeAudioData return a promise. r= >+ if (rv.Failed()) { Why not do this right after the CreatePromise call? r=me
Attachment #8510190 - Flags: review?(bzbarsky) → review+
Looks like it was a straight-up Linux failure (not e10s related).
Make that a failure across the board. Please make sure this is green on Try before relanding ;)
Comment on attachment 8522394 [details] [diff] [review] Stop checking exceptions on decodeAudioData now that it uses promises, and check it in the promise test file instead. r= >+ ok(e.name == "TypeError", "The error should be EncodingError"); I don't see how the name check there says anything about it being EncodingError. r=me apart from that
Attachment #8522394 - Flags: review?(bzbarsky) → review+
Yes sorry, it was jus me being confused.
Depends on: 1113925
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: