Source/WebCore/ChangeLog

 12013-01-14 Mark Pilgrim <pilgrim@chromium.org>
 2
 3 [Chromium] Move AudioDestinationChromium into WebCore
 4 https://bugs.webkit.org/show_bug.cgi?id=106803
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This doesn't really belong in WebKit/chromium/src since it defines
 9 things directly in the WebCore namespace.
 10
 11 * WebCore.gypi:
 12 * platform/audio/chromium/AudioDestinationChromium.cpp: Added.
 13 (WebCore):
 14 (WebCore::AudioDestination::create):
 15 (WebCore::AudioDestinationChromium::AudioDestinationChromium):
 16 (WebCore::AudioDestinationChromium::~AudioDestinationChromium):
 17 (WebCore::AudioDestinationChromium::start):
 18 (WebCore::AudioDestinationChromium::stop):
 19 (WebCore::AudioDestination::hardwareSampleRate):
 20 (WebCore::AudioDestinationChromium::render):
 21 (WebCore::AudioDestinationChromium::provideInput):
 22 * platform/audio/chromium/AudioDestinationChromium.h: Added.
 23 (WebCore):
 24 (AudioDestinationChromium):
 25 (WebCore::AudioDestinationChromium::isPlaying):
 26 (WebCore::AudioDestinationChromium::sampleRate):
 27
1282013-01-14 Kentaro Hara <haraken@chromium.org>
229
330 [V8] Make an Isolate parameter mandatory in associateObjectWithWrapper()
139622

Source/WebCore/WebCore.gypi

36163616 'platform/audio/ZeroPole.cpp',
36173617 'platform/audio/ZeroPole.h',
36183618 'platform/audio/chromium/AudioBusChromium.cpp',
 3619 'platform/audio/chromium/AudioDestinationChromium.cpp',
 3620 'platform/audio/chromium/AudioDestinationChromium.h',
36193621 'platform/audio/mac/AudioBusMac.mm',
36203622 'platform/audio/mac/AudioDestinationMac.cpp',
36213623 'platform/audio/mac/AudioDestinationMac.h',
139622

Source/WebCore/platform/audio/chromium/AudioDestinationChromium.cpp

 1/*
 2 * Copyright (C) 2010 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 14 * its contributors may be used to endorse or promote products derived
 15 * from this software without specific prior written permission.
 16 *
 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27 */
 28
 29#include "config.h"
 30
 31#if ENABLE(WEB_AUDIO)
 32#include "AudioDestinationChromium.h"
 33
 34#include "AudioFIFO.h"
 35#include "AudioPullFIFO.h"
 36#include <public/Platform.h>
 37
 38using namespace WebKit;
 39
 40namespace WebCore {
 41
 42// Buffer size at which the web audio engine will render.
 43const unsigned renderBufferSize = 128;
 44
 45// Size of the FIFO
 46const size_t fifoSize = 8192;
 47
 48// Factory method: Chromium-implementation
 49PassOwnPtr<AudioDestination> AudioDestination::create(AudioIOCallback& callback, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
 50{
 51 return adoptPtr(new AudioDestinationChromium(callback, numberOfInputChannels, numberOfOutputChannels, sampleRate));
 52}
 53
 54AudioDestinationChromium::AudioDestinationChromium(AudioIOCallback& callback, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
 55 : m_callback(callback)
 56 , m_numberOfOutputChannels(numberOfOutputChannels)
 57 , m_inputBus(numberOfInputChannels, renderBufferSize)
 58 , m_renderBus(numberOfOutputChannels, renderBufferSize, false)
 59 , m_sampleRate(sampleRate)
 60 , m_isPlaying(false)
 61{
 62 // Use the optimal buffer size recommended by the audio backend.
 63 m_callbackBufferSize = WebKit::Platform::current()->audioHardwareBufferSize();
 64
 65 // Quick exit if the requested size is too large.
 66 ASSERT(m_callbackBufferSize + renderBufferSize <= fifoSize);
 67 if (m_callbackBufferSize + renderBufferSize > fifoSize)
 68 return;
 69
 70 // FIXME: switch to new API (with input channels) once chromium supports it.
 71 m_audioDevice = adoptPtr(WebKit::Platform::current()->createAudioDevice(m_callbackBufferSize, numberOfOutputChannels, sampleRate, this));
 72 ASSERT(m_audioDevice);
 73
 74 // Create a FIFO to handle the possibility of the callback size
 75 // not being a multiple of the render size. If the FIFO already
 76 // contains enough data, the data will be provided directly.
 77 // Otherwise, the FIFO will call the provider enough times to
 78 // satisfy the request for data.
 79 m_fifo = adoptPtr(new AudioPullFIFO(*this, numberOfOutputChannels, fifoSize, renderBufferSize));
 80
 81 // Input buffering.
 82 m_inputFifo = adoptPtr(new AudioFIFO(numberOfInputChannels, fifoSize));
 83
 84 // If the callback size does not match the render size, then we need to buffer some
 85 // extra silence for the input. Otherwise, we can over-consume the input FIFO.
 86 if (m_callbackBufferSize != renderBufferSize) {
 87 // FIXME: handle multi-channel input and don't hard-code to stereo.
 88 AudioBus silence(2, renderBufferSize);
 89 m_inputFifo->push(&silence);
 90 }
 91}
 92
 93AudioDestinationChromium::~AudioDestinationChromium()
 94{
 95 stop();
 96}
 97
 98void AudioDestinationChromium::start()
 99{
 100 if (!m_isPlaying && m_audioDevice) {
 101 m_audioDevice->start();
 102 m_isPlaying = true;
 103 }
 104}
 105
 106void AudioDestinationChromium::stop()
 107{
 108 if (m_isPlaying && m_audioDevice) {
 109 m_audioDevice->stop();
 110 m_isPlaying = false;
 111 }
 112}
 113
 114float AudioDestination::hardwareSampleRate()
 115{
 116 return static_cast<float>(WebKit::Platform::current()->audioHardwareSampleRate());
 117}
 118
 119void AudioDestinationChromium::render(const WebVector<float*>& sourceData, const WebVector<float*>& audioData, size_t numberOfFrames)
 120{
 121 bool isNumberOfChannelsGood = audioData.size() == m_numberOfOutputChannels;
 122 if (!isNumberOfChannelsGood) {
 123 ASSERT_NOT_REACHED();
 124 return;
 125 }
 126
 127 bool isBufferSizeGood = numberOfFrames == m_callbackBufferSize;
 128 if (!isBufferSizeGood) {
 129 ASSERT_NOT_REACHED();
 130 return;
 131 }
 132
 133 // Buffer optional live input.
 134 if (sourceData.size() >= 2) {
 135 // FIXME: handle multi-channel input and don't hard-code to stereo.
 136 AudioBus wrapperBus(2, numberOfFrames, false);
 137 wrapperBus.setChannelMemory(0, sourceData[0], numberOfFrames);
 138 wrapperBus.setChannelMemory(1, sourceData[1], numberOfFrames);
 139 m_inputFifo->push(&wrapperBus);
 140 }
 141
 142 m_renderBus.setChannelMemory(0, audioData[0], numberOfFrames);
 143 m_renderBus.setChannelMemory(1, audioData[1], numberOfFrames);
 144
 145 m_fifo->consume(&m_renderBus, numberOfFrames);
 146}
 147
 148void AudioDestinationChromium::provideInput(AudioBus* bus, size_t framesToProcess)
 149{
 150 AudioBus* sourceBus = 0;
 151 if (m_inputFifo->framesInFifo() >= framesToProcess) {
 152 m_inputFifo->consume(&m_inputBus, framesToProcess);
 153 sourceBus = &m_inputBus;
 154 }
 155
 156 m_callback.render(sourceBus, bus, framesToProcess);
 157}
 158
 159} // namespace WebCore
 160
 161#endif // ENABLE(WEB_AUDIO)
0

Source/WebCore/platform/audio/chromium/AudioDestinationChromium.h

 1/*
 2 * Copyright (C) 2010 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 14 * its contributors may be used to endorse or promote products derived
 15 * from this software without specific prior written permission.
 16 *
 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27 */
 28
 29#ifndef AudioDestinationChromium_h
 30#define AudioDestinationChromium_h
 31
 32#include "AudioBus.h"
 33#include "AudioDestination.h"
 34#include "AudioIOCallback.h"
 35#include "AudioSourceProvider.h"
 36#include <public/WebAudioDevice.h>
 37#include <public/WebVector.h>
 38
 39namespace WebKit { class WebAudioDevice; }
 40
 41namespace WebCore {
 42
 43class AudioFIFO;
 44class AudioPullFIFO;
 45
 46// An AudioDestination using Chromium's audio system
 47
 48class AudioDestinationChromium : public AudioDestination, public WebKit::WebAudioDevice::RenderCallback, public AudioSourceProvider {
 49public:
 50 AudioDestinationChromium(AudioIOCallback&, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
 51 virtual ~AudioDestinationChromium();
 52
 53 virtual void start();
 54 virtual void stop();
 55 bool isPlaying() { return m_isPlaying; }
 56
 57 float sampleRate() const { return m_sampleRate; }
 58
 59 // WebKit::WebAudioDevice::RenderCallback
 60 virtual void render(const WebKit::WebVector<float*>& sourceData, const WebKit::WebVector<float*>& audioData, size_t numberOfFrames);
 61
 62 // WebCore::AudioSourceProvider
 63 virtual void provideInput(AudioBus*, size_t framesToProcess);
 64
 65private:
 66 AudioIOCallback& m_callback;
 67 unsigned m_numberOfOutputChannels;
 68 AudioBus m_inputBus;
 69 AudioBus m_renderBus;
 70 float m_sampleRate;
 71 bool m_isPlaying;
 72 OwnPtr<WebKit::WebAudioDevice> m_audioDevice;
 73 size_t m_callbackBufferSize;
 74
 75 OwnPtr<AudioFIFO> m_inputFifo;
 76 OwnPtr<AudioPullFIFO> m_fifo;
 77};
 78
 79} // namespace WebCore
 80
 81#endif // AudioDestinationChromium_h
0

Source/WebKit/chromium/ChangeLog

 12013-01-14 Mark Pilgrim <pilgrim@chromium.org>
 2
 3 [Chromium] Move AudioDestinationChromium into WebCore
 4 https://bugs.webkit.org/show_bug.cgi?id=106803
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This doesn't really belong in WebKit/chromium/src since it defines
 9 things directly in the WebCore namespace.
 10
 11 * WebKit.gyp:
 12 * src/AudioDestinationChromium.cpp: Removed.
 13 * src/AudioDestinationChromium.h: Removed.
 14
1152013-01-14 Kentaro Hara <haraken@chromium.org>
216
317 [V8] Make an Isolate parameter mandatory in ScriptDebugServer::interruptAndRun()
139622

Source/WebKit/chromium/WebKit.gyp

350350 'src/AsyncFileSystemChromium.h',
351351 'src/AsyncFileWriterChromium.cpp',
352352 'src/AsyncFileWriterChromium.h',
353  'src/AudioDestinationChromium.cpp',
354  'src/AudioDestinationChromium.h',
355353 'src/AutofillPopupMenuClient.cpp',
356354 'src/AutofillPopupMenuClient.h',
357355 'src/BackForwardListChromium.cpp',
139622

Source/WebKit/chromium/src/AudioDestinationChromium.cpp

1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14  * its contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "config.h"
30 
31 #if ENABLE(WEB_AUDIO)
32 #include "AudioDestinationChromium.h"
33 #include "AudioFIFO.h"
34 #include "AudioPullFIFO.h"
35 #include <public/Platform.h>
36 
37 using namespace WebKit;
38 
39 namespace WebCore {
40 
41 // Buffer size at which the web audio engine will render.
42 const unsigned renderBufferSize = 128;
43 
44 // Size of the FIFO
45 const size_t fifoSize = 8192;
46 
47 // Factory method: Chromium-implementation
48 PassOwnPtr<AudioDestination> AudioDestination::create(AudioIOCallback& callback, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
49 {
50  return adoptPtr(new AudioDestinationChromium(callback, numberOfInputChannels, numberOfOutputChannels, sampleRate));
51 }
52 
53 AudioDestinationChromium::AudioDestinationChromium(AudioIOCallback& callback, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
54  : m_callback(callback)
55  , m_numberOfOutputChannels(numberOfOutputChannels)
56  , m_inputBus(numberOfInputChannels, renderBufferSize)
57  , m_renderBus(numberOfOutputChannels, renderBufferSize, false)
58  , m_sampleRate(sampleRate)
59  , m_isPlaying(false)
60 {
61  // Use the optimal buffer size recommended by the audio backend.
62  m_callbackBufferSize = WebKit::Platform::current()->audioHardwareBufferSize();
63 
64  // Quick exit if the requested size is too large.
65  ASSERT(m_callbackBufferSize + renderBufferSize <= fifoSize);
66  if (m_callbackBufferSize + renderBufferSize > fifoSize)
67  return;
68 
69  // FIXME: switch to new API (with input channels) once chromium supports it.
70  m_audioDevice = adoptPtr(WebKit::Platform::current()->createAudioDevice(m_callbackBufferSize, numberOfOutputChannels, sampleRate, this));
71  ASSERT(m_audioDevice);
72 
73  // Create a FIFO to handle the possibility of the callback size
74  // not being a multiple of the render size. If the FIFO already
75  // contains enough data, the data will be provided directly.
76  // Otherwise, the FIFO will call the provider enough times to
77  // satisfy the request for data.
78  m_fifo = adoptPtr(new AudioPullFIFO(*this, numberOfOutputChannels, fifoSize, renderBufferSize));
79 
80  // Input buffering.
81  m_inputFifo = adoptPtr(new AudioFIFO(numberOfInputChannels, fifoSize));
82 
83  // If the callback size does not match the render size, then we need to buffer some
84  // extra silence for the input. Otherwise, we can over-consume the input FIFO.
85  if (m_callbackBufferSize != renderBufferSize) {
86  // FIXME: handle multi-channel input and don't hard-code to stereo.
87  AudioBus silence(2, renderBufferSize);
88  m_inputFifo->push(&silence);
89  }
90 }
91 
92 AudioDestinationChromium::~AudioDestinationChromium()
93 {
94  stop();
95 }
96 
97 void AudioDestinationChromium::start()
98 {
99  if (!m_isPlaying && m_audioDevice) {
100  m_audioDevice->start();
101  m_isPlaying = true;
102  }
103 }
104 
105 void AudioDestinationChromium::stop()
106 {
107  if (m_isPlaying && m_audioDevice) {
108  m_audioDevice->stop();
109  m_isPlaying = false;
110  }
111 }
112 
113 float AudioDestination::hardwareSampleRate()
114 {
115  return static_cast<float>(WebKit::Platform::current()->audioHardwareSampleRate());
116 }
117 
118 void AudioDestinationChromium::render(const WebVector<float*>& sourceData, const WebVector<float*>& audioData, size_t numberOfFrames)
119 {
120  bool isNumberOfChannelsGood = audioData.size() == m_numberOfOutputChannels;
121  if (!isNumberOfChannelsGood) {
122  ASSERT_NOT_REACHED();
123  return;
124  }
125 
126  bool isBufferSizeGood = numberOfFrames == m_callbackBufferSize;
127  if (!isBufferSizeGood) {
128  ASSERT_NOT_REACHED();
129  return;
130  }
131 
132  // Buffer optional live input.
133  if (sourceData.size() >= 2) {
134  // FIXME: handle multi-channel input and don't hard-code to stereo.
135  AudioBus wrapperBus(2, numberOfFrames, false);
136  wrapperBus.setChannelMemory(0, sourceData[0], numberOfFrames);
137  wrapperBus.setChannelMemory(1, sourceData[1], numberOfFrames);
138  m_inputFifo->push(&wrapperBus);
139  }
140 
141  m_renderBus.setChannelMemory(0, audioData[0], numberOfFrames);
142  m_renderBus.setChannelMemory(1, audioData[1], numberOfFrames);
143 
144  m_fifo->consume(&m_renderBus, numberOfFrames);
145 }
146 
147 void AudioDestinationChromium::provideInput(AudioBus* bus, size_t framesToProcess)
148 {
149  AudioBus* sourceBus = 0;
150  if (m_inputFifo->framesInFifo() >= framesToProcess) {
151  m_inputFifo->consume(&m_inputBus, framesToProcess);
152  sourceBus = &m_inputBus;
153  }
154 
155  m_callback.render(sourceBus, bus, framesToProcess);
156 }
157 
158 } // namespace WebCore
159 
160 #endif // ENABLE(WEB_AUDIO)
139622

Source/WebKit/chromium/src/AudioDestinationChromium.h

1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14  * its contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef AudioDestinationChromium_h
30 #define AudioDestinationChromium_h
31 
32 #include "AudioBus.h"
33 #include "AudioDestination.h"
34 #include "AudioIOCallback.h"
35 #include "AudioSourceProvider.h"
36 #include <public/WebAudioDevice.h>
37 #include <public/WebVector.h>
38 
39 namespace WebKit { class WebAudioDevice; }
40 
41 namespace WebCore {
42 
43 class AudioFIFO;
44 class AudioPullFIFO;
45 
46 // An AudioDestination using Chromium's audio system
47 
48 class AudioDestinationChromium : public AudioDestination, public WebKit::WebAudioDevice::RenderCallback, public AudioSourceProvider {
49 public:
50  AudioDestinationChromium(AudioIOCallback&, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
51  virtual ~AudioDestinationChromium();
52 
53  virtual void start();
54  virtual void stop();
55  bool isPlaying() { return m_isPlaying; }
56 
57  float sampleRate() const { return m_sampleRate; }
58 
59  // WebKit::WebAudioDevice::RenderCallback
60  virtual void render(const WebKit::WebVector<float*>& sourceData, const WebKit::WebVector<float*>& audioData, size_t numberOfFrames);
61 
62  // WebCore::AudioSourceProvider
63  virtual void provideInput(AudioBus*, size_t framesToProcess);
64 
65 private:
66  AudioIOCallback& m_callback;
67  unsigned m_numberOfOutputChannels;
68  AudioBus m_inputBus;
69  AudioBus m_renderBus;
70  float m_sampleRate;
71  bool m_isPlaying;
72  OwnPtr<WebKit::WebAudioDevice> m_audioDevice;
73  size_t m_callbackBufferSize;
74 
75  OwnPtr<AudioFIFO> m_inputFifo;
76  OwnPtr<AudioPullFIFO> m_fifo;
77 };
78 
79 } // namespace WebCore
80 
81 #endif // AudioDestinationChromium_h
139622