Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 ~TrackDisplayUpdateScope() | 161 ~TrackDisplayUpdateScope() |
| 162 { | 162 { |
| 163 ASSERT(m_mediaElement); | 163 ASSERT(m_mediaElement); |
| 164 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); | 164 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; | 168 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 class AudioSourceProviderClientLockScope { | |
| 172 STACK_ALLOCATED(); | |
| 173 public: | |
| 174 #if ENABLE(WEB_AUDIO) | |
| 175 AudioSourceProviderClientLockScope(HTMLMediaElement& element) | |
|
haraken
2014/07/26 04:11:37
Add explicit.
tkent
2014/07/28 01:20:55
Done.
| |
| 176 : m_client(element.audioSourceNode()) | |
| 177 { | |
| 178 if (m_client) | |
| 179 m_client->lock(); | |
| 180 } | |
| 181 ~AudioSourceProviderClientLockScope() | |
| 182 { | |
| 183 if (m_client) | |
| 184 m_client->unlock(); | |
| 185 } | |
| 186 | |
| 187 private: | |
| 188 RawPtrWillBeMember<AudioSourceProviderClient> m_client; | |
|
haraken
2014/07/26 04:11:37
I wonder if we can just use RefPtrWillBeMember<Aud
tkent
2014/07/28 01:20:55
Done. But do you think Patch Set 3 is better than
| |
| 189 #else | |
| 190 AudioSourceProviderClientLockScope(HTMLMediaElement&) { } | |
| 191 ~AudioSourceProviderClientLockScope() { } | |
| 192 #endif | |
| 193 }; | |
| 194 | |
| 171 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind) | 195 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind) |
| 172 { | 196 { |
| 173 switch (kind) { | 197 switch (kind) { |
| 174 case WebMediaPlayerClient::AudioTrackKindNone: | 198 case WebMediaPlayerClient::AudioTrackKindNone: |
| 175 return emptyAtom; | 199 return emptyAtom; |
| 176 case WebMediaPlayerClient::AudioTrackKindAlternative: | 200 case WebMediaPlayerClient::AudioTrackKindAlternative: |
| 177 return AudioTrack::alternativeKeyword(); | 201 return AudioTrack::alternativeKeyword(); |
| 178 case WebMediaPlayerClient::AudioTrackKindDescriptions: | 202 case WebMediaPlayerClient::AudioTrackKindDescriptions: |
| 179 return AudioTrack::descriptionsKeyword(); | 203 return AudioTrack::descriptionsKeyword(); |
| 180 case WebMediaPlayerClient::AudioTrackKindMain: | 204 case WebMediaPlayerClient::AudioTrackKindMain: |
| (...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3386 } | 3410 } |
| 3387 | 3411 |
| 3388 void HTMLMediaElement::clearMediaPlayer(int flags) | 3412 void HTMLMediaElement::clearMediaPlayer(int flags) |
| 3389 { | 3413 { |
| 3390 forgetResourceSpecificTracks(); | 3414 forgetResourceSpecificTracks(); |
| 3391 | 3415 |
| 3392 closeMediaSource(); | 3416 closeMediaSource(); |
| 3393 | 3417 |
| 3394 cancelDeferredLoad(); | 3418 cancelDeferredLoad(); |
| 3395 | 3419 |
| 3396 #if ENABLE(WEB_AUDIO) | 3420 { |
| 3397 if (m_audioSourceNode) | 3421 AudioSourceProviderClientLockScope scope(*this); |
| 3398 m_audioSourceNode->lock(); | 3422 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3399 #endif | 3423 } |
| 3400 | |
| 3401 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | |
| 3402 | |
| 3403 #if ENABLE(WEB_AUDIO) | |
| 3404 if (m_audioSourceNode) | |
| 3405 m_audioSourceNode->unlock(); | |
| 3406 #endif | |
| 3407 | 3424 |
| 3408 stopPeriodicTimers(); | 3425 stopPeriodicTimers(); |
| 3409 m_loadTimer.stop(); | 3426 m_loadTimer.stop(); |
| 3410 | 3427 |
| 3411 m_pendingActionFlags &= ~flags; | 3428 m_pendingActionFlags &= ~flags; |
| 3412 m_loadState = WaitingForSource; | 3429 m_loadState = WaitingForSource; |
| 3413 | 3430 |
| 3414 if (m_textTracks) | 3431 if (m_textTracks) |
| 3415 configureTextTrackDisplay(AssumeNoVisibleChange); | 3432 configureTextTrackDisplay(AssumeNoVisibleChange); |
| 3416 } | 3433 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3681 void* HTMLMediaElement::preDispatchEventHandler(Event* event) | 3698 void* HTMLMediaElement::preDispatchEventHandler(Event* event) |
| 3682 { | 3699 { |
| 3683 if (event && event->type() == EventTypeNames::webkitfullscreenchange) | 3700 if (event && event->type() == EventTypeNames::webkitfullscreenchange) |
| 3684 configureMediaControls(); | 3701 configureMediaControls(); |
| 3685 | 3702 |
| 3686 return 0; | 3703 return 0; |
| 3687 } | 3704 } |
| 3688 | 3705 |
| 3689 void HTMLMediaElement::createMediaPlayer() | 3706 void HTMLMediaElement::createMediaPlayer() |
| 3690 { | 3707 { |
| 3691 #if ENABLE(WEB_AUDIO) | 3708 AudioSourceProviderClientLockScope scope(*this); |
| 3692 if (m_audioSourceNode) | |
| 3693 m_audioSourceNode->lock(); | |
| 3694 #endif | |
| 3695 | 3709 |
| 3696 closeMediaSource(); | 3710 closeMediaSource(); |
| 3697 | 3711 |
| 3698 m_player = MediaPlayer::create(this); | 3712 m_player = MediaPlayer::create(this); |
| 3699 | 3713 |
| 3700 #if ENABLE(WEB_AUDIO) | 3714 #if ENABLE(WEB_AUDIO) |
| 3701 if (m_audioSourceNode) { | 3715 if (m_audioSourceNode && audioSourceProvider()) { |
| 3702 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. | 3716 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. |
| 3703 if (audioSourceProvider()) | 3717 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3704 audioSourceProvider()->setClient(m_audioSourceNode); | |
| 3705 | |
| 3706 m_audioSourceNode->unlock(); | |
| 3707 } | 3718 } |
| 3708 #endif | 3719 #endif |
| 3709 } | 3720 } |
| 3710 | 3721 |
| 3711 #if ENABLE(WEB_AUDIO) | 3722 #if ENABLE(WEB_AUDIO) |
| 3712 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3723 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| 3713 { | 3724 { |
| 3714 m_audioSourceNode = sourceNode; | 3725 m_audioSourceNode = sourceNode; |
| 3715 | 3726 |
| 3716 if (m_audioSourceNode) | 3727 AudioSourceProviderClientLockScope scope(*this); |
| 3717 m_audioSourceNode->lock(); | |
| 3718 | |
| 3719 if (audioSourceProvider()) | 3728 if (audioSourceProvider()) |
| 3720 audioSourceProvider()->setClient(m_audioSourceNode); | 3729 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3721 | |
| 3722 if (m_audioSourceNode) | |
| 3723 m_audioSourceNode->unlock(); | |
| 3724 } | 3730 } |
| 3725 | 3731 |
| 3726 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() | 3732 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() |
| 3727 { | 3733 { |
| 3728 if (m_player) | 3734 if (m_player) |
| 3729 return m_player->audioSourceProvider(); | 3735 return m_player->audioSourceProvider(); |
| 3730 | 3736 |
| 3731 return 0; | 3737 return 0; |
| 3732 } | 3738 } |
| 3733 #endif | 3739 #endif |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3963 | 3969 |
| 3964 #if ENABLE(WEB_AUDIO) | 3970 #if ENABLE(WEB_AUDIO) |
| 3965 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3971 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3966 { | 3972 { |
| 3967 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3973 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3968 audioSourceProvider()->setClient(0); | 3974 audioSourceProvider()->setClient(0); |
| 3969 } | 3975 } |
| 3970 #endif | 3976 #endif |
| 3971 | 3977 |
| 3972 } | 3978 } |
| OLD | NEW |