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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using namespace WebCore; 42 using namespace WebCore;
43 43
44 namespace WebKit { 44 namespace WebKit {
45 45
46 class WebAudioBusPrivate : public AudioBus { 46 class WebAudioBusPrivate : public AudioBus {
47 }; 47 };
48 48
49 void WebAudioBus::initialize(unsigned numberOfChannels, size_t length, double sa mpleRate) 49 void WebAudioBus::initialize(unsigned numberOfChannels, size_t length, double sa mpleRate)
50 { 50 {
51 #if ENABLE(WEB_AUDIO) 51 #if ENABLE(WEB_AUDIO)
52 AudioBus* audioBus = new AudioBus(numberOfChannels, length); 52 RefPtr<AudioBus> audioBus = AudioBus::create(numberOfChannels, length);
53 audioBus->setSampleRate(sampleRate); 53 audioBus->setSampleRate(sampleRate);
54 54
55 if (m_private) 55 if (m_private)
56 delete m_private; 56 (static_cast<AudioBus*>(m_private))->deref();
57 m_private = static_cast<WebAudioBusPrivate*>(audioBus); 57
58 audioBus->ref();
59 m_private = static_cast<WebAudioBusPrivate*>(audioBus.get());
58 #else 60 #else
59 ASSERT_NOT_REACHED(); 61 ASSERT_NOT_REACHED();
60 #endif 62 #endif
61 } 63 }
62 64
63 void WebAudioBus::resizeSmaller(size_t newLength) 65 void WebAudioBus::resizeSmaller(size_t newLength)
64 { 66 {
65 #if ENABLE(WEB_AUDIO) 67 #if ENABLE(WEB_AUDIO)
66 ASSERT(m_private); 68 ASSERT(m_private);
67 if (m_private) { 69 if (m_private) {
68 ASSERT(newLength <= length()); 70 ASSERT(newLength <= length());
69 m_private->resizeSmaller(newLength); 71 m_private->resizeSmaller(newLength);
70 } 72 }
71 #else 73 #else
72 ASSERT_NOT_REACHED(); 74 ASSERT_NOT_REACHED();
73 #endif 75 #endif
74 } 76 }
75 77
76 void WebAudioBus::reset() 78 void WebAudioBus::reset()
77 { 79 {
78 #if ENABLE(WEB_AUDIO) 80 #if ENABLE(WEB_AUDIO)
79 delete m_private; 81 if (m_private) {
80 m_private = 0; 82 (static_cast<AudioBus*>(m_private))->deref();
83 m_private = 0;
84 }
81 #else 85 #else
82 ASSERT_NOT_REACHED(); 86 ASSERT_NOT_REACHED();
83 #endif 87 #endif
84 } 88 }
85 89
86 unsigned WebAudioBus::numberOfChannels() const 90 unsigned WebAudioBus::numberOfChannels() const
87 { 91 {
88 #if ENABLE(WEB_AUDIO) 92 #if ENABLE(WEB_AUDIO)
89 if (!m_private) 93 if (!m_private)
90 return 0; 94 return 0;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 RefPtr<AudioBus> audioBus(adoptRef(static_cast<AudioBus*>(m_private))); 142 RefPtr<AudioBus> audioBus(adoptRef(static_cast<AudioBus*>(m_private)));
139 m_private = 0; 143 m_private = 0;
140 return audioBus; 144 return audioBus;
141 #else 145 #else
142 ASSERT_NOT_REACHED(); 146 ASSERT_NOT_REACHED();
143 return 0; 147 return 0;
144 #endif 148 #endif
145 } 149 }
146 150
147 } // namespace WebKit 151 } // namespace WebKit
OLDNEW
« 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