Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1389)

Unified Diff: Source/core/platform/chromium/support/WebAudioBus.cpp

Issue 14628008: Require use of AudioBus::create() to avoid ref-counting issues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Require use of Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/chromium/support/WebAudioBus.cpp
diff --git a/Source/core/platform/chromium/support/WebAudioBus.cpp b/Source/core/platform/chromium/support/WebAudioBus.cpp
index db360e33323c898da352ef656f7d97490df5997b..f09152d739c889ddd36bc07ba227d5b5d7968e36 100644
--- a/Source/core/platform/chromium/support/WebAudioBus.cpp
+++ b/Source/core/platform/chromium/support/WebAudioBus.cpp
@@ -49,12 +49,14 @@ class WebAudioBusPrivate : public AudioBus {
void WebAudioBus::initialize(unsigned numberOfChannels, size_t length, double sampleRate)
{
#if ENABLE(WEB_AUDIO)
- AudioBus* audioBus = new AudioBus(numberOfChannels, length);
+ RefPtr<AudioBus> audioBus = AudioBus::create(numberOfChannels, length);
audioBus->setSampleRate(sampleRate);
if (m_private)
- delete m_private;
- m_private = static_cast<WebAudioBusPrivate*>(audioBus);
+ (static_cast<AudioBus*>(m_private))->deref();
+
+ audioBus->ref();
+ m_private = static_cast<WebAudioBusPrivate*>(audioBus.get());
#else
ASSERT_NOT_REACHED();
#endif
@@ -76,8 +78,10 @@ void WebAudioBus::resizeSmaller(size_t newLength)
void WebAudioBus::reset()
{
#if ENABLE(WEB_AUDIO)
- delete m_private;
- m_private = 0;
+ if (m_private) {
+ (static_cast<AudioBus*>(m_private))->deref();
+ m_private = 0;
+ }
#else
ASSERT_NOT_REACHED();
#endif
« no previous file with comments | « Source/core/platform/audio/chromium/AudioDestinationChromium.cpp ('k') | Source/modules/webaudio/AudioDestinationNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698