| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "core/dom/CrossThreadTask.h" | 31 #include "core/dom/CrossThreadTask.h" |
| 32 #include "modules/webaudio/AudioContext.h" | 32 #include "modules/webaudio/AudioContext.h" |
| 33 #include "platform/Task.h" | 33 #include "platform/Task.h" |
| 34 #include "platform/audio/AudioBus.h" | 34 #include "platform/audio/AudioBus.h" |
| 35 #include "platform/audio/HRTFDatabaseLoader.h" | 35 #include "platform/audio/HRTFDatabaseLoader.h" |
| 36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 #include <algorithm> | 37 #include <algorithm> |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 #if !ENABLE(OILPAN) | |
| 42 // We need a dedicated specialization for OfflineAudioDestinationNode because it | |
| 43 // doesn't inherit from RefCounted. | |
| 44 template<> struct CrossThreadCopierBase<false, false, false, PassRefPtr<OfflineA
udioDestinationNode> > : public CrossThreadCopierPassThrough<PassRefPtr<OfflineA
udioDestinationNode> > { | |
| 45 }; | |
| 46 #endif | |
| 47 | |
| 48 const size_t renderQuantumSize = 128; | 41 const size_t renderQuantumSize = 128; |
| 49 | 42 |
| 50 OfflineAudioDestinationNode::OfflineAudioDestinationNode(AudioContext* context,
AudioBuffer* renderTarget) | 43 OfflineAudioDestinationNode::OfflineAudioDestinationNode(AudioContext* context,
AudioBuffer* renderTarget) |
| 51 : AudioDestinationNode(context, renderTarget->sampleRate()) | 44 : AudioDestinationNode(context, renderTarget->sampleRate()) |
| 52 , m_renderTarget(renderTarget) | 45 , m_renderTarget(renderTarget) |
| 53 , m_startedRendering(false) | 46 , m_startedRendering(false) |
| 54 { | 47 { |
| 55 m_renderBus = AudioBus::create(renderTarget->numberOfChannels(), renderQuant
umSize); | 48 m_renderBus = AudioBus::create(renderTarget->numberOfChannels(), renderQuant
umSize); |
| 56 } | 49 } |
| 57 | 50 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 88 void OfflineAudioDestinationNode::startRendering() | 81 void OfflineAudioDestinationNode::startRendering() |
| 89 { | 82 { |
| 90 ASSERT(isMainThread()); | 83 ASSERT(isMainThread()); |
| 91 ASSERT(m_renderTarget.get()); | 84 ASSERT(m_renderTarget.get()); |
| 92 if (!m_renderTarget.get()) | 85 if (!m_renderTarget.get()) |
| 93 return; | 86 return; |
| 94 | 87 |
| 95 if (!m_startedRendering) { | 88 if (!m_startedRendering) { |
| 96 m_startedRendering = true; | 89 m_startedRendering = true; |
| 97 m_renderThread = adoptPtr(blink::Platform::current()->createThread("Offl
ine Audio Renderer")); | 90 m_renderThread = adoptPtr(blink::Platform::current()->createThread("Offl
ine Audio Renderer")); |
| 98 m_renderThread->postTask(new Task(bind(&OfflineAudioDestinationNode::off
lineRender, PassRefPtrWillBeRawPtr<OfflineAudioDestinationNode>(this)))); | 91 m_renderThread->postTask(new Task(bind(&OfflineAudioDestinationNode::off
lineRender, this))); |
| 99 } | 92 } |
| 100 } | 93 } |
| 101 | 94 |
| 102 void OfflineAudioDestinationNode::offlineRender() | 95 void OfflineAudioDestinationNode::offlineRender() |
| 103 { | 96 { |
| 104 ASSERT(!isMainThread()); | 97 ASSERT(!isMainThread()); |
| 105 ASSERT(m_renderBus.get()); | 98 ASSERT(m_renderBus.get()); |
| 106 if (!m_renderBus.get()) | 99 if (!m_renderBus.get()) |
| 107 return; | 100 return; |
| 108 | 101 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 138 float* destination = m_renderTarget->getChannelData(channelIndex)->d
ata(); | 131 float* destination = m_renderTarget->getChannelData(channelIndex)->d
ata(); |
| 139 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop
y); | 132 memcpy(destination + n, source, sizeof(float) * framesAvailableToCop
y); |
| 140 } | 133 } |
| 141 | 134 |
| 142 n += framesAvailableToCopy; | 135 n += framesAvailableToCopy; |
| 143 framesToProcess -= framesAvailableToCopy; | 136 framesToProcess -= framesAvailableToCopy; |
| 144 } | 137 } |
| 145 | 138 |
| 146 // Our work is done. Let the AudioContext know. | 139 // Our work is done. Let the AudioContext know. |
| 147 if (context()->executionContext()) | 140 if (context()->executionContext()) |
| 148 context()->executionContext()->postTask(createCrossThreadTask(&OfflineAu
dioDestinationNode::notifyComplete, PassRefPtrWillBeRawPtr<OfflineAudioDestinati
onNode>(this))); | 141 context()->executionContext()->postTask(createCrossThreadTask(&OfflineAu
dioDestinationNode::notifyComplete, this)); |
| 149 } | 142 } |
| 150 | 143 |
| 151 void OfflineAudioDestinationNode::notifyComplete() | 144 void OfflineAudioDestinationNode::notifyComplete() |
| 152 { | 145 { |
| 153 context()->fireCompletionEvent(); | 146 context()->fireCompletionEvent(); |
| 154 } | 147 } |
| 155 | 148 |
| 156 void OfflineAudioDestinationNode::trace(Visitor* visitor) | 149 void OfflineAudioDestinationNode::trace(Visitor* visitor) |
| 157 { | 150 { |
| 158 visitor->trace(m_renderTarget); | 151 visitor->trace(m_renderTarget); |
| 159 AudioDestinationNode::trace(visitor); | 152 AudioDestinationNode::trace(visitor); |
| 160 } | 153 } |
| 161 | 154 |
| 162 } // namespace blink | 155 } // namespace blink |
| 163 | 156 |
| 164 #endif // ENABLE(WEB_AUDIO) | 157 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |