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 23 matching lines...) Expand all Loading... |
34 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
35 #include <algorithm> | 35 #include <algorithm> |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 const size_t OfflineAudioDestinationHandler::renderQuantumSize = 128; | 39 const size_t OfflineAudioDestinationHandler::renderQuantumSize = 128; |
40 | 40 |
41 OfflineAudioDestinationHandler::OfflineAudioDestinationHandler(AudioNode& node,
AudioBuffer* renderTarget) | 41 OfflineAudioDestinationHandler::OfflineAudioDestinationHandler(AudioNode& node,
AudioBuffer* renderTarget) |
42 : AudioDestinationHandler(node, renderTarget->sampleRate()) | 42 : AudioDestinationHandler(node, renderTarget->sampleRate()) |
43 , m_renderTarget(renderTarget) | 43 , m_renderTarget(renderTarget) |
44 , m_renderThread(adoptPtr(Platform::current()->createThread("offline audio r
enderer"))) | |
45 , m_framesProcessed(0) | 44 , m_framesProcessed(0) |
46 , m_framesToProcess(0) | 45 , m_framesToProcess(0) |
47 , m_isRenderingStarted(false) | 46 , m_isRenderingStarted(false) |
48 , m_shouldSuspend(false) | 47 , m_shouldSuspend(false) |
49 { | 48 { |
| 49 m_renderThread = AudioWorkletThread::create(*this); |
| 50 // m_renderThread->initialize(frame, std::move(startUpData)); |
| 51 |
50 m_renderBus = AudioBus::create(renderTarget->numberOfChannels(), renderQuant
umSize); | 52 m_renderBus = AudioBus::create(renderTarget->numberOfChannels(), renderQuant
umSize); |
51 m_framesToProcess = m_renderTarget->length(); | 53 m_framesToProcess = m_renderTarget->length(); |
52 } | 54 } |
53 | 55 |
54 PassRefPtr<OfflineAudioDestinationHandler> OfflineAudioDestinationHandler::creat
e(AudioNode& node, AudioBuffer* renderTarget) | 56 PassRefPtr<OfflineAudioDestinationHandler> OfflineAudioDestinationHandler::creat
e(AudioNode& node, AudioBuffer* renderTarget) |
55 { | 57 { |
56 return adoptRef(new OfflineAudioDestinationHandler(node, renderTarget)); | 58 return adoptRef(new OfflineAudioDestinationHandler(node, renderTarget)); |
57 } | 59 } |
58 | 60 |
59 OfflineAudioDestinationHandler::~OfflineAudioDestinationHandler() | 61 OfflineAudioDestinationHandler::~OfflineAudioDestinationHandler() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ASSERT(isMainThread()); | 98 ASSERT(isMainThread()); |
97 ASSERT(m_renderThread); | 99 ASSERT(m_renderThread); |
98 ASSERT(m_renderTarget); | 100 ASSERT(m_renderTarget); |
99 | 101 |
100 if (!m_renderTarget) | 102 if (!m_renderTarget) |
101 return; | 103 return; |
102 | 104 |
103 // Rendering was not started. Starting now. | 105 // Rendering was not started. Starting now. |
104 if (!m_isRenderingStarted) { | 106 if (!m_isRenderingStarted) { |
105 m_isRenderingStarted = true; | 107 m_isRenderingStarted = true; |
106 m_renderThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, | 108 m_renderThread->audioRenderThread().postTask(BLINK_FROM_HERE, |
107 threadSafeBind(&OfflineAudioDestinationHandler::startOfflineRenderin
g, this)); | 109 threadSafeBind(&OfflineAudioDestinationHandler::startOfflineRenderin
g, this)); |
108 return; | 110 return; |
109 } | 111 } |
110 | 112 |
111 // Rendering is already started, which implicitly means we resume the | 113 // Rendering is already started, which implicitly means we resume the |
112 // rendering by calling |doOfflineRendering| on the render thread. | 114 // rendering by calling |doOfflineRendering| on the render thread. |
113 m_renderThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, | 115 m_renderThread->audioRenderThread().postTask(BLINK_FROM_HERE, |
114 threadSafeBind(&OfflineAudioDestinationHandler::doOfflineRendering, this
)); | 116 threadSafeBind(&OfflineAudioDestinationHandler::doOfflineRendering, this
)); |
115 } | 117 } |
116 | 118 |
117 void OfflineAudioDestinationHandler::stopRendering() | 119 void OfflineAudioDestinationHandler::stopRendering() |
118 { | 120 { |
119 // offline audio rendering CANNOT BE stopped by JavaScript. | 121 // offline audio rendering CANNOT BE stopped by JavaScript. |
120 ASSERT_NOT_REACHED(); | 122 ASSERT_NOT_REACHED(); |
121 } | 123 } |
122 | 124 |
123 WebThread* OfflineAudioDestinationHandler::offlineRenderThread() | 125 AudioWorkletThread* OfflineAudioDestinationHandler::offlineRenderThread() |
124 { | 126 { |
125 ASSERT(m_renderThread); | 127 ASSERT(m_renderThread); |
126 | 128 |
127 return m_renderThread.get(); | 129 return m_renderThread.get(); |
128 } | 130 } |
129 | 131 |
130 void OfflineAudioDestinationHandler::startOfflineRendering() | 132 void OfflineAudioDestinationHandler::startOfflineRendering() |
131 { | 133 { |
132 ASSERT(!isMainThread()); | 134 ASSERT(!isMainThread()); |
133 | 135 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 { | 317 { |
316 setHandler(OfflineAudioDestinationHandler::create(*this, renderTarget)); | 318 setHandler(OfflineAudioDestinationHandler::create(*this, renderTarget)); |
317 } | 319 } |
318 | 320 |
319 OfflineAudioDestinationNode* OfflineAudioDestinationNode::create(AbstractAudioCo
ntext* context, AudioBuffer* renderTarget) | 321 OfflineAudioDestinationNode* OfflineAudioDestinationNode::create(AbstractAudioCo
ntext* context, AudioBuffer* renderTarget) |
320 { | 322 { |
321 return new OfflineAudioDestinationNode(*context, renderTarget); | 323 return new OfflineAudioDestinationNode(*context, renderTarget); |
322 } | 324 } |
323 | 325 |
324 } // namespace blink | 326 } // namespace blink |
OLD | NEW |