Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.cpp

Issue 2889393003: Lazy initialization of the rendering thread in OfflineAudioContext (Closed)
Patch Set: Change thread creation location and add layout test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 #include "platform/wtf/PtrUtil.h" 39 #include "platform/wtf/PtrUtil.h"
40 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 OfflineAudioDestinationHandler::OfflineAudioDestinationHandler( 44 OfflineAudioDestinationHandler::OfflineAudioDestinationHandler(
45 AudioNode& node, 45 AudioNode& node,
46 AudioBuffer* render_target) 46 AudioBuffer* render_target)
47 : AudioDestinationHandler(node), 47 : AudioDestinationHandler(node),
48 render_target_(render_target), 48 render_target_(render_target),
49 render_thread_(
50 Platform::Current()->CreateThread("offline audio renderer")),
51 frames_processed_(0), 49 frames_processed_(0),
52 frames_to_process_(0), 50 frames_to_process_(0),
53 is_rendering_started_(false), 51 is_rendering_started_(false),
54 should_suspend_(false) { 52 should_suspend_(false) {
55 render_bus_ = AudioBus::Create(render_target->numberOfChannels(), 53 render_bus_ = AudioBus::Create(render_target->numberOfChannels(),
56 AudioUtilities::kRenderQuantumFrames); 54 AudioUtilities::kRenderQuantumFrames);
57 frames_to_process_ = render_target_->length(); 55 frames_to_process_ = render_target_->length();
58 56
59 // Node-specific defaults. 57 // Node-specific defaults.
60 channel_count_ = render_target_->numberOfChannels(); 58 channel_count_ = render_target_->numberOfChannels();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 void OfflineAudioDestinationHandler::StopRendering() { 129 void OfflineAudioDestinationHandler::StopRendering() {
132 // offline audio rendering CANNOT BE stopped by JavaScript. 130 // offline audio rendering CANNOT BE stopped by JavaScript.
133 NOTREACHED(); 131 NOTREACHED();
134 } 132 }
135 133
136 size_t OfflineAudioDestinationHandler::CallbackBufferSize() const { 134 size_t OfflineAudioDestinationHandler::CallbackBufferSize() const {
137 // The callback buffer size has no meaning for an offline context. 135 // The callback buffer size has no meaning for an offline context.
138 NOTREACHED(); 136 NOTREACHED();
139 return 0; 137 return 0;
140 } 138 }
139
140 void OfflineAudioDestinationHandler::InitializeOfflineRenderThread() {
141 render_thread_ = Platform::Current()->CreateThread("offline audio renderer");
142 }
143
141 WebThread* OfflineAudioDestinationHandler::OfflineRenderThread() { 144 WebThread* OfflineAudioDestinationHandler::OfflineRenderThread() {
142 DCHECK(render_thread_); 145 DCHECK(render_thread_);
143 146
144 return render_thread_.get(); 147 return render_thread_.get();
145 } 148 }
146 149
147 void OfflineAudioDestinationHandler::StartOfflineRendering() { 150 void OfflineAudioDestinationHandler::StartOfflineRendering() {
148 DCHECK(!IsMainThread()); 151 DCHECK(!IsMainThread());
149 152
150 DCHECK(render_bus_); 153 DCHECK(render_bus_);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target)); 344 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target));
342 } 345 }
343 346
344 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create( 347 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create(
345 BaseAudioContext* context, 348 BaseAudioContext* context,
346 AudioBuffer* render_target) { 349 AudioBuffer* render_target) {
347 return new OfflineAudioDestinationNode(*context, render_target); 350 return new OfflineAudioDestinationNode(*context, render_target);
348 } 351 }
349 352
350 } // namespace blink 353 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698