Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 OfflineAudioContext* OfflineAudioDestinationHandler::Context() const { | 95 OfflineAudioContext* OfflineAudioDestinationHandler::Context() const { |
| 98 return static_cast<OfflineAudioContext*>(AudioDestinationHandler::Context()); | 96 return static_cast<OfflineAudioContext*>(AudioDestinationHandler::Context()); |
| 99 } | 97 } |
| 100 | 98 |
| 101 unsigned long OfflineAudioDestinationHandler::MaxChannelCount() const { | 99 unsigned long OfflineAudioDestinationHandler::MaxChannelCount() const { |
| 102 return channel_count_; | 100 return channel_count_; |
| 103 } | 101 } |
| 104 | 102 |
| 105 void OfflineAudioDestinationHandler::StartRendering() { | 103 void OfflineAudioDestinationHandler::StartRendering() { |
| 106 DCHECK(IsMainThread()); | 104 DCHECK(IsMainThread()); |
| 107 DCHECK(render_thread_); | |
| 108 DCHECK(render_target_); | 105 DCHECK(render_target_); |
| 109 | 106 |
| 110 if (!render_target_) | 107 if (!render_target_) |
| 111 return; | 108 return; |
| 112 | 109 |
| 110 render_thread_ = Platform::Current()->CreateThread("offline audio renderer"); | |
|
Raymond Toy
2017/05/19 19:37:54
Maybe if we fail to create the thread we can rejec
| |
| 111 DCHECK(render_thread_); | |
| 112 | |
| 113 // Rendering was not started. Starting now. | 113 // Rendering was not started. Starting now. |
| 114 if (!is_rendering_started_) { | 114 if (!is_rendering_started_) { |
| 115 is_rendering_started_ = true; | 115 is_rendering_started_ = true; |
| 116 render_thread_->GetWebTaskRunner()->PostTask( | 116 render_thread_->GetWebTaskRunner()->PostTask( |
| 117 BLINK_FROM_HERE, | 117 BLINK_FROM_HERE, |
| 118 CrossThreadBind(&OfflineAudioDestinationHandler::StartOfflineRendering, | 118 CrossThreadBind(&OfflineAudioDestinationHandler::StartOfflineRendering, |
| 119 WrapPassRefPtr(this))); | 119 WrapPassRefPtr(this))); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target)); | 341 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create( | 344 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create( |
| 345 BaseAudioContext* context, | 345 BaseAudioContext* context, |
| 346 AudioBuffer* render_target) { | 346 AudioBuffer* render_target) { |
| 347 return new OfflineAudioDestinationNode(*context, render_target); | 347 return new OfflineAudioDestinationNode(*context, render_target); |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace blink | 350 } // namespace blink |
| OLD | NEW |