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