| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 199 } |
| 200 | 200 |
| 201 // ---------------------------------------------------------------- | 201 // ---------------------------------------------------------------- |
| 202 | 202 |
| 203 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AbstractAudioContext& c
ontext, HTMLMediaElement& mediaElement) | 203 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AbstractAudioContext& c
ontext, HTMLMediaElement& mediaElement) |
| 204 : AudioSourceNode(context) | 204 : AudioSourceNode(context) |
| 205 { | 205 { |
| 206 setHandler(MediaElementAudioSourceHandler::create(*this, mediaElement)); | 206 setHandler(MediaElementAudioSourceHandler::create(*this, mediaElement)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AbstractAudioCo
ntext& context, HTMLMediaElement& mediaElement) | 209 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AbstractAudioCo
ntext& context, HTMLMediaElement& mediaElement, ExceptionState& exceptionState) |
| 210 { | 210 { |
| 211 return new MediaElementAudioSourceNode(context, mediaElement); | 211 DCHECK(isMainThread()); |
| 212 |
| 213 if (context.isContextClosed()) { |
| 214 context.throwExceptionForClosedState(exceptionState); |
| 215 return nullptr; |
| 216 } |
| 217 |
| 218 // First check if this media element already has a source node. |
| 219 if (mediaElement.audioSourceNode()) { |
| 220 exceptionState.throwDOMException( |
| 221 InvalidStateError, |
| 222 "HTMLMediaElement already connected previously to a different MediaE
lementSourceNode."); |
| 223 return nullptr; |
| 224 } |
| 225 |
| 226 MediaElementAudioSourceNode* node = new MediaElementAudioSourceNode(context,
mediaElement); |
| 227 |
| 228 if (node) { |
| 229 mediaElement.setAudioSourceNode(node); |
| 230 // context keeps reference until node is disconnected |
| 231 context.notifySourceNodeStartedProcessing(node); |
| 232 } |
| 233 |
| 234 return node; |
| 212 } | 235 } |
| 213 | 236 |
| 214 DEFINE_TRACE(MediaElementAudioSourceNode) | 237 DEFINE_TRACE(MediaElementAudioSourceNode) |
| 215 { | 238 { |
| 216 AudioSourceProviderClient::trace(visitor); | 239 AudioSourceProviderClient::trace(visitor); |
| 217 AudioSourceNode::trace(visitor); | 240 AudioSourceNode::trace(visitor); |
| 218 } | 241 } |
| 219 | 242 |
| 220 MediaElementAudioSourceHandler& MediaElementAudioSourceNode::mediaElementAudioSo
urceHandler() const | 243 MediaElementAudioSourceHandler& MediaElementAudioSourceNode::mediaElementAudioSo
urceHandler() const |
| 221 { | 244 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 242 mediaElementAudioSourceHandler().lock(); | 265 mediaElementAudioSourceHandler().lock(); |
| 243 } | 266 } |
| 244 | 267 |
| 245 void MediaElementAudioSourceNode::unlock() | 268 void MediaElementAudioSourceNode::unlock() |
| 246 { | 269 { |
| 247 mediaElementAudioSourceHandler().unlock(); | 270 mediaElementAudioSourceHandler().unlock(); |
| 248 } | 271 } |
| 249 | 272 |
| 250 } // namespace blink | 273 } // namespace blink |
| 251 | 274 |
| OLD | NEW |