| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #endif | 75 #endif |
| 76 } | 76 } |
| 77 | 77 |
| 78 void DeferredTaskHandler::AddDeferredBreakConnection(AudioHandler& node) { | 78 void DeferredTaskHandler::AddDeferredBreakConnection(AudioHandler& node) { |
| 79 DCHECK(IsAudioThread()); | 79 DCHECK(IsAudioThread()); |
| 80 deferred_break_connection_list_.push_back(&node); | 80 deferred_break_connection_list_.push_back(&node); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DeferredTaskHandler::BreakConnections() { | 83 void DeferredTaskHandler::BreakConnections() { |
| 84 DCHECK(IsAudioThread()); | 84 DCHECK(IsAudioThread()); |
| 85 ASSERT(IsGraphOwner()); | 85 DCHECK(IsGraphOwner()); |
| 86 | 86 |
| 87 for (unsigned i = 0; i < deferred_break_connection_list_.size(); ++i) | 87 for (unsigned i = 0; i < deferred_break_connection_list_.size(); ++i) |
| 88 deferred_break_connection_list_[i]->BreakConnectionWithLock(); | 88 deferred_break_connection_list_[i]->BreakConnectionWithLock(); |
| 89 deferred_break_connection_list_.Clear(); | 89 deferred_break_connection_list_.Clear(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DeferredTaskHandler::MarkSummingJunctionDirty( | 92 void DeferredTaskHandler::MarkSummingJunctionDirty( |
| 93 AudioSummingJunction* summing_junction) { | 93 AudioSummingJunction* summing_junction) { |
| 94 ASSERT(IsGraphOwner()); | 94 DCHECK(IsGraphOwner()); |
| 95 dirty_summing_junctions_.insert(summing_junction); | 95 dirty_summing_junctions_.insert(summing_junction); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void DeferredTaskHandler::RemoveMarkedSummingJunction( | 98 void DeferredTaskHandler::RemoveMarkedSummingJunction( |
| 99 AudioSummingJunction* summing_junction) { | 99 AudioSummingJunction* summing_junction) { |
| 100 DCHECK(IsMainThread()); | 100 DCHECK(IsMainThread()); |
| 101 AutoLocker locker(*this); | 101 AutoLocker locker(*this); |
| 102 dirty_summing_junctions_.erase(summing_junction); | 102 dirty_summing_junctions_.erase(summing_junction); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void DeferredTaskHandler::MarkAudioNodeOutputDirty(AudioNodeOutput* output) { | 105 void DeferredTaskHandler::MarkAudioNodeOutputDirty(AudioNodeOutput* output) { |
| 106 ASSERT(IsGraphOwner()); | 106 DCHECK(IsGraphOwner()); |
| 107 DCHECK(IsMainThread()); | 107 DCHECK(IsMainThread()); |
| 108 dirty_audio_node_outputs_.insert(output); | 108 dirty_audio_node_outputs_.insert(output); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void DeferredTaskHandler::RemoveMarkedAudioNodeOutput(AudioNodeOutput* output) { | 111 void DeferredTaskHandler::RemoveMarkedAudioNodeOutput(AudioNodeOutput* output) { |
| 112 ASSERT(IsGraphOwner()); | 112 DCHECK(IsGraphOwner()); |
| 113 DCHECK(IsMainThread()); | 113 DCHECK(IsMainThread()); |
| 114 dirty_audio_node_outputs_.erase(output); | 114 dirty_audio_node_outputs_.erase(output); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void DeferredTaskHandler::HandleDirtyAudioSummingJunctions() { | 117 void DeferredTaskHandler::HandleDirtyAudioSummingJunctions() { |
| 118 ASSERT(IsGraphOwner()); | 118 DCHECK(IsGraphOwner()); |
| 119 | 119 |
| 120 for (AudioSummingJunction* junction : dirty_summing_junctions_) | 120 for (AudioSummingJunction* junction : dirty_summing_junctions_) |
| 121 junction->UpdateRenderingState(); | 121 junction->UpdateRenderingState(); |
| 122 dirty_summing_junctions_.Clear(); | 122 dirty_summing_junctions_.Clear(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void DeferredTaskHandler::HandleDirtyAudioNodeOutputs() { | 125 void DeferredTaskHandler::HandleDirtyAudioNodeOutputs() { |
| 126 ASSERT(IsGraphOwner()); | 126 DCHECK(IsGraphOwner()); |
| 127 | 127 |
| 128 HashSet<AudioNodeOutput*> dirty_outputs; | 128 HashSet<AudioNodeOutput*> dirty_outputs; |
| 129 dirty_audio_node_outputs_.Swap(dirty_outputs); | 129 dirty_audio_node_outputs_.Swap(dirty_outputs); |
| 130 | 130 |
| 131 // Note: the updating of rendering state may cause output nodes | 131 // Note: the updating of rendering state may cause output nodes |
| 132 // further down the chain to be marked as dirty. These will not | 132 // further down the chain to be marked as dirty. These will not |
| 133 // be processed in this render quantum. | 133 // be processed in this render quantum. |
| 134 for (AudioNodeOutput* output : dirty_outputs) | 134 for (AudioNodeOutput* output : dirty_outputs) |
| 135 output->UpdateRenderingState(); | 135 output->UpdateRenderingState(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DeferredTaskHandler::AddAutomaticPullNode(AudioHandler* node) { | 138 void DeferredTaskHandler::AddAutomaticPullNode(AudioHandler* node) { |
| 139 ASSERT(IsGraphOwner()); | 139 DCHECK(IsGraphOwner()); |
| 140 | 140 |
| 141 if (!automatic_pull_nodes_.Contains(node)) { | 141 if (!automatic_pull_nodes_.Contains(node)) { |
| 142 automatic_pull_nodes_.insert(node); | 142 automatic_pull_nodes_.insert(node); |
| 143 automatic_pull_nodes_need_updating_ = true; | 143 automatic_pull_nodes_need_updating_ = true; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void DeferredTaskHandler::RemoveAutomaticPullNode(AudioHandler* node) { | 147 void DeferredTaskHandler::RemoveAutomaticPullNode(AudioHandler* node) { |
| 148 ASSERT(IsGraphOwner()); | 148 DCHECK(IsGraphOwner()); |
| 149 | 149 |
| 150 if (automatic_pull_nodes_.Contains(node)) { | 150 if (automatic_pull_nodes_.Contains(node)) { |
| 151 automatic_pull_nodes_.erase(node); | 151 automatic_pull_nodes_.erase(node); |
| 152 automatic_pull_nodes_need_updating_ = true; | 152 automatic_pull_nodes_need_updating_ = true; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 void DeferredTaskHandler::UpdateAutomaticPullNodes() { | 156 void DeferredTaskHandler::UpdateAutomaticPullNodes() { |
| 157 ASSERT(IsGraphOwner()); | 157 DCHECK(IsGraphOwner()); |
| 158 | 158 |
| 159 if (automatic_pull_nodes_need_updating_) { | 159 if (automatic_pull_nodes_need_updating_) { |
| 160 CopyToVector(automatic_pull_nodes_, rendering_automatic_pull_nodes_); | 160 CopyToVector(automatic_pull_nodes_, rendering_automatic_pull_nodes_); |
| 161 automatic_pull_nodes_need_updating_ = false; | 161 automatic_pull_nodes_need_updating_ = false; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 void DeferredTaskHandler::ProcessAutomaticPullNodes(size_t frames_to_process) { | 165 void DeferredTaskHandler::ProcessAutomaticPullNodes(size_t frames_to_process) { |
| 166 DCHECK(IsAudioThread()); | 166 DCHECK(IsAudioThread()); |
| 167 | 167 |
| 168 for (unsigned i = 0; i < rendering_automatic_pull_nodes_.size(); ++i) | 168 for (unsigned i = 0; i < rendering_automatic_pull_nodes_.size(); ++i) |
| 169 rendering_automatic_pull_nodes_[i]->ProcessIfNecessary(frames_to_process); | 169 rendering_automatic_pull_nodes_[i]->ProcessIfNecessary(frames_to_process); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void DeferredTaskHandler::AddChangedChannelCountMode(AudioHandler* node) { | 172 void DeferredTaskHandler::AddChangedChannelCountMode(AudioHandler* node) { |
| 173 ASSERT(IsGraphOwner()); | 173 DCHECK(IsGraphOwner()); |
| 174 DCHECK(IsMainThread()); | 174 DCHECK(IsMainThread()); |
| 175 deferred_count_mode_change_.insert(node); | 175 deferred_count_mode_change_.insert(node); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void DeferredTaskHandler::RemoveChangedChannelCountMode(AudioHandler* node) { | 178 void DeferredTaskHandler::RemoveChangedChannelCountMode(AudioHandler* node) { |
| 179 ASSERT(IsGraphOwner()); | 179 DCHECK(IsGraphOwner()); |
| 180 | 180 |
| 181 deferred_count_mode_change_.erase(node); | 181 deferred_count_mode_change_.erase(node); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void DeferredTaskHandler::AddChangedChannelInterpretation(AudioHandler* node) { | 184 void DeferredTaskHandler::AddChangedChannelInterpretation(AudioHandler* node) { |
| 185 ASSERT(IsGraphOwner()); | 185 DCHECK(IsGraphOwner()); |
| 186 DCHECK(IsMainThread()); | 186 DCHECK(IsMainThread()); |
| 187 deferred_channel_interpretation_change_.insert(node); | 187 deferred_channel_interpretation_change_.insert(node); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void DeferredTaskHandler::RemoveChangedChannelInterpretation( | 190 void DeferredTaskHandler::RemoveChangedChannelInterpretation( |
| 191 AudioHandler* node) { | 191 AudioHandler* node) { |
| 192 ASSERT(IsGraphOwner()); | 192 DCHECK(IsGraphOwner()); |
| 193 | 193 |
| 194 deferred_channel_interpretation_change_.erase(node); | 194 deferred_channel_interpretation_change_.erase(node); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void DeferredTaskHandler::UpdateChangedChannelCountMode() { | 197 void DeferredTaskHandler::UpdateChangedChannelCountMode() { |
| 198 ASSERT(IsGraphOwner()); | 198 DCHECK(IsGraphOwner()); |
| 199 | 199 |
| 200 for (AudioHandler* node : deferred_count_mode_change_) | 200 for (AudioHandler* node : deferred_count_mode_change_) |
| 201 node->UpdateChannelCountMode(); | 201 node->UpdateChannelCountMode(); |
| 202 deferred_count_mode_change_.Clear(); | 202 deferred_count_mode_change_.Clear(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void DeferredTaskHandler::UpdateChangedChannelInterpretation() { | 205 void DeferredTaskHandler::UpdateChangedChannelInterpretation() { |
| 206 ASSERT(IsGraphOwner()); | 206 DCHECK(IsGraphOwner()); |
| 207 | 207 |
| 208 for (AudioHandler* node : deferred_channel_interpretation_change_) | 208 for (AudioHandler* node : deferred_channel_interpretation_change_) |
| 209 node->UpdateChannelInterpretation(); | 209 node->UpdateChannelInterpretation(); |
| 210 deferred_channel_interpretation_change_.Clear(); | 210 deferred_channel_interpretation_change_.Clear(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 DeferredTaskHandler::DeferredTaskHandler() | 213 DeferredTaskHandler::DeferredTaskHandler() |
| 214 : automatic_pull_nodes_need_updating_(false), audio_thread_(0) {} | 214 : automatic_pull_nodes_need_updating_(false), audio_thread_(0) {} |
| 215 | 215 |
| 216 PassRefPtr<DeferredTaskHandler> DeferredTaskHandler::Create() { | 216 PassRefPtr<DeferredTaskHandler> DeferredTaskHandler::Create() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 253 } |
| 254 | 254 |
| 255 void DeferredTaskHandler::AddRenderingOrphanHandler( | 255 void DeferredTaskHandler::AddRenderingOrphanHandler( |
| 256 PassRefPtr<AudioHandler> handler) { | 256 PassRefPtr<AudioHandler> handler) { |
| 257 DCHECK(handler); | 257 DCHECK(handler); |
| 258 DCHECK(!rendering_orphan_handlers_.Contains(handler)); | 258 DCHECK(!rendering_orphan_handlers_.Contains(handler)); |
| 259 rendering_orphan_handlers_.push_back(handler); | 259 rendering_orphan_handlers_.push_back(handler); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void DeferredTaskHandler::RequestToDeleteHandlersOnMainThread() { | 262 void DeferredTaskHandler::RequestToDeleteHandlersOnMainThread() { |
| 263 ASSERT(IsGraphOwner()); | 263 DCHECK(IsGraphOwner()); |
| 264 DCHECK(IsAudioThread()); | 264 DCHECK(IsAudioThread()); |
| 265 if (rendering_orphan_handlers_.IsEmpty()) | 265 if (rendering_orphan_handlers_.IsEmpty()) |
| 266 return; | 266 return; |
| 267 deletable_orphan_handlers_.AppendVector(rendering_orphan_handlers_); | 267 deletable_orphan_handlers_.AppendVector(rendering_orphan_handlers_); |
| 268 rendering_orphan_handlers_.Clear(); | 268 rendering_orphan_handlers_.Clear(); |
| 269 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( | 269 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( |
| 270 BLINK_FROM_HERE, | 270 BLINK_FROM_HERE, |
| 271 CrossThreadBind(&DeferredTaskHandler::DeleteHandlersOnMainThread, | 271 CrossThreadBind(&DeferredTaskHandler::DeleteHandlersOnMainThread, |
| 272 PassRefPtr<DeferredTaskHandler>(this))); | 272 PassRefPtr<DeferredTaskHandler>(this))); |
| 273 } | 273 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 285 deletable_orphan_handlers_.Clear(); | 285 deletable_orphan_handlers_.Clear(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void DeferredTaskHandler::SetAudioThreadToCurrentThread() { | 288 void DeferredTaskHandler::SetAudioThreadToCurrentThread() { |
| 289 DCHECK(!IsMainThread()); | 289 DCHECK(!IsMainThread()); |
| 290 ThreadIdentifier thread = CurrentThread(); | 290 ThreadIdentifier thread = CurrentThread(); |
| 291 ReleaseStore(&audio_thread_, thread); | 291 ReleaseStore(&audio_thread_, thread); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |