15ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen/* 25ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * Copyright (C) 2010 Google Inc. All rights reserved. 35ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 45ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * Redistribution and use in source and binary forms, with or without 55ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * modification, are permitted provided that the following conditions 65ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * are met: 75ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 85ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 1. Redistributions of source code must retain the above copyright 95ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * notice, this list of conditions and the following disclaimer. 105ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 2. Redistributions in binary form must reproduce the above copyright 115ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * notice, this list of conditions and the following disclaimer in the 125ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * documentation and/or other materials provided with the distribution. 135ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 145ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * its contributors may be used to endorse or promote products derived 155ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * from this software without specific prior written permission. 165ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * 175ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 185ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 195ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 205ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 215ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 225ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 235ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 245ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 265ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen */ 285ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 295ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen#ifndef ReverbInputBuffer_h 305ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen#define ReverbInputBuffer_h 315ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 32e14391e94c850b8bd03680c23b38978db68687a8John Reck#include "AudioArray.h" 335ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 345ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsennamespace WebCore { 355ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 365ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen// ReverbInputBuffer is used to buffer input samples for deferred processing by the background threads. 375ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsenclass ReverbInputBuffer { 385ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsenpublic: 395ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen ReverbInputBuffer(size_t length); 405ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 415ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // The realtime audio thread keeps writing samples here. 425ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // The assumption is that the buffer's length is evenly divisible by numberOfFrames (for nearly all cases this will be fine). 435ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // FIXME: remove numberOfFrames restriction... 445ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen void write(float* sourceP, size_t numberOfFrames); 455ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 465ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // Background threads can call this to check if there's anything to read... 475ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen size_t writeIndex() const { return m_writeIndex; } 485ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 495ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // The individual background threads read here (and hope that they can keep up with the buffer writing). 505ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // readIndex is updated with the next readIndex to read from... 515ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // The assumption is that the buffer's length is evenly divisible by numberOfFrames. 525ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen // FIXME: remove numberOfFrames restriction... 535ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen float* directReadFrom(int* readIndex, size_t numberOfFrames); 545ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 555ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen void reset(); 565ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 575ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsenprivate: 585ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen AudioFloatArray m_buffer; 595ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen size_t m_writeIndex; 605ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen}; 615ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 625ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen} // namespace WebCore 635ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen 645ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen#endif // ReverbInputBuffer_h 65