| 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 // manageable, especially |m_finishedSourceNodes| is likely to be short. | 668 // manageable, especially |m_finishedSourceNodes| is likely to be short. |
| 669 for (AudioNode* node : finished_source_nodes_) { | 669 for (AudioNode* node : finished_source_nodes_) { |
| 670 size_t i = active_source_nodes_.Find(node); | 670 size_t i = active_source_nodes_.Find(node); |
| 671 if (i != kNotFound) | 671 if (i != kNotFound) |
| 672 active_source_nodes_.erase(i); | 672 active_source_nodes_.erase(i); |
| 673 } | 673 } |
| 674 finished_source_nodes_.Clear(); | 674 finished_source_nodes_.Clear(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 bool BaseAudioContext::ReleaseFinishedSourceNodes() { | 677 bool BaseAudioContext::ReleaseFinishedSourceNodes() { |
| 678 ASSERT(IsGraphOwner()); | 678 DCHECK(IsGraphOwner()); |
| 679 DCHECK(IsAudioThread()); | 679 DCHECK(IsAudioThread()); |
| 680 bool did_remove = false; | 680 bool did_remove = false; |
| 681 for (AudioHandler* handler : finished_source_handlers_) { | 681 for (AudioHandler* handler : finished_source_handlers_) { |
| 682 for (AudioNode* node : active_source_nodes_) { | 682 for (AudioNode* node : active_source_nodes_) { |
| 683 if (finished_source_nodes_.Contains(node)) | 683 if (finished_source_nodes_.Contains(node)) |
| 684 continue; | 684 continue; |
| 685 if (handler == &node->Handler()) { | 685 if (handler == &node->Handler()) { |
| 686 handler->BreakConnection(); | 686 handler->BreakConnection(); |
| 687 finished_source_nodes_.insert(node); | 687 finished_source_nodes_.insert(node); |
| 688 did_remove = true; | 688 did_remove = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 704 | 704 |
| 705 void BaseAudioContext::ReleaseActiveSourceNodes() { | 705 void BaseAudioContext::ReleaseActiveSourceNodes() { |
| 706 DCHECK(IsMainThread()); | 706 DCHECK(IsMainThread()); |
| 707 for (auto& source_node : active_source_nodes_) | 707 for (auto& source_node : active_source_nodes_) |
| 708 source_node->Handler().BreakConnection(); | 708 source_node->Handler().BreakConnection(); |
| 709 | 709 |
| 710 active_source_nodes_.Clear(); | 710 active_source_nodes_.Clear(); |
| 711 } | 711 } |
| 712 | 712 |
| 713 void BaseAudioContext::HandleStoppableSourceNodes() { | 713 void BaseAudioContext::HandleStoppableSourceNodes() { |
| 714 ASSERT(IsGraphOwner()); | 714 DCHECK(IsGraphOwner()); |
| 715 | 715 |
| 716 // Find AudioBufferSourceNodes to see if we can stop playing them. | 716 // Find AudioBufferSourceNodes to see if we can stop playing them. |
| 717 for (AudioNode* node : active_source_nodes_) { | 717 for (AudioNode* node : active_source_nodes_) { |
| 718 // If the AudioNode has been marked as finished and released by | 718 // If the AudioNode has been marked as finished and released by |
| 719 // the audio thread, but not yet removed by the main thread | 719 // the audio thread, but not yet removed by the main thread |
| 720 // (see releaseActiveSourceNodes() above), |node| must not be | 720 // (see releaseActiveSourceNodes() above), |node| must not be |
| 721 // touched as its handler may have been released already. | 721 // touched as its handler may have been released already. |
| 722 if (finished_source_nodes_.Contains(node)) | 722 if (finished_source_nodes_.Contains(node)) |
| 723 continue; | 723 continue; |
| 724 if (node->Handler().GetNodeType() == | 724 if (node->Handler().GetNodeType() == |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 } | 796 } |
| 797 | 797 |
| 798 resume_resolvers_.Clear(); | 798 resume_resolvers_.Clear(); |
| 799 is_resolving_resume_promises_ = false; | 799 is_resolving_resume_promises_ = false; |
| 800 } | 800 } |
| 801 | 801 |
| 802 void BaseAudioContext::ResolvePromisesForResume() { | 802 void BaseAudioContext::ResolvePromisesForResume() { |
| 803 // This runs inside the BaseAudioContext's lock when handling pre-render | 803 // This runs inside the BaseAudioContext's lock when handling pre-render |
| 804 // tasks. | 804 // tasks. |
| 805 DCHECK(IsAudioThread()); | 805 DCHECK(IsAudioThread()); |
| 806 ASSERT(IsGraphOwner()); | 806 DCHECK(IsGraphOwner()); |
| 807 | 807 |
| 808 // Resolve any pending promises created by resume(). Only do this if we | 808 // Resolve any pending promises created by resume(). Only do this if we |
| 809 // haven't already started resolving these promises. This gets called very | 809 // haven't already started resolving these promises. This gets called very |
| 810 // often and it takes some time to resolve the promises in the main thread. | 810 // often and it takes some time to resolve the promises in the main thread. |
| 811 if (!is_resolving_resume_promises_ && resume_resolvers_.size() > 0) { | 811 if (!is_resolving_resume_promises_ && resume_resolvers_.size() > 0) { |
| 812 is_resolving_resume_promises_ = true; | 812 is_resolving_resume_promises_ = true; |
| 813 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( | 813 Platform::Current()->MainThread()->GetWebTaskRunner()->PostTask( |
| 814 BLINK_FROM_HERE, | 814 BLINK_FROM_HERE, |
| 815 CrossThreadBind(&BaseAudioContext::ResolvePromisesForResumeOnMainThread, | 815 CrossThreadBind(&BaseAudioContext::ResolvePromisesForResumeOnMainThread, |
| 816 WrapCrossThreadPersistent(this))); | 816 WrapCrossThreadPersistent(this))); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 } | 921 } |
| 922 | 922 |
| 923 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { | 923 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { |
| 924 if (GetExecutionContext()) | 924 if (GetExecutionContext()) |
| 925 return GetExecutionContext()->GetSecurityOrigin(); | 925 return GetExecutionContext()->GetSecurityOrigin(); |
| 926 | 926 |
| 927 return nullptr; | 927 return nullptr; |
| 928 } | 928 } |
| 929 | 929 |
| 930 } // namespace blink | 930 } // namespace blink |
| OLD | NEW |