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