TEST(ConvolverNodeTest, ReverbLifetime)
{
    OwnPtr<DummyPageHolder> page = DummyPageHolder::create();
    OfflineAudioContext* context = OfflineAudioContext::create(&page->document(), 2, 1, 48000, ASSERT_NO_EXCEPTION);
    ConvolverNode* node = context->createConvolver(ASSERT_NO_EXCEPTION);
    ConvolverHandler& handler = node->convolverHandler();
    EXPECT_FALSE(handler.m_reverb);
    node->setBuffer(AudioBuffer::create(2, 1, 48000), ASSERT_NO_EXCEPTION);
    EXPECT_TRUE(handler.m_reverb);
    AudioContext::AutoLocker locker(context);
    handler.dispose();
    // m_reverb should live after dispose() because an audio thread is using it.
    EXPECT_TRUE(handler.m_reverb);
}
Пример #2
0
ConvolverNode* ConvolverNode::create(BaseAudioContext* context,
                                     const ConvolverOptions& options,
                                     ExceptionState& exceptionState) {
  ConvolverNode* node = create(*context, exceptionState);

  if (!node)
    return nullptr;

  node->handleChannelOptions(options, exceptionState);

  // It is important to set normalize first because setting the buffer will
  // examing the normalize attribute to see if normalization needs to be done.
  node->setNormalize(!options.disableNormalization());
  if (options.hasBuffer())
    node->setBuffer(options.buffer(), exceptionState);
  return node;
}
Пример #3
0
void JSConvolverNode::setBuffer(ExecState*, JSValue value)
{
    ConvolverNode* imp = static_cast<ConvolverNode*>(impl());
    imp->setBuffer(toAudioBuffer(value));
}