Implement OfflineAudioContext

RESOLVED FIXED in mozilla24

Status

()

RESOLVED FIXED
6 years ago
2 years ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

({dev-doc-complete})

Trunk
mozilla24
x86
macOS
dev-doc-complete
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(15 attachments, 5 obsolete attachments)

4.59 KB, patch
roc
: review+
Details | Diff | Splinter Review
3.41 KB, patch
roc
: review+
Details | Diff | Splinter Review
2.81 KB, patch
roc
: review+
Details | Diff | Splinter Review
2.26 KB, patch
roc
: review+
Details | Diff | Splinter Review
1.84 KB, patch
roc
: review+
Details | Diff | Splinter Review
1.21 KB, patch
roc
: review+
Details | Diff | Splinter Review
12.79 KB, patch
roc
: review+
Ehsan
: checkin+
Details | Diff | Splinter Review
2.89 KB, patch
roc
: review+
Details | Diff | Splinter Review
6.76 KB, patch
roc
: review+
Details | Diff | Splinter Review
5.18 KB, patch
Details | Diff | Splinter Review
8.44 KB, patch
Details | Diff | Splinter Review
9.84 KB, patch
roc
: review+
Details | Diff | Splinter Review
16.96 KB, patch
roc
: review+
Details | Diff | Splinter Review
8.96 KB, patch
Details | Diff | Splinter Review
8.35 KB, patch
roc
: review+
Details | Diff | Splinter Review
(Assignee)

Description

6 years ago
roc, do you know what underlying assumptions MediaStreamsGraphImpl makes about the underlying hardware, such as the number of channels, sample rate, etc.?

Thanks!
(Assignee)

Comment 1

6 years ago
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
Attachment #709855 - Flags: review?(roc)
(Assignee)

Comment 7

6 years ago
I haven't finished the rest of the patches in this series yet so I won't attach them to the bug just now, but we should be able to land the first 6 parts now.
Note that bug 836850 is now fixed, so we can just use a single class here if desired.
(Assignee)

Comment 11

6 years ago
(In reply to Boris Zbarsky (:bz) from comment #10)
> Note that bug 836850 is now fixed, so we can just use a single class here if
> desired.

Yes, thanks!
Depends on: 836850
(Assignee)

Updated

6 years ago
Whiteboard: [leave open]
(Assignee)

Updated

6 years ago
Depends on: 859600
(Assignee)

Comment 12

6 years ago
This currently passes try.  I'd like to land this part sooner.  I'm working on the rest.
Attachment #746745 - Flags: review?(roc)
Comment on attachment 746745 [details] [diff] [review]
Part 7: Implement a non-realtime API in MediaStreamGraph

Review of attachment 746745 [details] [diff] [review]:
-----------------------------------------------------------------

Nice!
Attachment #746745 - Flags: review?(roc) → review+
(Assignee)

Updated

6 years ago
Whiteboard: [leave open]
(Assignee)

Comment 14

6 years ago
Comment on attachment 746745 [details] [diff] [review]
Part 7: Implement a non-realtime API in MediaStreamGraph

https://hg.mozilla.org/integration/mozilla-inbound/rev/c97a67b4ec08
Attachment #746745 - Flags: checkin+
(Assignee)

Updated

6 years ago
Depends on: 871226
(Assignee)

Updated

6 years ago
Depends on: 872635
(Assignee)

Updated

6 years ago
Whiteboard: [leave open]
(Assignee)

Comment 17

6 years ago
Attachment #749984 - Flags: review?(roc)
(Assignee)

Comment 19

6 years ago
Attachment #749987 - Flags: review?(roc)
(Assignee)

Comment 23

6 years ago
(Assignee)

Updated

6 years ago
Blocks: 872394
(Assignee)

Comment 24

6 years ago
Try is happy with this stuff: https://tbpl.mozilla.org/?tree=Try&rev=b4da97aa2e0f
Comment on attachment 749983 [details] [diff] [review]
Part 8: Add a non-realtime media graph API to produce a given number of ticks

Review of attachment 749983 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/media/MediaStreamGraphImpl.h
@@ +531,5 @@
>     */
>    bool mRealtime;
> +  /**
> +   * True when a non-realtime MediaStreamGraph has started to process input.  This
> +   * value is always set to true on the main thread.

"only accessed on the main thread"
Attachment #749983 - Flags: review?(roc) → review+
Comment on attachment 749987 [details] [diff] [review]
Part 11: Implement the processing of OfflineAudioContext

Review of attachment 749987 [details] [diff] [review]:
-----------------------------------------------------------------

I actually think we should run the entire graph at the OfflineAudioContext's rate. Sorry, I know that's a big change and maybe difficult, but it seems like the right thing to do.

If you want to take a shortcut and only support OfflineAudioContext with the IdealAudioRate, we can do that for now to get tests working better.
Comment on attachment 749988 [details] [diff] [review]
Part 12: Fix the lifetime management of the Web Audio graph in presence of OfflineAudioContexts

Review of attachment 749988 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/media/webaudio/AudioDestinationNode.cpp
@@ +253,5 @@
>    mStream = graph->CreateAudioNodeStream(engine, MediaStreamGraph::EXTERNAL_STREAM);
>  }
>  
> +void
> +AudioDestinationNode::DestroyGraphIfNeeded()

This seems like a poor name, since you unconditionally destroy the graph.
(Assignee)

Comment 28

6 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #26)
> Comment on attachment 749987 [details] [diff] [review]
> Part 11: Implement the processing of OfflineAudioContext
> 
> Review of attachment 749987 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I actually think we should run the entire graph at the OfflineAudioContext's
> rate. Sorry, I know that's a big change and maybe difficult, but it seems
> like the right thing to do.

Hmm, why do you think that we should do that?  That pretty much breaks everything that depends on the current assumption that the graph runs at 48KHz...

> If you want to take a shortcut and only support OfflineAudioContext with the
> IdealAudioRate, we can do that for now to get tests working better.

No matter what we decide to do eventually, I definitely don't want to make that big of a change here, since we need this sooner rather than later...  We can always do that later, and it should be transparent as far as content is concerned.
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #28)
> (In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #26)
> > Comment on attachment 749987 [details] [diff] [review]
> > Part 11: Implement the processing of OfflineAudioContext
> > 
> > Review of attachment 749987 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > I actually think we should run the entire graph at the OfflineAudioContext's
> > rate. Sorry, I know that's a big change and maybe difficult, but it seems
> > like the right thing to do.
> 
> Hmm, why do you think that we should do that?  That pretty much breaks
> everything that depends on the current assumption that the graph runs at
> 48KHz...

Why? Using OfflineAudioContext you can specify that the rate is 48KHz, which is actually *more* reliable than assuming AudioContext's rate is 48KHz!

That's one reason I think we should do that; if someone wants processing to happen at a certain rate, we can and should support that in OfflineAudioContext.

> > If you want to take a shortcut and only support OfflineAudioContext with the
> > IdealAudioRate, we can do that for now to get tests working better.
> 
> No matter what we decide to do eventually, I definitely don't want to make
> that big of a change here, since we need this sooner rather than later... 
> We can always do that later, and it should be transparent as far as content
> is concerned.

OK.
(Assignee)

Comment 30

6 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #29)
> (In reply to :Ehsan Akhgari (needinfo? me!) from comment #28)
> > (In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #26)
> > > Comment on attachment 749987 [details] [diff] [review]
> > > Part 11: Implement the processing of OfflineAudioContext
> > > 
> > > Review of attachment 749987 [details] [diff] [review]:
> > > -----------------------------------------------------------------
> > > 
> > > I actually think we should run the entire graph at the OfflineAudioContext's
> > > rate. Sorry, I know that's a big change and maybe difficult, but it seems
> > > like the right thing to do.
> > 
> > Hmm, why do you think that we should do that?  That pretty much breaks
> > everything that depends on the current assumption that the graph runs at
> > 48KHz...
> 
> Why? Using OfflineAudioContext you can specify that the rate is 48KHz, which
> is actually *more* reliable than assuming AudioContext's rate is 48KHz!

Well, we make assumptions about IdealAudioRate() all around the code base.  If we want to change that, all of the existing code must be audited to make sure we don't break things.  (At least we should change all callers of IdealAudioRate.)

> That's one reason I think we should do that; if someone wants processing to
> happen at a certain rate, we can and should support that in
> OfflineAudioContext.

Hmm, I guess there's actually a content visible difference for a-rate AudioParams...  I was not paying attention to that. :(

> > > If you want to take a shortcut and only support OfflineAudioContext with the
> > > IdealAudioRate, we can do that for now to get tests working better.
> > 
> > No matter what we decide to do eventually, I definitely don't want to make
> > that big of a change here, since we need this sooner rather than later... 
> > We can always do that later, and it should be transparent as far as content
> > is concerned.
> 
> OK.

To confirm my understanding, do you mean throwing when you try to create an OfflineAudioContext with a different rate for now, or leave the patch as is?  (I slightly prefer to leave it as is)
(Assignee)

Comment 31

6 years ago
(with the nit addressed)
Attachment #749983 - Attachment is obsolete: true
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #30)
> To confirm my understanding, do you mean throwing when you try to create an
> OfflineAudioContext with a different rate for now, or leave the patch as is?
> (I slightly prefer to leave it as is)

Throw, I think.
(Assignee)

Comment 34

6 years ago
(In reply to comment #33)
> (In reply to :Ehsan Akhgari (needinfo? me!) from comment #30)
> > To confirm my understanding, do you mean throwing when you try to create an
> > OfflineAudioContext with a different rate for now, or leave the patch as is?
> > (I slightly prefer to leave it as is)
> 
> Throw, I think.

OK, I'll do that tomorrow though.  Not feeling well right now...
(Assignee)

Comment 35

6 years ago
Attachment #749984 - Attachment is obsolete: true
Attachment #750399 - Flags: review?(roc)
(Assignee)

Comment 37

6 years ago
Attachment #749987 - Attachment is obsolete: true
Attachment #749987 - Flags: review?(roc)
Attachment #750401 - Flags: review?(roc)
Comment on attachment 750401 [details] [diff] [review]
Part 11: Implement the processing of OfflineAudioContext

Review of attachment 750401 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/media/webaudio/AudioDestinationNode.cpp
@@ +31,5 @@
> +    // These allocations might fail if content provides a huge number of
> +    // channels or size, but it's OK since we'll deal with the failure
> +    // gracefully.
> +    if (mInputChannels.SetLength(aNumberOfChannels)) {
> +      static const fallible_t fallible = fallible_t();

Factoring this out seems pointless. Just use new (fallible_t()).

@@ +108,5 @@
> +      {
> +        // If it's not safe to run scripts right now, schedule this to run later
> +        if (!nsContentUtils::IsSafeToRunScript()) {
> +          nsContentUtils::AddScriptRunner(this);
> +          return NS_OK;

Unnecessary. It's always safe to run script in an nsRunnable dispatched to the main thread.

@@ +165,1 @@
>    uint32_t mLength;

Please document the meaning of mWriteIndex and mLength. And mInputChannels.
Attachment #750401 - Flags: review?(roc) → review+
(Assignee)

Comment 39

6 years ago
(In reply to comment #38)
> @@ +108,5 @@
> > +      {
> > +        // If it's not safe to run scripts right now, schedule this to run later
> > +        if (!nsContentUtils::IsSafeToRunScript()) {
> > +          nsContentUtils::AddScriptRunner(this);
> > +          return NS_OK;
> 
> Unnecessary. It's always safe to run script in an nsRunnable dispatched to the
> main thread.

See bug 865233 comment 8.  :-)
Gah. We should have NS_DispatchToMainThreadWhenSafeToRunScript or something like that. OK.
(Assignee)

Comment 41

6 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #38)
> Comment on attachment 750401 [details] [diff] [review]
> Part 11: Implement the processing of OfflineAudioContext
> 
> Review of attachment 750401 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: content/media/webaudio/AudioDestinationNode.cpp
> @@ +31,5 @@
> > +    // These allocations might fail if content provides a huge number of
> > +    // channels or size, but it's OK since we'll deal with the failure
> > +    // gracefully.
> > +    if (mInputChannels.SetLength(aNumberOfChannels)) {
> > +      static const fallible_t fallible = fallible_t();
> 
> Factoring this out seems pointless. Just use new (fallible_t()).

That seems to confuse the compiler, since it doesn't know whether we mean to allocate a fallible_t or not. :(
(Assignee)

Comment 42

6 years ago
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #40)
> Gah. We should have NS_DispatchToMainThreadWhenSafeToRunScript or something
> like that. OK.

Agreed! Filed bug 873292.
Keywords: dev-doc-needed
(Assignee)

Updated

6 years ago
Depends on: 873553
(Assignee)

Comment 45

6 years ago
Mass moving Web Audio bugs to the Web Audio component.  Filter on duckityduck.
Component: Video/Audio → Web Audio
Depends on: 910171
Documented. https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext
Keywords: dev-doc-needed → dev-doc-complete

Updated

2 years ago
Depends on: 1388591
You need to log in before you can comment on or make changes to this bug.