WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
76417
Only create AudioBus with required number of channels for AudioNodeOutput
https://bugs.webkit.org/show_bug.cgi?id=76417
Summary
Only create AudioBus with required number of channels for AudioNodeOutput
Raymond
Reported
2012-01-16 19:00:11 PST
Only create AudioBus with required number of channels for AudioNodeOutput
Attachments
Patch
(5.88 KB, patch)
2012-01-16 20:08 PST
,
Raymond
no flags
Details
Formatted Diff
Diff
Patch
(5.96 KB, patch)
2012-01-17 17:50 PST
,
Raymond
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Raymond
Comment 1
2012-01-16 20:08:18 PST
Created
attachment 122705
[details]
Patch
Raymond
Comment 2
2012-01-16 20:10:12 PST
Hi this patch is aim to create AudioBus on demand for AudioNodeOutput to : 1. Save memory 2. Help to support multi-channels for WebAudio later more easily. My goal is also apply this to AudioNodeInput, While since AudioNodeInput's case is slightly complicated than AudioNodeOutput due to the similar change might involve changes in AudioNode's checkNumberOfChannelsForInput and thus its subclass, So I would prefer to do it in a separate patch when this patch is accepted. One thing I am not quite sure is that it seems to me the original design is to pre-allocate all memories upon node creation, is that aim to help the render thread run more smoothly? However, since this memory allocation work is done at the beginning or end of a rendering quantum, and also in some audio processor class they also do memory allocations upon channels change, so I think this might not be a big deal, and after all, channels number rarely changes.
Chris Rogers
Comment 3
2012-01-17 14:13:22 PST
Raymond, thanks for the patch. As it stands right now the re-allocation of AudioBus is not thread-safe with the audio thread. For example, a mono bus might be deleted and a new stereo bus created, but meanwhile the audio thread is using the mono bus. Two solutions I can see: 1) Waste even more memory and allocate storage for up to six channels. This doesn't seem like a great solution 2) Make it thread-safe using a similar approach to what we now do for connections (see pre and post-render tasks in AudioContext)
Raymond
Comment 4
2012-01-17 17:21:14 PST
(In reply to
comment #3
)
> Raymond, thanks for the patch. > > As it stands right now the re-allocation of AudioBus is not thread-safe with the audio thread. For example, a mono bus might be deleted and a new stereo bus created, but meanwhile the audio thread is using the mono bus. > > Two solutions I can see: > > 1) Waste even more memory and allocate storage for up to six channels. This doesn't seem like a great solution > > 2) Make it thread-safe using a similar approach to what we now do for connections (see pre and post-render tasks in AudioContext)
Hi Roger thanks for the review. I did pay attention to the thread-safe issue, while maybe I miss some code path? But as far as I can see at present: AudioNodeOutput::updateInternalBus is called by AudioNodeOutput::updateNumberOfChannels which is called by two function : AudioNodeOutput::updateRenderingState and AudioNodeOutput::setNumberOfChannels. In both case, AudioNodeOutput::updateNumberOfChannels will only be invoked at the very start or end of a rendering quantum, which is the same case as the connections handle dirty input/output node. so is there any other case I miss here?
Chris Rogers
Comment 5
2012-01-17 17:33:10 PST
(In reply to
comment #4
)
> (In reply to
comment #3
) > > Raymond, thanks for the patch. > > > > As it stands right now the re-allocation of AudioBus is not thread-safe with the audio thread. For example, a mono bus might be deleted and a new stereo bus created, but meanwhile the audio thread is using the mono bus. > > > > Two solutions I can see: > > > > 1) Waste even more memory and allocate storage for up to six channels. This doesn't seem like a great solution > > > > 2) Make it thread-safe using a similar approach to what we now do for connections (see pre and post-render tasks in AudioContext) > > Hi Roger > > thanks for the review. I did pay attention to the thread-safe issue, while maybe I miss some code path? But as far as I can see at present: > > AudioNodeOutput::updateInternalBus is called by AudioNodeOutput::updateNumberOfChannels which is called by two function : AudioNodeOutput::updateRenderingState and AudioNodeOutput::setNumberOfChannels. > > In both case, AudioNodeOutput::updateNumberOfChannels will only be invoked at the very start or end of a rendering quantum, which is the same case as the connections handle dirty input/output node. > > so is there any other case I miss here?
Sorry, you're right. I even see we have an ASSERT in updateNumberOfChannels()... This looks fine to me with one minor comment fix (but I'm not a reviewer). by the way, no worries, but my name is "Chris" :)
Chris Rogers
Comment 6
2012-01-17 17:34:22 PST
Comment on
attachment 122705
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=122705&action=review
> Source/WebCore/webaudio/AudioNodeOutput.h:113 > + // m_internalBus must only be changed in the audio thread (or constructor).
It would be good to be exact here about where in the audio thread it's safe: "in the audio thread" -> "in the audio thread with the context's graph lock"
Raymond
Comment 7
2012-01-17 17:41:53 PST
(In reply to
comment #6
)
> (From update of
attachment 122705
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=122705&action=review
> > > Source/WebCore/webaudio/AudioNodeOutput.h:113 > > + // m_internalBus must only be changed in the audio thread (or constructor). > > It would be good to be exact here about where in the audio thread it's safe: > > "in the audio thread" -> "in the audio thread with the context's graph lock"
Oh, right, exactly. I will update the patch. Thanks Chris ;)
Raymond
Comment 8
2012-01-17 17:50:52 PST
Created
attachment 122852
[details]
Patch
Chris Rogers
Comment 9
2012-01-18 14:26:35 PST
Thanks - looks fine to me!
Kenneth Russell
Comment 10
2012-01-18 17:55:10 PST
Comment on
attachment 122852
[details]
Patch rs=me based on crogers' review.
WebKit Review Bot
Comment 11
2012-01-18 19:23:11 PST
Comment on
attachment 122852
[details]
Patch Clearing flags on attachment: 122852 Committed
r105373
: <
http://trac.webkit.org/changeset/105373
>
WebKit Review Bot
Comment 12
2012-01-18 19:23:15 PST
All reviewed patches have been landed. Closing bug.
Roland Steiner
Comment 13
2012-01-18 23:55:39 PST
In line 50: ASSERT(numberOfChannels >= 0 && numberOfChannels <= MaxNumberOfChannels); numberOfChannels is 'unsigned', so it's always >= 0 (this causes compile issues when warnings are treated as errors)
Raymond
Comment 14
2012-01-19 00:00:18 PST
(In reply to
comment #13
)
> In line 50: ASSERT(numberOfChannels >= 0 && numberOfChannels <= MaxNumberOfChannels); > > numberOfChannels is 'unsigned', so it's always >= 0 (this causes compile issues when warnings are treated as errors)
oops... will try to fix this issue together with other patch later.
Roland Steiner
Comment 15
2012-01-19 00:31:58 PST
I took the liberty and removed that part of the clause in
r105390
.
Raymond
Comment 16
2012-01-19 16:42:17 PST
(In reply to
comment #15
)
> I took the liberty and removed that part of the clause in
r105390
.
Thanks a lot!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug