Exemplo n.º 1
0
void AudioDestination::render(const blink::WebVector<float*>& sourceData, const blink::WebVector<float*>& audioData, size_t numberOfFrames)
{
    bool isNumberOfChannelsGood = audioData.size() == m_numberOfOutputChannels;
    if (!isNumberOfChannelsGood) {
        ASSERT_NOT_REACHED();
        return;
    }

    bool isBufferSizeGood = numberOfFrames == m_callbackBufferSize;
    if (!isBufferSizeGood) {
        ASSERT_NOT_REACHED();
        return;
    }

    // Buffer optional live input.
    if (sourceData.size() >= 2) {
        // FIXME: handle multi-channel input and don't hard-code to stereo.
        RefPtr<AudioBus> wrapperBus = AudioBus::create(2, numberOfFrames, false);
        wrapperBus->setChannelMemory(0, sourceData[0], numberOfFrames);
        wrapperBus->setChannelMemory(1, sourceData[1], numberOfFrames);
        m_inputFifo->push(wrapperBus.get());
    }

    for (unsigned i = 0; i < m_numberOfOutputChannels; ++i)
        m_renderBus->setChannelMemory(i, audioData[i], numberOfFrames);

    m_fifo->consume(m_renderBus.get(), numberOfFrames);
}
Exemplo n.º 2
0
 virtual void setUint8Array(const char* propertyName, const blink::WebVector<unsigned char>& vector)
 {
     RefPtr<Uint8Array> uint8Array = Uint8Array::create(vector.data(), vector.size());
     m_dictionary.set(propertyName, toV8(uint8Array.get(), m_holder, m_isolate));
 }