WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
137464
Take Web Audio into account for the Page::isPlayingAudio() API
https://bugs.webkit.org/show_bug.cgi?id=137464
Summary
Take Web Audio into account for the Page::isPlayingAudio() API
Ada Chan
Reported
2014-10-06 14:35:15 PDT
Page::isPlayingAudio(), first added in
https://bugs.webkit.org/show_bug.cgi?id=137218
, does not take into account AudioNodes that are playing audio yet. We need to support that.
Attachments
Patch
(29.43 KB, patch)
2014-11-18 15:43 PST
,
Ada Chan
no flags
Details
Formatted Diff
Diff
Revised patch: incorporated feedback from Jer and Chris.
(25.35 KB, patch)
2014-11-19 11:49 PST
,
Ada Chan
jer.noble
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Ada Chan
Comment 1
2014-11-18 15:43:49 PST
Created
attachment 241821
[details]
Patch
Jer Noble
Comment 2
2014-11-18 16:15:59 PST
Comment on
attachment 241821
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=241821&action=review
> Source/WebCore/platform/audio/ios/AudioDestinationIOS.cpp:198 > + if (!result) { > m_isPlaying = true; > + updateIsEffectivelyPlayingAudio(); > + }
We should add a "void setPlaying(bool)" to avoid duplicated code here...
> Source/WebCore/platform/audio/ios/AudioDestinationIOS.cpp:213 > - if (!result) > + if (!result) { > m_isPlaying = false; > + updateIsEffectivelyPlayingAudio(); > + }
...And here.
> Source/WebCore/platform/audio/ios/AudioDestinationIOS.cpp:245 > +void AudioDestinationIOS::updateIsSilent() > +{ > + bool isSilent = true; > + for (unsigned i = 0; i < m_renderBus->numberOfChannels(); ++i) { > + AudioChannel* channel = m_renderBus->channel(i); > + if (!channel->isSilent()) { > + isSilent = false; > + break; > + } > + }
AudioBus has an isSilent() member which returns true if all channels are silent. You shouldn't have to write this loop yourself. In fact, this could probably be a "void setSilent(bool)" method, and you could call "setSilent(m_renderBus.isSilent())" from render() above.
> Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp:151 > - if (!result) > + if (!result) { > m_isPlaying = true; > + updateIsEffectivelyPlayingAudio(); > + }
And since there's nothing platform specific here, perhaps we should move this up into the AudioDestinationNode class, in AudioDestinationNode::render().
> Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp:161 > - if (!result) > + if (!result) { > m_isPlaying = false; > + updateIsEffectivelyPlayingAudio(); > + }
Ditto.
> Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp:209 > +void AudioDestinationMac::updateIsSilent() > +{ > + bool isSilent = true; > + for (unsigned i = 0; i < m_renderBus->numberOfChannels(); ++i) { > + AudioChannel* channel = m_renderBus->channel(i); > + if (!channel->isSilent()) { > + isSilent = false; > + break; > + } > + } > + > + if (isSilent != m_isSilent) { > + m_isSilent = isSilent; > + updateIsEffectivelyPlayingAudio(); > + } > +} > + > +void AudioDestinationMac::updateIsEffectivelyPlayingAudio() > +{ > + bool isEffectivelyPlayingAudio = isPlaying() && !isSilent(); > + if (isEffectivelyPlayingAudio != m_isEffectivelyPlayingAudio) { > + m_isEffectivelyPlayingAudio = isEffectivelyPlayingAudio; > + m_callback.isPlayingAudioDidChange(); > + } > +}
Ditto.
Chris Dumez
Comment 3
2014-11-18 17:39:38 PST
Comment on
attachment 241821
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=241821&action=review
> LayoutTests/webaudio/web-audio-is-playing.html:4 > + <script type="text/javascript" src="../resources/js-test-pre.js"></script>
nit: Can omit the type as this is the default.
> LayoutTests/webaudio/web-audio-is-playing.html:32 > + }, 300);
Would it work with a 0 delay? It is really so that we need to wait that long, I am worried that test is going to be flaky.
Ada Chan
Comment 4
2014-11-18 23:25:57 PST
(In reply to
comment #2
) Thanks for your feedback, Jer! I'll update my patch.
Ada Chan
Comment 5
2014-11-18 23:29:25 PST
(In reply to
comment #3
)
> Comment on
attachment 241821
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=241821&action=review
> > > LayoutTests/webaudio/web-audio-is-playing.html:4 > > + <script type="text/javascript" src="../resources/js-test-pre.js"></script> > > nit: Can omit the type as this is the default.
OK, will fix.
> > > LayoutTests/webaudio/web-audio-is-playing.html:32 > > + }, 300); > > Would it work with a 0 delay? It is really so that we need to wait that > long, I am worried that test is going to be flaky.
Yes, I've tested with different delays and values less than this one do not pass consistently. Do you have suggestions on other ways to test this? This test also produces a very short beep.
Chris Dumez
Comment 6
2014-11-19 09:15:10 PST
Comment on
attachment 241821
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=241821&action=review
>>> LayoutTests/webaudio/web-audio-is-playing.html:32 >>> + }, 300); >> >> Would it work with a 0 delay? It is really so that we need to wait that long, I am worried that test is going to be flaky. > > Yes, I've tested with different delays and values less than this one do not pass consistently. Do you have suggestions on other ways to test this? This test also produces a very short beep.
You should probably use shouldBecomeEqual() from js-test-pre.js. I think it is used exactly for such cases.
Ada Chan
Comment 7
2014-11-19 11:49:43 PST
Created
attachment 241873
[details]
Revised patch: incorporated feedback from Jer and Chris.
Ada Chan
Comment 8
2014-11-19 14:59:32 PST
Committed:
http://trac.webkit.org/changeset/176350
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